forked from chteufleur/go-xmpp4steam
XMPP debug in config file + stability
This commit is contained in:
parent
95a589c802
commit
42c3787a0a
20
main.go
20
main.go
|
|
@ -15,7 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "go-xmpp4steam v0.1.2"
|
Version = "go-xmpp4steam v0.1.3"
|
||||||
configurationFilePath = "xmpp4steam.cfg"
|
configurationFilePath = "xmpp4steam.cfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -35,6 +35,7 @@ func init() {
|
||||||
xmpp.JidStr = mapConfig["xmpp_hostname"]
|
xmpp.JidStr = mapConfig["xmpp_hostname"]
|
||||||
xmpp.Secret = mapConfig["xmpp_secret"]
|
xmpp.Secret = mapConfig["xmpp_secret"]
|
||||||
xmpp.PreferedJID = mapConfig["xmpp_authorized_jid"]
|
xmpp.PreferedJID = mapConfig["xmpp_authorized_jid"]
|
||||||
|
xmpp.Debug = mapConfig["xmpp_debug"] == "true"
|
||||||
|
|
||||||
// Steam config
|
// Steam config
|
||||||
steam.Username = mapConfig["steam_login"]
|
steam.Username = mapConfig["steam_login"]
|
||||||
|
|
@ -64,18 +65,25 @@ func main() {
|
||||||
|
|
||||||
// XMPP -> Steam gateways
|
// XMPP -> Steam gateways
|
||||||
func gatewayXmppSteamAction() {
|
func gatewayXmppSteamAction() {
|
||||||
|
connecting := false
|
||||||
for {
|
for {
|
||||||
action := <-xmpp.ChanAction
|
action := <-xmpp.ChanAction
|
||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case xmpp.ActionConnexion:
|
case xmpp.ActionConnexion:
|
||||||
if !steam.IsConnected() {
|
if !steam.IsConnected() {
|
||||||
steam.Connect()
|
if !connecting {
|
||||||
|
steam.Connect()
|
||||||
|
connecting = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
connecting = false
|
||||||
}
|
}
|
||||||
|
|
||||||
case xmpp.ActionDeconnexion:
|
case xmpp.ActionDeconnexion:
|
||||||
if steam.IsConnected() {
|
if steam.IsConnected() {
|
||||||
steam.Disconnect()
|
steam.Disconnect()
|
||||||
|
connecting = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,8 +155,8 @@ func gatewaySteamXmppMessage() {
|
||||||
|
|
||||||
func gatewaySteamXmppPresence() {
|
func gatewaySteamXmppPresence() {
|
||||||
for {
|
for {
|
||||||
// name := steam.ChanPresence
|
|
||||||
steamId := <-steam.ChanPresence
|
steamId := <-steam.ChanPresence
|
||||||
|
name := <- steam.ChanPresence
|
||||||
stat := <-steam.ChanPresenceSteam
|
stat := <-steam.ChanPresenceSteam
|
||||||
gameName := <-steam.ChanPresence
|
gameName := <-steam.ChanPresence
|
||||||
|
|
||||||
|
|
@ -177,17 +185,17 @@ func gatewaySteamXmppPresence() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := SetSteamId[steamId]; !ok {
|
if _, ok := SetSteamId[steamId]; !ok {
|
||||||
xmpp.SendPresenceFrom(status, xmpp.Type_subscribe, steamId+"@"+xmpp.JidStr, gameName)
|
xmpp.SendPresenceFrom(status, xmpp.Type_subscribe, steamId+"@"+xmpp.JidStr, gameName, name)
|
||||||
SetSteamId[steamId] = struct{}{}
|
SetSteamId[steamId] = struct{}{}
|
||||||
}
|
}
|
||||||
xmpp.SendPresenceFrom(status, tpye, steamId+"@"+xmpp.JidStr, gameName)
|
xmpp.SendPresenceFrom(status, tpye, steamId+"@"+xmpp.JidStr, gameName, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func disconnectAllSteamUser() {
|
func disconnectAllSteamUser() {
|
||||||
for sid, _ := range SetSteamId {
|
for sid, _ := range SetSteamId {
|
||||||
xmpp.SendPresenceFrom(xmpp.Status_offline, xmpp.Type_unavailable, sid+"@"+xmpp.JidStr, "")
|
xmpp.SendPresenceFrom(xmpp.Status_offline, xmpp.Type_unavailable, sid+"@"+xmpp.JidStr, "", "")
|
||||||
delete(SetSteamId, sid)
|
delete(SetSteamId, sid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"Addresses":[{"IP":"162.254.196.42","Port":27020},{"IP":"162.254.196.42","Port":27021},{"IP":"162.254.196.43","Port":27019},{"IP":"162.254.196.43","Port":27018},{"IP":"162.254.196.41","Port":27017},{"IP":"162.254.196.43","Port":27020},{"IP":"162.254.196.42","Port":27018},{"IP":"162.254.196.42","Port":27017},{"IP":"162.254.196.40","Port":27018},{"IP":"162.254.196.41","Port":27021},{"IP":"162.254.196.42","Port":27019},{"IP":"146.66.152.11","Port":27017},{"IP":"162.254.196.41","Port":27018},{"IP":"162.254.196.41","Port":27019},{"IP":"162.254.196.40","Port":27017},{"IP":"162.254.196.40","Port":27019},{"IP":"162.254.196.43","Port":27021},{"IP":"162.254.196.40","Port":27021},{"IP":"162.254.196.41","Port":27020},{"IP":"146.66.152.10","Port":27019},{"IP":"146.66.152.11","Port":27019},{"IP":"162.254.197.40","Port":27019},{"IP":"162.254.197.41","Port":27019},{"IP":"162.254.197.41","Port":27020},{"IP":"146.66.152.10","Port":27017},{"IP":"162.254.196.43","Port":27017},{"IP":"162.254.197.41","Port":27018},{"IP":"146.66.152.10","Port":27020},{"IP":"146.66.152.10","Port":27018},{"IP":"162.254.197.40","Port":27020},{"IP":"162.254.197.42","Port":27020},{"IP":"146.66.152.11","Port":27018},{"IP":"162.254.197.42","Port":27019},{"IP":"162.254.197.41","Port":27017},{"IP":"162.254.196.40","Port":27020},{"IP":"162.254.197.41","Port":27021},{"IP":"162.254.197.42","Port":27021},{"IP":"162.254.197.42","Port":27018},{"IP":"162.254.197.40","Port":27021},{"IP":"162.254.197.40","Port":27017},{"IP":"146.66.152.11","Port":27020},{"IP":"162.254.197.40","Port":27018},{"IP":"162.254.197.42","Port":27017},{"IP":"185.25.180.15","Port":27019},{"IP":"146.66.155.8","Port":27020},{"IP":"185.25.182.10","Port":27018},{"IP":"155.133.242.9","Port":27019},{"IP":"155.133.242.9","Port":27017},{"IP":"185.25.180.15","Port":27020},{"IP":"185.25.180.14","Port":27017},{"IP":"185.25.182.10","Port":27019},{"IP":"185.25.182.10","Port":27020},{"IP":"146.66.155.8","Port":27017},{"IP":"155.133.242.9","Port":27020},{"IP":"185.25.180.15","Port":27018},{"IP":"155.133.242.9","Port":27018},{"IP":"185.25.182.10","Port":27017},{"IP":"185.25.180.14","Port":27019},{"IP":"185.25.180.14","Port":27020},{"IP":"155.133.242.8","Port":27018},{"IP":"155.133.242.8","Port":27017},{"IP":"155.133.242.8","Port":27019},{"IP":"146.66.155.8","Port":27019},{"IP":"146.66.155.8","Port":27018},{"IP":"185.25.180.15","Port":27017},{"IP":"155.133.242.8","Port":27020},{"IP":"185.25.180.14","Port":27018},{"IP":"208.78.164.14","Port":27019},{"IP":"208.78.164.14","Port":27018},{"IP":"208.78.164.14","Port":27017},{"IP":"208.78.164.11","Port":27018},{"IP":"208.78.164.9","Port":27018},{"IP":"208.78.164.12","Port":27019},{"IP":"208.78.164.9","Port":27019},{"IP":"208.78.164.11","Port":27017},{"IP":"208.78.164.9","Port":27017},{"IP":"208.78.164.13","Port":27017},{"IP":"208.78.164.12","Port":27017},{"IP":"208.78.164.10","Port":27017},{"IP":"208.78.164.10","Port":27018}]}
|
{"Addresses":[{"IP":"162.254.196.40","Port":27021},{"IP":"162.254.196.42","Port":27018},{"IP":"162.254.196.43","Port":27020},{"IP":"162.254.196.43","Port":27019},{"IP":"162.254.196.40","Port":27018},{"IP":"162.254.196.42","Port":27019},{"IP":"162.254.196.41","Port":27018},{"IP":"162.254.197.41","Port":27019},{"IP":"162.254.197.40","Port":27018},{"IP":"162.254.197.41","Port":27020},{"IP":"162.254.197.41","Port":27018},{"IP":"146.66.152.11","Port":27020},{"IP":"146.66.152.11","Port":27018},{"IP":"146.66.152.11","Port":27019},{"IP":"162.254.196.41","Port":27021},{"IP":"162.254.196.41","Port":27017},{"IP":"162.254.196.41","Port":27020},{"IP":"162.254.196.42","Port":27021},{"IP":"162.254.197.42","Port":27020},{"IP":"162.254.197.40","Port":27020},{"IP":"146.66.152.10","Port":27017},{"IP":"146.66.152.10","Port":27020},{"IP":"162.254.196.43","Port":27018},{"IP":"162.254.196.40","Port":27020},{"IP":"162.254.196.43","Port":27021},{"IP":"162.254.196.42","Port":27020},{"IP":"162.254.196.43","Port":27017},{"IP":"162.254.196.42","Port":27017},{"IP":"162.254.197.40","Port":27021},{"IP":"162.254.197.42","Port":27018},{"IP":"162.254.197.42","Port":27021},{"IP":"162.254.197.42","Port":27019},{"IP":"146.66.152.10","Port":27018},{"IP":"146.66.152.11","Port":27017},{"IP":"162.254.196.40","Port":27017},{"IP":"162.254.196.40","Port":27019},{"IP":"162.254.197.40","Port":27017},{"IP":"162.254.197.41","Port":27017},{"IP":"162.254.197.41","Port":27021},{"IP":"162.254.196.41","Port":27019},{"IP":"162.254.197.40","Port":27019},{"IP":"146.66.152.10","Port":27019},{"IP":"162.254.197.42","Port":27017},{"IP":"155.133.242.9","Port":27020},{"IP":"155.133.242.9","Port":27019},{"IP":"155.133.242.9","Port":27018},{"IP":"185.25.180.15","Port":27018},{"IP":"185.25.180.15","Port":27020},{"IP":"185.25.180.14","Port":27018},{"IP":"185.25.180.15","Port":27017},{"IP":"155.133.242.8","Port":27019},{"IP":"185.25.180.15","Port":27019},{"IP":"185.25.180.14","Port":27017},{"IP":"185.25.180.14","Port":27020},{"IP":"155.133.242.8","Port":27020},{"IP":"146.66.155.8","Port":27017},{"IP":"155.133.242.9","Port":27017},{"IP":"155.133.242.8","Port":27018},{"IP":"146.66.155.8","Port":27020},{"IP":"185.25.182.10","Port":27018},{"IP":"185.25.180.14","Port":27019},{"IP":"146.66.155.8","Port":27018},{"IP":"185.25.182.10","Port":27017},{"IP":"155.133.242.8","Port":27017},{"IP":"185.25.182.10","Port":27020},{"IP":"185.25.182.10","Port":27019},{"IP":"146.66.155.8","Port":27019},{"IP":"208.78.164.9","Port":27018},{"IP":"208.78.164.9","Port":27019},{"IP":"208.78.164.10","Port":27019},{"IP":"208.78.164.10","Port":27018},{"IP":"208.78.164.9","Port":27017},{"IP":"208.78.164.11","Port":27019},{"IP":"208.78.164.14","Port":27019},{"IP":"208.78.164.13","Port":27017},{"IP":"208.78.164.12","Port":27018},{"IP":"208.78.164.14","Port":27017},{"IP":"208.78.164.10","Port":27017},{"IP":"208.78.164.12","Port":27017},{"IP":"208.78.164.14","Port":27018}]}
|
||||||
|
|
@ -87,8 +87,8 @@ func mainSteam() {
|
||||||
ioutil.WriteFile(serverAddrs, b, 0666)
|
ioutil.WriteFile(serverAddrs, b, 0666)
|
||||||
|
|
||||||
case *steam.PersonaStateEvent:
|
case *steam.PersonaStateEvent:
|
||||||
// ChanPresence <- e.Name
|
|
||||||
ChanPresence <- e.FriendId.ToString()
|
ChanPresence <- e.FriendId.ToString()
|
||||||
|
ChanPresence <- e.Name
|
||||||
ChanPresenceSteam <- e.State
|
ChanPresenceSteam <- e.State
|
||||||
ChanPresence <- e.GameName
|
ChanPresence <- e.GameName
|
||||||
|
|
||||||
|
|
|
||||||
12
xmpp/xmpp.go
12
xmpp/xmpp.go
|
|
@ -49,13 +49,15 @@ var (
|
||||||
ChanAction = make(chan string)
|
ChanAction = make(chan string)
|
||||||
|
|
||||||
CurrentStatus = Status_offline
|
CurrentStatus = Status_offline
|
||||||
|
|
||||||
|
Debug = true
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
log.Printf("%sRunning", LogInfo)
|
log.Printf("%sRunning", LogInfo)
|
||||||
// Create stream and configure it as a component connection.
|
// Create stream and configure it as a component connection.
|
||||||
jid = must(xmpp.ParseJID(JidStr)).(xmpp.JID)
|
jid = must(xmpp.ParseJID(JidStr)).(xmpp.JID)
|
||||||
stream = must(xmpp.NewStream(Addr, &xmpp.StreamConfig{LogStanzas: true})).(*xmpp.Stream)
|
stream = must(xmpp.NewStream(Addr, &xmpp.StreamConfig{LogStanzas: Debug})).(*xmpp.Stream)
|
||||||
comp = must(xmpp.NewComponentXMPP(stream, jid, Secret)).(*xmpp.XMPP)
|
comp = must(xmpp.NewComponentXMPP(stream, jid, Secret)).(*xmpp.XMPP)
|
||||||
|
|
||||||
mainXMPP()
|
mainXMPP()
|
||||||
|
|
@ -108,11 +110,15 @@ func SendPresence(status, tpye, message string) {
|
||||||
comp.Out <- xmpp.Presence{To: PreferedJID, From: jid.Domain, Show: status, Type: tpye, Status: message}
|
comp.Out <- xmpp.Presence{To: PreferedJID, From: jid.Domain, Show: status, Type: tpye, Status: message}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendPresenceFrom(status, tpye, from, message string) {
|
func SendPresenceFrom(status, tpye, from, message, nick string) {
|
||||||
if message == "" {
|
if message == "" {
|
||||||
|
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Nick: nick}
|
||||||
|
} else if nick == "" {
|
||||||
|
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Status: message}
|
||||||
|
} else if nick == "" {
|
||||||
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye}
|
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye}
|
||||||
} else {
|
} else {
|
||||||
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Status: message}
|
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Status: message, Nick: nick}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ xmpp_server_port=5347
|
||||||
xmpp_hostname=xmppsteam.kingpenguin.tk
|
xmpp_hostname=xmppsteam.kingpenguin.tk
|
||||||
xmpp_secret=xmpp4steam_password
|
xmpp_secret=xmpp4steam_password
|
||||||
xmpp_authorized_jid=chteufleur@kingpenguin.tk
|
xmpp_authorized_jid=chteufleur@kingpenguin.tk
|
||||||
|
xmpp_debug=true
|
||||||
|
|
||||||
# Steam informations
|
# Steam informations
|
||||||
steam_login=toto
|
steam_login=toto
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue