Make a different map for iq stanza + handle iq response without containing HTTP Auth namespace
This commit is contained in:
parent
7ecfbfe63b
commit
6de5cee2ca
6
main.go
6
main.go
|
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
Version = "v0.1.0"
|
||||
Version = "v0.1.1"
|
||||
configurationFilePath = "httpAuth.cfg"
|
||||
|
||||
default_xmpp_server_address = "127.0.0.1"
|
||||
|
|
@ -35,12 +35,12 @@ func init() {
|
|||
// HTTP config
|
||||
httpTimeout, err := strconv.Atoi(mapConfig["http_timeoute_sec"])
|
||||
if err == nil {
|
||||
log.Println("Define HTTP timeout to "+strconv.Itoa(httpTimeout)+" second")
|
||||
log.Println("Define HTTP timeout to " + strconv.Itoa(httpTimeout) + " second")
|
||||
http.TimeoutSec = httpTimeout
|
||||
}
|
||||
httpPort, err := strconv.Atoi(mapConfig["http_port"])
|
||||
if err == nil {
|
||||
log.Println("Define HTTP port to "+strconv.Itoa(httpPort))
|
||||
log.Println("Define HTTP port to " + strconv.Itoa(httpPort))
|
||||
http.HttpPortBind = httpPort
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func (client *Client) askViaIQ() {
|
|||
m := xmpp.Iq{Type: xmpp.IQTypeGet, To: client.JID, From: jid.Domain, Id: stanzaIDstr}
|
||||
confirm := &xmpp.Confirm{Id: client.Transaction, Method: client.Method, URL: client.Domain}
|
||||
m.PayloadEncode(confirm)
|
||||
WaitMessageAnswers[stanzaIDstr] = client
|
||||
WaitIqMessages[stanzaIDstr] = client
|
||||
comp.Out <- m
|
||||
}
|
||||
|
||||
|
|
|
|||
12
xmpp/xmpp.go
12
xmpp/xmpp.go
|
|
@ -28,6 +28,7 @@ var (
|
|||
ChanAction = make(chan string)
|
||||
|
||||
WaitMessageAnswers = make(map[string]*Client)
|
||||
WaitIqMessages = make(map[string]*Client)
|
||||
|
||||
Debug = true
|
||||
)
|
||||
|
|
@ -76,15 +77,22 @@ func mainXMPP() {
|
|||
case xmpp.NSHTTPAuth:
|
||||
confirm := &xmpp.Confirm{}
|
||||
v.PayloadDecode(confirm)
|
||||
client := WaitMessageAnswers[v.Id]
|
||||
delete(WaitMessageAnswers, v.Id)
|
||||
client := WaitIqMessages[v.Id]
|
||||
delete(WaitIqMessages, v.Id)
|
||||
processConfirm(v, client)
|
||||
|
||||
default:
|
||||
// Handle reply iq that doesn't contain HTTP-Auth namespace
|
||||
client := WaitIqMessages[v.Id]
|
||||
delete(WaitIqMessages, v.Id)
|
||||
processConfirm(v, client)
|
||||
|
||||
if client == nil {
|
||||
reply := v.Response(xmpp.IQTypeError)
|
||||
reply.PayloadEncode(xmpp.NewError("cancel", xmpp.FeatureNotImplemented, ""))
|
||||
comp.Out <- reply
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
log.Printf("%srecv: %v", LogDebug, x)
|
||||
|
|
|
|||
Loading…
Reference in New Issue