flag for authcode
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package csgo
|
package csgo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/an0nfunc/go-steam/v3"
|
"github.com/an0nfunc/go-steam/v3"
|
||||||
@@ -128,11 +127,12 @@ func (d *DemoMatchLoader) connectToSteam() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DemoMatchLoader) Setup(username string) error {
|
func (d *DemoMatchLoader) Setup(username string, authCode string) error {
|
||||||
d.steamLogin = new(steam.LogOnDetails)
|
d.steamLogin = new(steam.LogOnDetails)
|
||||||
d.steamLogin.Username = username
|
d.steamLogin.Username = username
|
||||||
d.steamLogin.Password = os.Getenv("STEAM_PASSWORD")
|
d.steamLogin.Password = os.Getenv("STEAM_PASSWORD")
|
||||||
d.steamLogin.ShouldRememberPassword = true
|
d.steamLogin.ShouldRememberPassword = true
|
||||||
|
d.steamLogin.AuthCode = authCode
|
||||||
|
|
||||||
if _, err := os.Stat(SENTRYFILE); err == nil {
|
if _, err := os.Stat(SENTRYFILE); err == nil {
|
||||||
hash, err := ioutil.ReadFile(SENTRYFILE)
|
hash, err := ioutil.ReadFile(SENTRYFILE)
|
||||||
@@ -208,10 +208,7 @@ func (d *DemoMatchLoader) steamEventHandler() {
|
|||||||
log.Warningf("[DL] Steam login denied: %+v", e)
|
log.Warningf("[DL] Steam login denied: %+v", e)
|
||||||
switch e.Result {
|
switch e.Result {
|
||||||
case steamlang.EResult_AccountLogonDenied:
|
case steamlang.EResult_AccountLogonDenied:
|
||||||
log.Warningf("[DL] Asking for auth code now, please provide on stdin.")
|
log.Warningf("[DL] Please provide AuthCode with --authcode")
|
||||||
scanner := bufio.NewScanner(os.Stdin)
|
|
||||||
scanner.Scan()
|
|
||||||
d.steamLogin.AuthCode = scanner.Text()
|
|
||||||
}
|
}
|
||||||
case *steam.DisconnectedEvent:
|
case *steam.DisconnectedEvent:
|
||||||
log.Warningf("Steam disconnected, trying to reconnect...")
|
log.Warningf("Steam disconnected, trying to reconnect...")
|
||||||
|
21
main.go
21
main.go
@@ -28,15 +28,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
conf = utils.Conf{}
|
conf = utils.Conf{}
|
||||||
demoLoader = &csgo.DemoMatchLoader{}
|
demoLoader = &csgo.DemoMatchLoader{}
|
||||||
router *mux.Router
|
router *mux.Router
|
||||||
db *utils.DBWithLock
|
db *utils.DBWithLock
|
||||||
sendGC chan *csgo.Demo
|
sendGC chan *csgo.Demo
|
||||||
demoParser = &csgo.DemoParser{}
|
demoParser = &csgo.DemoParser{}
|
||||||
firstHK = true
|
firstHK = true
|
||||||
rL ratelimit.Limiter
|
rL ratelimit.Limiter
|
||||||
configFlag = flag.String("config", "config.yaml", "Set config to use")
|
configFlag = flag.String("config", "config.yaml", "Set config to use")
|
||||||
|
authCodeFlag = flag.String("authcode", "", "Provide Steam AuthCode to login")
|
||||||
)
|
)
|
||||||
|
|
||||||
type PlayerResponse struct {
|
type PlayerResponse struct {
|
||||||
@@ -389,7 +390,7 @@ func main() {
|
|||||||
|
|
||||||
rL = ratelimit.New(conf.Steam.RatePerSecond)
|
rL = ratelimit.New(conf.Steam.RatePerSecond)
|
||||||
// setup GC
|
// setup GC
|
||||||
err = demoLoader.Setup(conf.Steam.Username)
|
err = demoLoader.Setup(conf.Steam.Username, *authCodeFlag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Unbale to setup DemoLoader: %v", err)
|
log.Fatalf("Unbale to setup DemoLoader: %v", err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user