bnet

package
v0.0.0-...-a711c0c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2016 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntityIDKindNone = iota
	EntityIDKindAccount
	EntityIDKindGameAccount
)

Byte 15 of an EntityID signifies which application uses it, bnet or a game.

View Source
const (
	EntityIDRegionNone = iota
	EntityIDRegionNorthAmerica
	EntityIDRegionEurope
	// Use this special region to distinguish stove's game account entity ids
	// from entity ids on other systems.
	EntityIDRegionTest = 0x7A
)

Byte 12 is used for the region; bnet accounts are not region-specific, but game accounts may be.

View Source
const (
	EntityIDGameNone    = 0
	EntityIDGameApp     = 0x417070   // 'App', the bnet app
	EntityIDGamePegasus = 0x57544347 // 'WTCG', i.e. pegasus
)

Bytes 11 through 8 are used for the FourCC of the game in question.

View Source
const (
	ErrorOK     = 0
	ErrorNoAuth = 10
)
View Source
const (
	NotifyClientRequest    = "GS_CL_REQ"
	NotifyClientResponse   = "GS_CL_RES"
	NotifyFindGameRequest  = "GS_FG_REQ"
	NotifyFindGameResponse = "GS_FG_RES"
	NotifyQueueEntry       = "GQ_ENTRY"
	NotifyQueueUpdate      = "GQ_UPDATE"
	NotifyQueueExit        = "GQ_EXIT"
	NotifyQueueResult      = "G_RESULT"
	NotifyMatchMakerStart  = "MM_START"
	NotifyMatchMakerEnd    = "MM_END"
	NotifyWhisper          = "WHISPER"
	NotifySpectatorInvite  = "WTCG.SpectatorInvite"
)
View Source
const (
	StateDisconnected = iota
	StateConnecting
	StateConnected
	StateLoggingIn
	StateAuthenticationFailed
	StateReady
	StateCount
)
View Source
const BnetAccountEntityIDHi uint64 = (EntityIDKindAccount << 56) |
	(EntityIDRegionTest << 32) |
	(EntityIDGameNone)

This is the high part of all account entity ids in this server

Variables

This section is empty.

Functions

func EntityId

func EntityId(high, low uint64) *entity.EntityId

EntityId creates a 128-bit entity id from its high and low qwords.

func Hash

func Hash(s string) uint32

Hash returns the fnv32a hash of the string.

func MakePacket

func MakePacket(header *rpc.Header, buf []byte) ([]byte, error)

MakePacket returns a buffer with the encoded values of the supplied header and body.

func Migrate

func Migrate()

func ServiceHash

func ServiceHash(binder ServiceBinder) uint32

ServiceHash returns a hash of the service's fully qualified name.

Types

type Account

type Account struct {
	// The lo part of the full entity id
	ID            int64
	Email         string
	WebCredential string
	// Formatted as Name#1234
	BattleTag    string
	Flags        int64
	GameAccounts []GameAccount
}

type AccountGameAccount

type AccountGameAccount struct {
	ID            int64
	AccountID     int64
	GameAccountID int64
}

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

The Account service holds data about the client's game account.

func (*AccountService) CacheExpire

func (s *AccountService) CacheExpire(body []byte) error

func (*AccountService) CreateGameAccount

func (s *AccountService) CreateGameAccount(body []byte) ([]byte, error)

func (*AccountService) CredentialUpdate

func (s *AccountService) CredentialUpdate(body []byte) error

func (*AccountService) FlagUpdate

func (s *AccountService) FlagUpdate(body []byte) ([]byte, error)

func (*AccountService) ForwardCacheExpire

func (s *AccountService) ForwardCacheExpire(body []byte) error

func (*AccountService) GetAccount

func (s *AccountService) GetAccount(body []byte) ([]byte, error)

func (*AccountService) GetAccountState

func (s *AccountService) GetAccountState(body []byte) ([]byte, error)

func (*AccountService) GetCAISInfo

func (s *AccountService) GetCAISInfo(body []byte) ([]byte, error)

func (*AccountService) GetEBalance

func (s *AccountService) GetEBalance(body []byte) ([]byte, error)

