forked from chteufleur/go-xmpp4steam
Fix received auth code
Fix XMPP comp out when user registrered Send offline presence when program exit
This commit is contained in:
parent
ce3b45b492
commit
9103fe6ecd
|
|
@ -16,7 +16,6 @@ type GatewayInfo struct {
|
||||||
// Steam
|
// Steam
|
||||||
SteamLogin string
|
SteamLogin string
|
||||||
SteamPassword string
|
SteamPassword string
|
||||||
SteamAuthCode string
|
|
||||||
SteamLoginInfo *steam.LogOnDetails
|
SteamLoginInfo *steam.LogOnDetails
|
||||||
SteamClient *steam.Client
|
SteamClient *steam.Client
|
||||||
SentryFile string
|
SentryFile string
|
||||||
|
|
@ -33,5 +32,5 @@ func (g *GatewayInfo) Run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GatewayInfo) SetSteamAuthCode(authCode string) {
|
func (g *GatewayInfo) SetSteamAuthCode(authCode string) {
|
||||||
g.SteamAuthCode = authCode
|
g.SteamLoginInfo.AuthCode = authCode
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
// "time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -34,7 +34,7 @@ func (g *GatewayInfo) SteamRun() {
|
||||||
g.setLoginInfos()
|
g.setLoginInfos()
|
||||||
g.SteamClient = steam.NewClient()
|
g.SteamClient = steam.NewClient()
|
||||||
g.SteamConnecting = false
|
g.SteamConnecting = false
|
||||||
// g.SteamClient.ConnectionTimeout = 10 * time.Second
|
g.SteamClient.ConnectionTimeout = 10 * time.Second
|
||||||
|
|
||||||
g.mainSteam()
|
g.mainSteam()
|
||||||
|
|
||||||
|
|
@ -131,13 +131,8 @@ func (g *GatewayInfo) setLoginInfos() {
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
g.SteamLoginInfo.SentryFileHash = sentryHash
|
g.SteamLoginInfo.SentryFileHash = sentryHash
|
||||||
log.Printf("%sAuthentification by SentryFileHash", LogSteamDebug)
|
|
||||||
} else if g.SteamAuthCode != "" {
|
|
||||||
g.SteamLoginInfo.AuthCode = g.SteamAuthCode
|
|
||||||
log.Printf("%sAuthentification by AuthCode (%s, %s, %s)", LogSteamDebug, g.SteamLoginInfo.Username, g.SteamLoginInfo.Password, g.SteamAuthCode)
|
|
||||||
} else {
|
|
||||||
log.Printf("%sFirst authentification (%s, %s)", LogSteamDebug, g.SteamLoginInfo.Username, g.SteamLoginInfo.Password)
|
|
||||||
}
|
}
|
||||||
|
log.Printf("%sAuthentification of (%s, %s)", LogSteamDebug, g.XMPP_JID_Client, g.SteamLoginInfo.Username)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GatewayInfo) IsSteamConnected() bool {
|
func (g *GatewayInfo) IsSteamConnected() bool {
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ func (g *GatewayInfo) SendXmppPresence(status, tpye, from, message, nick string)
|
||||||
p.Nick = nick
|
p.Nick = nick
|
||||||
}
|
}
|
||||||
if from == "" {
|
if from == "" {
|
||||||
|
// TODO add an option to allow message comming directly from the gateway
|
||||||
p.From = XmppJidComponent
|
p.From = XmppJidComponent
|
||||||
} else {
|
} else {
|
||||||
p.From = from
|
p.From = from
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -15,7 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "go-xmpp4steam v0.3.1"
|
Version = "go-xmpp4steam v0.3.2"
|
||||||
configurationFilePath = "xmpp4steam.cfg"
|
configurationFilePath = "xmpp4steam.cfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"Addresses":[{"IP":"146.66.152.11","Port":27017},{"IP":"146.66.152.11","Port":27018},{"IP":"146.66.152.11","Port":27019},{"IP":"146.66.152.10","Port":27020},{"IP":"146.66.152.11","Port":27020},{"IP":"162.254.197.41","Port":27018},{"IP":"146.66.152.10","Port":27019},{"IP":"146.66.152.10","Port":27017},{"IP":"162.254.197.42","Port":27021},{"IP":"162.254.197.40","Port":27019},{"IP":"146.66.152.10","Port":27018},{"IP":"162.254.197.41","Port":27021},{"IP":"162.254.197.40","Port":27018},{"IP":"162.254.197.40","Port":27021},{"IP":"162.254.197.42","Port":27018},{"IP":"162.254.197.41","Port":27017},{"IP":"162.254.197.42","Port":27017},{"IP":"162.254.197.41","Port":27019},{"IP":"162.254.197.42","Port":27019},{"IP":"162.254.197.40","Port":27020},{"IP":"162.254.197.41","Port":27020},{"IP":"162.254.197.40","Port":27017},{"IP":"162.254.197.42","Port":27020},{"IP":"162.254.196.40","Port":27021},{"IP":"162.254.196.42","Port":27017},{"IP":"162.254.196.41","Port":27021},{"IP":"162.254.196.43","Port":27021},{"IP":"162.254.196.41","Port":27017},{"IP":"162.254.196.42","Port":27019},{"IP":"162.254.196.41","Port":27019},{"IP":"162.254.196.40","Port":27018},{"IP":"162.254.196.43","Port":27019},{"IP":"162.254.196.43","Port":27017},{"IP":"162.254.196.40","Port":27019},{"IP":"162.254.196.43","Port":27018},{"IP":"162.254.196.42","Port":27018},{"IP":"162.254.196.43","Port":27020},{"IP":"162.254.196.41","Port":27020},{"IP":"162.254.196.42","Port":27021},{"IP":"162.254.196.40","Port":27020},{"IP":"162.254.196.40","Port":27017},{"IP":"162.254.196.41","Port":27018},{"IP":"162.254.196.42","Port":27020},{"IP":"146.66.155.8","Port":27018},{"IP":"146.66.155.8","Port":27017},{"IP":"146.66.155.8","Port":27020},{"IP":"185.25.182.10","Port":27018},{"IP":"185.25.182.10","Port":27019},{"IP":"185.25.182.10","Port":27017},{"IP":"185.25.182.10","Port":27020},{"IP":"155.133.242.8","Port":27017},{"IP":"185.25.180.15","Port":27020},{"IP":"155.133.242.8","Port":27018},{"IP":"155.133.242.8","Port":27020},{"IP":"185.25.180.14","Port":27019},{"IP":"185.25.180.14","Port":27017},{"IP":"185.25.180.14","Port":27018},{"IP":"185.25.180.15","Port":27019},{"IP":"155.133.242.9","Port":27020},{"IP":"185.25.180.14","Port":27020},{"IP":"185.25.180.15","Port":27018},{"IP":"155.133.242.9","Port":27017},{"IP":"155.133.242.9","Port":27019},{"IP":"146.66.155.8","Port":27019},{"IP":"155.133.242.9","Port":27018},{"IP":"155.133.242.8","Port":27019},{"IP":"185.25.180.15","Port":27017},{"IP":"208.78.164.11","Port":27019},{"IP":"208.78.164.14","Port":27018},{"IP":"208.78.164.9","Port":27017},{"IP":"208.78.164.13","Port":27019},{"IP":"208.78.164.13","Port":27018},{"IP":"208.78.164.10","Port":27019},{"IP":"208.78.164.10","Port":27018},{"IP":"208.78.164.12","Port":27019},{"IP":"208.78.164.9","Port":27019},{"IP":"208.78.164.10","Port":27017},{"IP":"208.78.164.14","Port":27019},{"IP":"208.78.164.11","Port":27018},{"IP":"208.78.164.12","Port":27018}]}
|
{"Addresses":[{"IP":"162.254.197.42","Port":27020},{"IP":"146.66.152.10","Port":27020},{"IP":"146.66.152.11","Port":27020},{"IP":"162.254.197.40","Port":27019},{"IP":"162.254.197.42","Port":27019},{"IP":"146.66.152.10","Port":27018},{"IP":"162.254.197.40","Port":27021},{"IP":"162.254.197.42","Port":27017},{"IP":"146.66.152.10","Port":27019},{"IP":"146.66.152.10","Port":27017},{"IP":"146.66.152.11","Port":27019},{"IP":"162.254.197.41","Port":27018},{"IP":"162.254.197.40","Port":27020},{"IP":"162.254.197.41","Port":27019},{"IP":"162.254.197.40","Port":27017},{"IP":"162.254.197.41","Port":27017},{"IP":"146.66.152.11","Port":27018},{"IP":"146.66.152.11","Port":27017},{"IP":"162.254.197.40","Port":27018},{"IP":"162.254.197.42","Port":27021},{"IP":"162.254.197.42","Port":27018},{"IP":"162.254.197.41","Port":27020},{"IP":"162.254.197.41","Port":27021},{"IP":"162.254.196.41","Port":27019},{"IP":"162.254.196.41","Port":27021},{"IP":"162.254.196.41","Port":27017},{"IP":"162.254.196.40","Port":27017},{"IP":"162.254.196.43","Port":27018},{"IP":"162.254.196.43","Port":27017},{"IP":"162.254.196.42","Port":27018},{"IP":"162.254.196.42","Port":27021},{"IP":"162.254.196.42","Port":27020},{"IP":"162.254.196.43","Port":27020},{"IP":"162.254.196.41","Port":27020},{"IP":"162.254.196.41","Port":27018},{"IP":"162.254.196.43","Port":27021},{"IP":"162.254.196.42","Port":27019},{"IP":"162.254.196.43","Port":27019},{"IP":"162.254.196.42","Port":27017},{"IP":"162.254.196.40","Port":27018},{"IP":"162.254.196.40","Port":27019},{"IP":"146.66.155.8","Port":27018},{"IP":"185.25.182.10","Port":27018},{"IP":"146.66.155.8","Port":27019},{"IP":"185.25.182.10","Port":27017},{"IP":"146.66.155.8","Port":27017},{"IP":"185.25.182.10","Port":27020},{"IP":"185.25.182.10","Port":27019},{"IP":"146.66.155.8","Port":27020},{"IP":"155.133.242.9","Port":27020},{"IP":"185.25.180.14","Port":27019},{"IP":"155.133.242.8","Port":27020},{"IP":"155.133.242.9","Port":27018},{"IP":"185.25.180.15","Port":27018},{"IP":"185.25.180.14","Port":27017},{"IP":"185.25.180.15","Port":27017},{"IP":"185.25.180.14","Port":27020},{"IP":"185.25.180.15","Port":27019},{"IP":"162.254.196.40","Port":27021},{"IP":"185.25.180.15","Port":27020},{"IP":"185.25.180.14","Port":27018},{"IP":"155.133.242.9","Port":27017},{"IP":"155.133.242.9","Port":27019},{"IP":"162.254.196.40","Port":27020},{"IP":"155.133.242.8","Port":27017},{"IP":"155.133.242.8","Port":27019},{"IP":"155.133.242.8","Port":27018},{"IP":"208.78.164.10","Port":27018},{"IP":"208.78.164.11","Port":27019},{"IP":"208.78.164.14","Port":27018},{"IP":"208.78.164.11","Port":27018},{"IP":"208.78.164.14","Port":27017},{"IP":"208.78.164.12","Port":27018},{"IP":"208.78.164.13","Port":27019},{"IP":"208.78.164.13","Port":27017},{"IP":"208.78.164.13","Port":27018},{"IP":"208.78.164.10","Port":27017},{"IP":"208.78.164.14","Port":27019},{"IP":"208.78.164.11","Port":27017},{"IP":"208.78.164.10","Port":27019}]}
|
||||||
|
|
@ -53,6 +53,7 @@ func execCommandAdHoc(iq *xmpp.Iq) {
|
||||||
} else if adHoc.Node == CommandGetIdentifiants {
|
} else if adHoc.Node == CommandGetIdentifiants {
|
||||||
// Command Auth Code
|
// Command Auth Code
|
||||||
cmdXForm := &xmpp.AdHocXForm{Type: xmpp.TypeAdHocForm, Title: "Steam Account Info", Instructions: "Please provide your Steam login and password."}
|
cmdXForm := &xmpp.AdHocXForm{Type: xmpp.TypeAdHocForm, Title: "Steam Account Info", Instructions: "Please provide your Steam login and password."}
|
||||||
|
// TODO Warn that the given info is stored in database in clear
|
||||||
|
|
||||||
field := &xmpp.AdHocField{Var: "login", Label: "Steam Login", Type: xmpp.TypeAdHocFieldTextSingle}
|
field := &xmpp.AdHocField{Var: "login", Label: "Steam Login", Type: xmpp.TypeAdHocFieldTextSingle}
|
||||||
cmdXForm.Fields = append(cmdXForm.Fields, *field)
|
cmdXForm.Fields = append(cmdXForm.Fields, *field)
|
||||||
|
|
@ -131,9 +132,7 @@ func execCommandAdHoc(iq *xmpp.Iq) {
|
||||||
isSqlSuccess = dbUser.AddLine()
|
isSqlSuccess = dbUser.AddLine()
|
||||||
}
|
}
|
||||||
if isSqlSuccess {
|
if isSqlSuccess {
|
||||||
if !isUserRegistred {
|
AddNewUser(dbUser.Jid, dbUser.SteamLogin, dbUser.SteamPwd)
|
||||||
AddNewUser(dbUser.Jid, dbUser.SteamLogin, dbUser.SteamPwd)
|
|
||||||
}
|
|
||||||
note.Value = "Command succeded !"
|
note.Value = "Command succeded !"
|
||||||
} else {
|
} else {
|
||||||
note.Value = "Error append while executing command"
|
note.Value = "Error append while executing command"
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,9 @@ func must(v interface{}, err error) interface{} {
|
||||||
|
|
||||||
func Disconnect() {
|
func Disconnect() {
|
||||||
log.Printf("%sXMPP disconnect", LogInfo)
|
log.Printf("%sXMPP disconnect", LogInfo)
|
||||||
SendPresence(gateway.Status_offline, gateway.Type_unavailable, "", "", "", "")
|
for _, u := range MapGatewayInfo {
|
||||||
|
u.SteamDisconnect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendPresence(status, tpye, from, to, message, nick string) {
|
func SendPresence(status, tpye, from, to, message, nick string) {
|
||||||
|
|
@ -154,6 +156,8 @@ func AddNewUser(jid, steamLogin, steamPwd string) {
|
||||||
g.SentryFile = gateway.SentryDirectory + jid
|
g.SentryFile = gateway.SentryDirectory + jid
|
||||||
g.FriendSteamId = make(map[string]struct{})
|
g.FriendSteamId = make(map[string]struct{})
|
||||||
|
|
||||||
|
g.XMPP_Out = comp.Out
|
||||||
|
|
||||||
MapGatewayInfo[jid] = g
|
MapGatewayInfo[jid] = g
|
||||||
go g.Run()
|
go g.Run()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue