Skip to content

Commit

Permalink
Merge pull request #117 from Jleagle/master
Browse files Browse the repository at this point in the history
Remove dot aliases
  • Loading branch information
Philipp15b authored May 5, 2021
2 parents 8da11b6 + 70c092e commit 8cbbaf6
Show file tree
Hide file tree
Showing 23 changed files with 526 additions and 527 deletions.
78 changes: 39 additions & 39 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"sync/atomic"
"time"

. "github.com/Philipp15b/go-steam/v2/protocol"
. "github.com/Philipp15b/go-steam/v2/protocol/protobuf"
. "github.com/Philipp15b/go-steam/v2/protocol/steamlang"
. "github.com/Philipp15b/go-steam/v2/steamid"
"github.com/Philipp15b/go-steam/v2/protocol"
"github.com/Philipp15b/go-steam/v2/protocol/protobuf"
"github.com/Philipp15b/go-steam/v2/protocol/steamlang"
"github.com/Philipp15b/go-steam/v2/steamid"
"github.com/golang/protobuf/proto"
)

Expand Down Expand Up @@ -57,7 +57,7 @@ func (a *Auth) LogOn(details *LogOnDetails) {
panic("Password or LoginKey must be set!")
}

logon := new(CMsgClientLogon)
logon := new(protobuf.CMsgClientLogon)
logon.AccountName = &details.Username
logon.Password = &details.Password
if details.AuthCode != "" {
Expand All @@ -67,7 +67,7 @@ func (a *Auth) LogOn(details *LogOnDetails) {
logon.TwoFactorCode = proto.String(details.TwoFactorCode)
}
logon.ClientLanguage = proto.String("english")
logon.ProtocolVersion = proto.Uint32(MsgClientLogon_CurrentProtocol)
logon.ProtocolVersion = proto.Uint32(steamlang.MsgClientLogon_CurrentProtocol)
logon.ShaSentryfile = details.SentryFileHash
if details.LoginKey != "" {
logon.LoginKey = proto.String(details.LoginKey)
Expand All @@ -76,53 +76,53 @@ func (a *Auth) LogOn(details *LogOnDetails) {
logon.ShouldRememberPassword = proto.Bool(details.ShouldRememberPassword)
}

atomic.StoreUint64(&a.client.steamId, uint64(NewIdAdv(0, 1, int32(EUniverse_Public), int32(EAccountType_Individual))))
atomic.StoreUint64(&a.client.steamId, uint64(steamid.NewIdAdv(0, 1, int32(steamlang.EUniverse_Public), int32(steamlang.EAccountType_Individual))))

a.client.Write(NewClientMsgProtobuf(EMsg_ClientLogon, logon))
a.client.Write(protocol.NewClientMsgProtobuf(steamlang.EMsg_ClientLogon, logon))
}

func (a *Auth) HandlePacket(packet *Packet) {
func (a *Auth) HandlePacket(packet *protocol.Packet) {
switch packet.EMsg {
case EMsg_ClientLogOnResponse:
case steamlang.EMsg_ClientLogOnResponse:
a.handleLogOnResponse(packet)
case EMsg_ClientNewLoginKey:
case steamlang.EMsg_ClientNewLoginKey:
a.handleLoginKey(packet)
case EMsg_ClientSessionToken:
case EMsg_ClientLoggedOff:
case steamlang.EMsg_ClientSessionToken:
case steamlang.EMsg_ClientLoggedOff:
a.handleLoggedOff(packet)
case EMsg_ClientUpdateMachineAuth:
case steamlang.EMsg_ClientUpdateMachineAuth:
a.handleUpdateMachineAuth(packet)
case EMsg_ClientAccountInfo:
case steamlang.EMsg_ClientAccountInfo:
a.handleAccountInfo(packet)
}
}

func (a *Auth) handleLogOnResponse(packet *Packet) {
func (a *Auth) handleLogOnResponse(packet *protocol.Packet) {
if !packet.IsProto {
a.client.Fatalf("Got non-proto logon response!")
return
}

body := new(CMsgClientLogonResponse)
body := new(protobuf.CMsgClientLogonResponse)
msg := packet.ReadProtoMsg(body)

result := EResult(body.GetEresult())
if result == EResult_OK {
result := steamlang.EResult(body.GetEresult())
if result == steamlang.EResult_OK {
atomic.StoreInt32(&a.client.sessionId, msg.Header.Proto.GetClientSessionid())
atomic.StoreUint64(&a.client.steamId, msg.Header.Proto.GetSteamid())
a.client.Web.webLoginKey = *body.WebapiAuthenticateUserNonce

go a.client.heartbeatLoop(time.Duration(body.GetOutOfGameHeartbeatSeconds()))

a.client.Emit(&LoggedOnEvent{
Result: EResult(body.GetEresult()),
ExtendedResult: EResult(body.GetEresultExtended()),
Result: steamlang.EResult(body.GetEresult()),
ExtendedResult: steamlang.EResult(body.GetEresultExtended()),
OutOfGameSecsPerHeartbeat: body.GetOutOfGameHeartbeatSeconds(),
InGameSecsPerHeartbeat: body.GetInGameHeartbeatSeconds(),
PublicIp: body.GetDeprecatedPublicIp(),
ServerTime: body.GetRtime32ServerTime(),
AccountFlags: EAccountFlags(body.GetAccountFlags()),
ClientSteamId: SteamId(body.GetClientSuppliedSteamid()),
AccountFlags: steamlang.EAccountFlags(body.GetAccountFlags()),
ClientSteamId: steamid.SteamId(body.GetClientSuppliedSteamid()),
EmailDomain: body.GetEmailDomain(),
CellId: body.GetCellId(),
CellIdPingThreshold: body.GetCellIdPingThreshold(),
Expand All @@ -134,20 +134,20 @@ func (a *Auth) handleLogOnResponse(packet *Packet) {
NumLoginFailuresToMigrate: body.GetCountLoginfailuresToMigrate(),
NumDisconnectsToMigrate: body.GetCountDisconnectsToMigrate(),
})
} else if result == EResult_Fail || result == EResult_ServiceUnavailable || result == EResult_TryAnotherCM {
} else if result == steamlang.EResult_Fail || result == steamlang.EResult_ServiceUnavailable || result == steamlang.EResult_TryAnotherCM {
// some error on Steam's side, we'll get an EOF later
} else {
a.client.Emit(&LogOnFailedEvent{
Result: EResult(body.GetEresult()),
Result: steamlang.EResult(body.GetEresult()),
})
a.client.Disconnect()
}
}

func (a *Auth) handleLoginKey(packet *Packet) {
body := new(CMsgClientNewLoginKey)
func (a *Auth) handleLoginKey(packet *protocol.Packet) {
body := new(protobuf.CMsgClientNewLoginKey)
packet.ReadProtoMsg(body)
a.client.Write(NewClientMsgProtobuf(EMsg_ClientNewLoginKeyAccepted, &CMsgClientNewLoginKeyAccepted{
a.client.Write(protocol.NewClientMsgProtobuf(steamlang.EMsg_ClientNewLoginKeyAccepted, &protobuf.CMsgClientNewLoginKeyAccepted{
UniqueId: proto.Uint32(body.GetUniqueId()),
}))
a.client.Emit(&LoginKeyEvent{
Expand All @@ -156,28 +156,28 @@ func (a *Auth) handleLoginKey(packet *Packet) {
})
}

func (a *Auth) handleLoggedOff(packet *Packet) {
result := EResult_Invalid
func (a *Auth) handleLoggedOff(packet *protocol.Packet) {
result := steamlang.EResult_Invalid
if packet.IsProto {
body := new(CMsgClientLoggedOff)
body := new(protobuf.CMsgClientLoggedOff)
packet.ReadProtoMsg(body)
result = EResult(body.GetEresult())
result = steamlang.EResult(body.GetEresult())
} else {
body := new(MsgClientLoggedOff)
body := new(steamlang.MsgClientLoggedOff)
packet.ReadClientMsg(body)
result = body.Result
}
a.client.Emit(&LoggedOffEvent{Result: result})
}

func (a *Auth) handleUpdateMachineAuth(packet *Packet) {
body := new(CMsgClientUpdateMachineAuth)
func (a *Auth) handleUpdateMachineAuth(packet *protocol.Packet) {
body := new(protobuf.CMsgClientUpdateMachineAuth)
packet.ReadProtoMsg(body)
hash := sha1.New()
hash.Write(packet.Data)
sha := hash.Sum(nil)

msg := NewClientMsgProtobuf(EMsg_ClientUpdateMachineAuthResponse, &CMsgClientUpdateMachineAuthResponse{
msg := protocol.NewClientMsgProtobuf(steamlang.EMsg_ClientUpdateMachineAuthResponse, &protobuf.CMsgClientUpdateMachineAuthResponse{
ShaFile: sha,
})
msg.SetTargetJobId(packet.SourceJobId)
Expand All @@ -186,14 +186,14 @@ func (a *Auth) handleUpdateMachineAuth(packet *Packet) {
a.client.Emit(&MachineAuthUpdateEvent{sha})
}

func (a *Auth) handleAccountInfo(packet *Packet) {
body := new(CMsgClientAccountInfo)
func (a *Auth) handleAccountInfo(packet *protocol.Packet) {
body := new(protobuf.CMsgClientAccountInfo)
packet.ReadProtoMsg(body)
a.client.Emit(&AccountInfoEvent{
PersonaName: body.GetPersonaName(),
Country: body.GetIpCountry(),
CountAuthedComputers: body.GetCountAuthedComputers(),
AccountFlags: EAccountFlags(body.GetAccountFlags()),
AccountFlags: steamlang.EAccountFlags(body.GetAccountFlags()),
FacebookId: body.GetFacebookId(),
FacebookName: body.GetFacebookName(),
})
Expand Down
18 changes: 9 additions & 9 deletions auth_events.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package steam

import (
. "github.com/Philipp15b/go-steam/v2/protocol/steamlang"
. "github.com/Philipp15b/go-steam/v2/steamid"
"github.com/Philipp15b/go-steam/v2/protocol/steamlang"
"github.com/Philipp15b/go-steam/v2/steamid"
)

type LoggedOnEvent struct {
Result EResult
ExtendedResult EResult
Result steamlang.EResult
ExtendedResult steamlang.EResult
OutOfGameSecsPerHeartbeat int32
InGameSecsPerHeartbeat int32
PublicIp uint32
ServerTime uint32
AccountFlags EAccountFlags
ClientSteamId SteamId `json:",string"`
AccountFlags steamlang.EAccountFlags
ClientSteamId steamid.SteamId `json:",string"`
EmailDomain string
CellId uint32
CellIdPingThreshold uint32
Expand All @@ -27,7 +27,7 @@ type LoggedOnEvent struct {
}

type LogOnFailedEvent struct {
Result EResult
Result steamlang.EResult
}

type LoginKeyEvent struct {
Expand All @@ -36,7 +36,7 @@ type LoginKeyEvent struct {
}

type LoggedOffEvent struct {
Result EResult
Result steamlang.EResult
}

type MachineAuthUpdateEvent struct {
Expand All @@ -47,7 +47,7 @@ type AccountInfoEvent struct {
PersonaName string
Country string
CountAuthedComputers int32
AccountFlags EAccountFlags
AccountFlags steamlang.EAccountFlags
FacebookId uint64 `json:",string"`
FacebookName string
}
Loading

0 comments on commit 8cbbaf6

Please sign in to comment.