func (*AccountService) GetEBalanceRestrictions

func (s *AccountService) GetEBalanceRestrictions(body []byte) ([]byte, error)

func (*AccountService) GetGameAccount

func (s *AccountService) GetGameAccount(body []byte) ([]byte, error)

func (*AccountService) GetGameAccountState

func (s *AccountService) GetGameAccountState(body []byte) ([]byte, error)

func (*AccountService) GetGameSessionInfo

func (s *AccountService) GetGameSessionInfo(body []byte) ([]byte, error)

func (*AccountService) GetGameTimeRemainingInfo

func (s *AccountService) GetGameTimeRemainingInfo(body []byte) ([]byte, error)

func (*AccountService) GetLicenses

func (s *AccountService) GetLicenses(body []byte) ([]byte, error)

func (*AccountService) GetWalletList

func (s *AccountService) GetWalletList(body []byte) ([]byte, error)

func (*AccountService) Invoke

func (s *AccountService) Invoke(method int, body []byte) (resp []byte, err error)

func (*AccountService) IsIgrAddress

func (s *AccountService) IsIgrAddress(body []byte) error

func (*AccountService) Methods

func (s *AccountService) Methods() []string

func (*AccountService) Name

func (s *AccountService) Name() string

func (*AccountService) Subscribe

func (s *AccountService) Subscribe(body []byte) ([]byte, error)

func (*AccountService) Unsubscribe

func (s *AccountService) Unsubscribe(body []byte) error

type AccountServiceBinder

type AccountServiceBinder struct{}

func (AccountServiceBinder) Bind

func (AccountServiceBinder) Bind(sess *Session) Service

type AuthClientService

type AuthClientService struct {
	// contains filtered or unexported fields
}

The AuthClient service is implemented by the client to handle auth modules and Logon results.

func (*AuthClientService) Invoke

func (s *AuthClientService) Invoke(method int, body []byte) (resp []byte, err error)

func (*AuthClientService) Methods

func (s *AuthClientService) Methods() []string

func (*AuthClientService) Name

func (s *AuthClientService) Name() string

type AuthClientServiceBinder

type AuthClientServiceBinder struct{}

func (AuthClientServiceBinder) Bind

type AuthServerService

type AuthServerService struct {
	// contains filtered or unexported fields
}

The AuthServer service handles Logon requests. This implementation does not use the Module system but instead relies on a pre-shared WebAuth token to authenticate the client.

func (*AuthServerService) CompleteLogin

func (s *AuthServerService) CompleteLogin() error

func (*AuthServerService) FinishQueue

func (s *AuthServerService) FinishQueue()

func (*AuthServerService) GenerateTempCookie

func (s *AuthServerService) GenerateTempCookie(body []byte) ([]byte, error)

func (*AuthServerService) Invoke

func (s *AuthServerService) Invoke(method int, body []byte) (resp []byte, err error)

func (*AuthServerService) Logon

func (s *AuthServerService) Logon(body []byte) error

func (*AuthServerService) Methods

func (s *AuthServerService) Methods() []string

func (*AuthServerService) ModuleMessage

func (s *AuthServerService) ModuleMessage(body []byte) error

func (*AuthServerService) ModuleNotify

func (s *AuthServerService) ModuleNotify(body []byte) error

func (*AuthServerService) Name

func (s *AuthServerService) Name() string

func (*AuthServerService) SelectGameAccount

func (s *AuthServerService) SelectGameAccount(body []byte) error

func (*AuthServerService) SelectGameAccount_DEPRECATED

func (s *AuthServerService) SelectGameAccount_DEPRECATED(body []byte) error

func (*AuthServerService) VerifyWebCredentials

func (s *AuthServerService) VerifyWebCredentials(body []byte) error

type AuthServerServiceBinder

type AuthServerServiceBinder struct{}

func (AuthServerServiceBinder) Bind

type ChallengeNotifyService

type ChallengeNotifyService struct {
	// contains filtered or unexported fields
}

The ChallengeNotify service is implemented by the client to allow the server to request the client provide proof of authentication.

func (*ChallengeNotifyService) Invoke

func (s *ChallengeNotifyService) Invoke(method int, body []byte) (resp []byte, err error)

func (*ChallengeNotifyService) Methods

func (s *ChallengeNotifyService) Methods() []string

func (*ChallengeNotifyService) Name

func (s *ChallengeNotifyService) Name() string

func (*ChallengeNotifyService) Run

func (s *ChallengeNotifyService) Run()

type ChallengeNotifyServiceBinder

type ChallengeNotifyServiceBinder struct{}

func (ChallengeNotifyServiceBinder) Bind

type ChannelInvitationService

type ChannelInvitationService struct {
	// contains filtered or unexported fields
}

The ChannelInvitation service manages chat channel invitations.

func (*ChannelInvitationService) AcceptInvitation

func (s *ChannelInvitationService) AcceptInvitation(body []byte) ([]byte, error)

func (*ChannelInvitationService) DeclineInvitation

func (s *ChannelInvitationService) DeclineInvitation(body []byte) error

func (*ChannelInvitationService) DecrementChannelCount

func (s *ChannelInvitationService) DecrementChannelCount(body []byte) error

func (*ChannelInvitationService) IncrementChannelCount

func (s *ChannelInvitationService) IncrementChannelCount(body []byte) ([]byte, error)

func (*ChannelInvitationService) Invoke

func (s *ChannelInvitationService) Invoke(method int, body []byte) (resp []byte, err error)

func (*ChannelInvitationService) ListChannelCount

func (s *ChannelInvitationService) ListChannelCount(body []byte) ([]byte, error)

func (*ChannelInvitationService) Methods

func (s *ChannelInvitationService) Methods() []string

func (*ChannelInvitationService) Name

func (s *ChannelInvitationService) Name() string

func (*ChannelInvitationService) RevokeInvitation

func (s *ChannelInvitationService) RevokeInvitation(body []byte) error

func (*ChannelInvitationService) SendInvitation

func (s *ChannelInvitationService) SendInvitation(body []byte) ([]byte, error)

func (*ChannelInvitationService) Subscribe

func (s *ChannelInvitationService) Subscribe(body []byte) ([]byte, error)

func (*ChannelInvitationService) SuggestInvitation

func (s *ChannelInvitationService) SuggestInvitation(body []byte) error

func (*ChannelInvitationService) Unsubscribe

func (s *ChannelInvitationService) Unsubscribe(body []byte) error

func (*ChannelInvitationService) UpdateChannelCount

func (s *ChannelInvitationService) UpdateChannelCount(body []byte) error

type ChannelInvitationServiceBinder

type ChannelInvitationServiceBinder struct{}

func (ChannelInvitationServiceBinder) Bind

type ConnectionService

type ConnectionService struct {
	// contains filtered or unexported fields
}

The Connection service is the default service that manages the RPC binding process for other services and also handles low-level functions like pings, errors resulting in disconnection, and elevations to encrypted streams.

func (*ConnectionService) Bind

func (s *ConnectionService) Bind(body []byte) ([]byte, error)

func (*ConnectionService) Connect

func (s *ConnectionService) Connect(body []byte) ([]byte, error)

func (*ConnectionService) Echo

func (s *ConnectionService) Echo(body []byte) ([]byte, error)

func (*ConnectionService) Encrypt

func (s *ConnectionService) Encrypt(body []byte) error

func (*ConnectionService) ForceDisconnect

func (s *ConnectionService) ForceDisconnect(body []byte) error

func (*ConnectionService) Invoke

func (s *ConnectionService) Invoke(method int, body []byte) (resp []byte, err error)

func (*ConnectionService) KeepAlive

func (s *ConnectionService) KeepAlive(body []byte) error

func (*ConnectionService) Methods

func (s *ConnectionService) Methods() []string

func (*ConnectionService) Name

func (s *ConnectionService) Name() string

func (*ConnectionService) RequestDisconnect

func (s *ConnectionService) RequestDisconnect(body []byte) error

type ConnectionServiceBinder

type ConnectionServiceBinder struct{}

func (ConnectionServiceBinder) Bind

type FourccValue

type FourccValue struct {
	Value string
}

Wrapper type for disambiguationg string and fourcc values in attributes.

type FriendsService

type FriendsService struct {
	// contains filtered or unexported fields
}

The Friends service handles friends and friend requests.

func (*FriendsService) AcceptInvitation

func (s *FriendsService) AcceptInvitation(body []byte) error

func (*FriendsService) AssignRole

func (s *FriendsService) AssignRole(body []byte) error

func (*FriendsService) DeclineInvitation

func (s *FriendsService) DeclineInvitation(body []byte) error

func (*FriendsService) IgnoreInvitation

func (s *FriendsService) IgnoreInvitation(body []byte) error

func (*FriendsService) Invoke

func (s *FriendsService) Invoke(method int, body []byte) (resp []byte, err error)

func (*FriendsService) Methods

func (s *FriendsService) Methods() []string

func (*FriendsService) Name

func (s *FriendsService) Name() string

func (*FriendsService) RemoveFriend

func (s *FriendsService) RemoveFriend(body []byte) ([]byte, error)

func (*FriendsService) RevokeAllInvitations

func (s *FriendsService) RevokeAllInvitations(body []byte) error

func (*FriendsService) RevokeInvitation

func (s *FriendsService) RevokeInvitation(body []byte) error

func (*FriendsService) SendInvitation

func (s *FriendsService) SendInvitation(body []byte) error

func (*FriendsService) SubscribeToFriends

func (s *FriendsService) SubscribeToFriends(body []byte) ([]byte, error)

func (*FriendsService) UnsubscribeToFriends

func (s *FriendsService) UnsubscribeToFriends(body []byte) error

func (*FriendsService) UpdateFriendState

func (s *FriendsService) UpdateFriendState(body []byte) error

func (*FriendsService) ViewFriends

func (s *FriendsService) ViewFriends(body []byte) ([]byte, error)

type FriendsServiceBinder

type FriendsServiceBinder struct{}

func (FriendsServiceBinder) Bind

func (FriendsServiceBinder) Bind(sess *Session) Service

type GameAccount

type GameAccount struct {
	// This ID must be the same as the account ID in the game's db.
	ID        int64
	CreatedAt time.Time
	Game      string
	Region    string
}

type GameMasterService

type GameMasterService struct {
	// contains filtered or unexported fields
}

The GameUtilities service arbitrates packets between the client and servers specific to individual games.

func (*GameMasterService) CancelGameEntry

func (s *GameMasterService) CancelGameEntry(body []byte) error

func (*GameMasterService) ChangeGame

func (s *GameMasterService) ChangeGame(body []byte) error

func (*GameMasterService) FindGame

func (s *GameMasterService) FindGame(body []byte) ([]byte, error)

func (*GameMasterService) GameEnded

func (s *GameMasterService) GameEnded(body []byte) error

func (*GameMasterService) GetFactoryInfo

func (s *GameMasterService) GetFactoryInfo(body []byte) ([]byte, error)

func (*GameMasterService) GetGameStats

func (s *GameMasterService) GetGameStats(body []byte) ([]byte, error)

func (*GameMasterService) Invoke

func (s *GameMasterService) Invoke(method int, body []byte) (resp []byte, err error)

func (*GameMasterService) JoinGame

func (s *GameMasterService) JoinGame(body []byte) ([]byte, error)

func (*GameMasterService) ListFactories

func (s *GameMasterService) ListFactories(body []byte) ([]byte, error)

func (*GameMasterService) Methods

func (s *GameMasterService) Methods() []string

func (*GameMasterService) Name

func (s *GameMasterService) Name() string

func (*GameMasterService) PlayerLeft

func (s *GameMasterService) PlayerLeft(body []byte) error

func (*GameMasterService) RegisterServer

func (s *GameMasterService) RegisterServer(body []byte) error

func (*GameMasterService) RegisterUtilities

func (s *GameMasterService) RegisterUtilities(body []byte) error

func (*GameMasterService) Subscribe

func (s *GameMasterService) Subscribe(body []byte) ([]byte, error)

func (*GameMasterService) UnregisterServer

func (s *GameMasterService) UnregisterServer(body []byte) error

func (*GameMasterService) UnregisterUtilities

func (s *GameMasterService) UnregisterUtilities(body []byte) error

func (*GameMasterService) Unsubscribe

func (s *GameMasterService) Unsubscribe(body []byte) error

type GameMasterServiceBinder

type GameMasterServiceBinder struct{}

func (GameMasterServiceBinder) Bind

type GameServer

type GameServer interface {
	// Connect connects the bnet session to the game session.  The game server
	// should set up the Client and ServerNotification channels on sess.
	Connect(sess *Session)
}

A GameServer accepts clients to create sessions.

type GameUtilitiesService

type GameUtilitiesService struct {
	// contains filtered or unexported fields
}

The GameUtilities service arbitrates packets between the client and servers specific to individual games.

func (*GameUtilitiesService) GetLoad

func (s *GameUtilitiesService) GetLoad(body []byte) ([]byte, error)

func (*GameUtilitiesService) GetPlayerVariables

func (s *GameUtilitiesService) GetPlayerVariables(body []byte) ([]byte, error)

func (*GameUtilitiesService) Invoke

func (s *GameUtilitiesService) Invoke(method int, body []byte) (resp []byte, err error)

func (*GameUtilitiesService) Methods

func (s *GameUtilitiesService) Methods() []string

func (*GameUtilitiesService) Name

func (s *GameUtilitiesService) Name() string

func (*GameUtilitiesService) NotifyGameAccountOffline

func (s *GameUtilitiesService) NotifyGameAccountOffline(body []byte) error

func (*GameUtilitiesService) NotifyGameAccountOnline

func (s *GameUtilitiesService) NotifyGameAccountOnline(body []byte) error

func (*GameUtilitiesService) PresenceChannelCreated

func (s *GameUtilitiesService) PresenceChannelCreated(body []byte) error

func (*GameUtilitiesService) ProcessClientRequest

func (s *GameUtilitiesService) ProcessClientRequest(body []byte) ([]byte, error)

func (*GameUtilitiesService) ProcessServerRequest

func (s *GameUtilitiesService) ProcessServerRequest(body []byte) ([]byte, error)

type GameUtilitiesServiceBinder

type GameUtilitiesServiceBinder struct{}

func (GameUtilitiesServiceBinder) Bind

type MessageValue

type MessageValue struct {
	Value []byte
}

Wrapper type for disambiguationg blob and message values in attributes.

type Notification

type Notification struct {
	Type       string
	Attributes []*attribute.Attribute
}

A notification sent or received by battle.net from or to another server.

func NewNotification

func NewNotification(ty string, m map[string]interface{}) *Notification

func (*Notification) Map

func (n *Notification) Map() map[string]interface{}

Converts a notification into a flat map containing a type key for the notification's type and all of the notification's attributes.

type NotificationListenerService

type NotificationListenerService struct {
	// contains filtered or unexported fields
}

The NotificationListener service sends notifications to the client.

func (*NotificationListenerService) Invoke

func (s *NotificationListenerService) Invoke(method int, body []byte) (resp []byte, err error)

func (*NotificationListenerService) Methods

func (s *NotificationListenerService) Methods() []string

func (*NotificationListenerService) Name

func (*NotificationListenerService) Notify

type NotificationListenerServiceBinder

type NotificationListenerServiceBinder struct{}

func (NotificationListenerServiceBinder) Bind

type NotifyHandler

type NotifyHandler func(n *Notification)

type PresenceService

type PresenceService struct {
	// contains filtered or unexported fields
}

The Presence service maintains and broadcasts the "presence" of players within the Bnet system: their current game, status, location, etc.

func (*PresenceService) Invoke

func (s *PresenceService) Invoke(method int, body []byte) (resp []byte, err error)

func (*PresenceService) Methods

func (s *PresenceService) Methods() []string

func (*PresenceService) Name

func (s *PresenceService) Name() string

func (*PresenceService) Query

func (s *PresenceService) Query(body []byte) error

func (*PresenceService) Subscribe

func (s *PresenceService) Subscribe(body []byte) error

func (*PresenceService) Unsubscribe

func (s *PresenceService) Unsubscribe(body []byte) error

func (*PresenceService) Update

func (s *PresenceService) Update(body []byte) error

type PresenceServiceBinder

type PresenceServiceBinder struct{}

func (PresenceServiceBinder) Bind

type ResourcesService

type ResourcesService struct {
	// contains filtered or unexported fields
}

The Resources service allows the client to query content handles for files that are usually often updated.

func (*ResourcesService) GetContentHandle

func (s *ResourcesService) GetContentHandle(body []byte) ([]byte, error)

func (*ResourcesService) Invoke

func (s *ResourcesService) Invoke(method int, body []byte) (resp []byte, err error)

func (*ResourcesService) Methods

func (s *ResourcesService) Methods() []string

func (*ResourcesService) Name

func (s *ResourcesService) Name() string

type ResourcesServiceBinder

type ResourcesServiceBinder struct{}

func (ResourcesServiceBinder) Bind

type Server

type Server struct {
	// contains filtered or unexported fields
}

A Server accepts client connections and processes each connection as a Session.

func NewServer

func NewServer() *Server

func (*Server) ConnectGameServer

func (s *Server) ConnectGameServer(client *Session, program string)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

ListenAndServe listens for incoming connections on the specified address indefinitely, handling each connection as a new Session.

func (*Server) RegisterGameServer

func (s *Server) RegisterGameServer(fourcc string, serv GameServer)

type Service

type Service interface {
	// Name returns the fully qualified name of the service.
	Name() string

	// Methods returns the names of the service's invokable methods.
	Methods() []string

	// Invoke executes a method.
	Invoke(method int, body []byte) (resp []byte, err error)
}

A Service is a set of RPC methods bound to a particular Session.

type ServiceBinder

type ServiceBinder interface {
	// Bind binds a service to a session.  Passing nil will give a default
	// instance which can be used to inspect the service and method names.
	Bind(sess *Session) Service
}

A ServiceBinder is used to create instances of a service bound to individual sessions.

type Session

type Session struct {
	// ServerNotifications are notifications sent by the bnet server to the game
	// server.
	ServerNotifications chan<- *Notification
	// ClientNotifications are notifications sent by the game server to the bnet
	// server.
	ClientNotifications <-chan *Notification
	// contains filtered or unexported fields
}

func NewSession

func NewSession(s *Server, c net.Conn) *Session

func (*Session) BindExport

func (s *Session) BindExport(index int, hash uint32)

func (*Session) BindImport

func (s *Session) BindImport(index int, hash uint32)

func (*Session) ChanForTransition

func (s *Session) ChanForTransition(state int) chan struct{}

ChanForTransition makes a channel that waits for the specified state.

func (*Session) Disconnect

func (s *Session) Disconnect()

func (*Session) DisconnectOnPanic

func (s *Session) DisconnectOnPanic()

func (*Session) HandleNotifications

func (s *Session) HandleNotifications()

func (*Session) HandlePacket

func (s *Session) HandlePacket(header *rpc.Header, body []byte)

func (*Session) HandleRequest

func (s *Session) HandleRequest(serviceId, methodId int, body []byte) (resp []byte)

func (*Session) HandleResponse

func (s *Session) HandleResponse(token uint32, body []byte)

func (*Session) ImportedService

func (s *Session) ImportedService(name string) Service

func (*Session) MakeRequestHeader

func (s *Session) MakeRequestHeader(service Service, methodId, size int) *rpc.Header

func (*Session) OnceNotified

func (s *Session) OnceNotified(ty string, handle NotifyHandler)

Will trigger handler once the server is notified with a notification of type ty.

func (*Session) QueuePacket

func (s *Session) QueuePacket(header *rpc.Header, buf []byte) error

func (*Session) Respond

func (s *Session) Respond(token uint32, body []byte)

func (*Session) Transition

func (s *Session) Transition(state int)

Transition updates the session's state with the value provided, and notifies any listeners of that state update.

func (*Session) WaitForTransition

func (s *Session) WaitForTransition(state int)

WaitForTransition blocks until the session state matches the value provided.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL