Documentation ¶
Overview ¶
This package allows you to automate actions on Valve's Steam network. It is a Go port of SteamKit.
To login, you'll have to create a new Client first. Then connect to the Steam network and wait for a ConnectedCallback. Then you may call the Login method in the Auth module with your login information. This is covered in more detail in the method's documentation. After you've received the LoggedOnEvent, you should set your persona state to online to receive friend lists etc.
Example code ¶
You can also find a running example in the `gsbot` package.
package main import ( "io/ioutil" "log" "github.com/WirStaff/go-steam" "github.com/WirStaff/go-steam/protocol/steamlang" ) func main() { myLoginInfo := new(steam.LogOnDetails) myLoginInfo.Username = "Your username" myLoginInfo.Password = "Your password" client := steam.NewClient() client.Connect() for event := range client.Events() { switch e := event.(type) { case *steam.ConnectedEvent: client.Auth.LogOn(myLoginInfo) case *steam.MachineAuthUpdateEvent: ioutil.WriteFile("sentry", e.Hash, 0666) case *steam.LoggedOnEvent: client.Social.SetPersonaState(steamlang.EPersonaState_Online) case steam.FatalErrorEvent: log.Print(e) case error: log.Print(e) } } }
Events ¶
go-steam emits events that can be read via Client.Events(). Although the channel has the type interface{}, only types from this package ending with "Event" and errors will be emitted.
Index ¶
- Variables
- func GetPublicKey(universe steamlang.EUniverse) *rsa.PublicKey
- func GetRandomCM() *netutil.PortAddr
- func InitializeSteamDirectory(cellId uint32) error
- type Client
- func (c *Client) Connect(cellId uint32, proxy *ProxyConnection) (*netutil.PortAddr, error)
- func (c *Client) ConnectTo(addr *netutil.PortAddr, proxy *ProxyConnection) error
- func (c *Client) ConnectToBind(addr *netutil.PortAddr, local *net.TCPAddr, proxy *ProxyConnection) error
- func (c *Client) Connected() bool
- func (c *Client) Disconnect()
- func (c *Client) Emit(event interface{})
- func (c *Client) Errorf(format string, a ...interface{})
- func (c *Client) Events() <-chan interface{}
- func (c *Client) Fatalf(format string, a ...interface{})
- func (c *Client) GetNextJobId() protocol.JobId
- func (c *Client) HeartbeatLoop(seconds time.Duration)
- func (c *Client) RegisterPacketHandler(handler PacketHandler)
- func (c *Client) SessionId() int32
- func (c *Client) SetSessionId(id int32)
- func (c *Client) SetSteamId(steamId uint64)
- func (c *Client) SetSteamIdForAuth(instance uint32, univerve steamlang.EUniverse, ...)
- func (c *Client) SteamId() steamid.SteamId
- func (c *Client) Write(msg protocol.IMsg)
- type ClientCMListEvent
- type ConnectedEvent
- type DisconnectedEvent
- type FatalErrorEvent
- type GCPacketHandler
- type GameCoordinator
- type PacketHandler
- type ProxyConnection
Constants ¶
This section is empty.
Variables ¶
var CMServers = []string{
"103.10.124.123:27018",
"103.10.124.122:27018",
"103.10.124.122:27017",
"103.10.124.123:27017",
"103.10.124.124:27017",
"103.10.124.124:27018",
"103.10.124.125:27017",
"103.10.124.125:27018",
"103.28.54.162:27018",
"103.28.54.162:27017",
"103.28.54.178:27017",
"103.28.54.178:27018",
"103.28.54.181:27017",
"103.28.54.165:27018",
"103.28.54.165:27017",
"103.28.54.171:27018",
"103.28.54.181:27018",
"103.28.54.171:27017",
"155.133.239.20:27018",
"155.133.239.20:27017",
"155.133.245.36:27017",
"155.133.245.36:27018",
"155.133.239.51:27017",
"155.133.239.51:27018",
"155.133.245.37:27017",
"155.133.245.37:27018",
"162.254.195.71:27017",
"162.254.195.71:27018",
"162.254.195.66:27017",
"162.254.195.66:27018",
"205.196.6.214:27017",
"205.196.6.214:27018",
"205.196.6.215:27017",
"155.133.253.34:27017",
"155.133.253.50:27018",
"155.133.253.50:27017",
"155.133.253.34:27018",
"162.254.193.102:27017",
"162.254.193.102:27018",
"162.254.193.74:27017",
"162.254.193.74:27018",
"205.196.6.215:27018",
"162.254.192.74:27017",
"162.254.192.74:27018",
"162.254.199.181:27018",
"162.254.199.163:27018",
"162.254.199.181:27017",
"162.254.192.75:27017",
"162.254.192.75:27018",
"162.254.199.163:27017",
"162.254.192.71:27017",
"162.254.192.71:27018",
"162.254.192.87:27018",
"162.254.192.87:27017",
"103.10.125.156:27018",
"103.10.125.156:27017",
"103.10.125.148:27018",
"103.10.125.148:27017",
"162.254.196.83:27017",
"162.254.196.83:27018",
"162.254.196.68:27018",
"162.254.196.68:27017",
"162.254.196.67:27017",
"162.254.196.67:27018",
"162.254.196.84:27018",
"162.254.196.84:27017",
"155.133.248.39:27018",
"155.133.248.39:27017",
"155.133.248.38:27018",
"155.133.248.38:27017",
"155.133.226.78:27018",
"155.133.226.78:27017",
"162.254.197.39:27017",
"162.254.197.39:27018",
"162.254.197.54:27018",
"162.254.197.54:27017",
"155.133.226.75:27018",
"155.133.226.75:27017",
"185.25.182.52:27018",
"185.25.182.52:27017",
"185.25.182.20:27017",
"185.25.182.20:27018",
"162.254.198.44:27018",
"162.254.198.44:27017",
"155.133.252.39:27018",
"155.133.252.39:27017",
"155.133.252.54:27017",
"155.133.252.54:27018",
"162.254.198.104:27018",
"162.254.198.104:27017",
"155.133.246.36:27017",
"155.133.246.36:27018",
"155.133.246.52:27017",
"155.133.246.52:27018",
"146.66.152.39:27018",
"155.133.246.51:27017",
"146.66.152.38:27017",
"146.66.152.39:27017",
"146.66.152.44:27018",
"146.66.152.44:27017",
}
CMServers contains a list of worlwide servers
Functions ¶
func GetRandomCM ¶
GetRandomCM returns a random server from a built-in IP list.
Prefer Client.Connect(), which uses IPs from the Steam Directory, which is always more up-to-date.
func InitializeSteamDirectory ¶
Load initial server list from Steam Directory Web API. Call InitializeSteamDirectory() before Connect() to use steam directory server list instead of static one.
Types ¶
type Client ¶
type Client struct { GC *GameCoordinator ConnectionTimeout time.Duration // contains filtered or unexported fields }
Represents a client to the Steam network. Always poll events from the channel returned by Events() or receiving messages will stop. All access, unless otherwise noted, should be threadsafe.
When a FatalErrorEvent is emitted, the connection is automatically closed. The same client can be used to reconnect. Other errors don't have any effect.
func (*Client) Connect ¶
Connects to a random Steam server and returns its address. If this client is already connected, it is disconnected first. This method tries to use an address from the Steam Directory and falls back to the built-in server list if the Steam Directory can't be reached. If you want to connect to a specific server, use `ConnectTo`.
func (*Client) ConnectTo ¶
func (c *Client) ConnectTo(addr *netutil.PortAddr, proxy *ProxyConnection) error
Connects to a specific server. You may want to use one of the `GetRandom*CM()` functions in this package. If this client is already connected, it is disconnected first.
func (*Client) ConnectToBind ¶
func (c *Client) ConnectToBind(addr *netutil.PortAddr, local *net.TCPAddr, proxy *ProxyConnection) error
Connects to a specific server, and binds to a specified local IP If this client is already connected, it is disconnected first.
func (*Client) Disconnect ¶
func (c *Client) Disconnect()
func (*Client) Events ¶
func (c *Client) Events() <-chan interface{}
Get the event channel. By convention all events are pointers, except for errors. It is never closed.
func (*Client) GetNextJobId ¶
func (*Client) HeartbeatLoop ¶
func (*Client) RegisterPacketHandler ¶
func (c *Client) RegisterPacketHandler(handler PacketHandler)
Registers a PacketHandler that receives all incoming packets.
func (*Client) SetSessionId ¶
func (*Client) SetSteamId ¶
func (*Client) SetSteamIdForAuth ¶
type ClientCMListEvent ¶
A list of connection manager addresses to connect to in the future. You should always save them and then select one of these instead of the builtin ones for the next connection.
type ConnectedEvent ¶
type ConnectedEvent struct{}
type DisconnectedEvent ¶
type DisconnectedEvent struct{}
type FatalErrorEvent ¶
type FatalErrorEvent error
When this event is emitted by the Client, the connection is automatically closed. This may be caused by a network error, for example.
type GCPacketHandler ¶
type GCPacketHandler interface {
HandleGCPacket(*gamecoordinator.GCPacket)
}
type GameCoordinator ¶
type GameCoordinator struct {
// contains filtered or unexported fields
}
func (*GameCoordinator) HandlePacket ¶
func (g *GameCoordinator) HandlePacket(packet *protocol.Packet)
func (*GameCoordinator) RegisterPacketHandler ¶
func (g *GameCoordinator) RegisterPacketHandler(handler GCPacketHandler)
func (*GameCoordinator) SetGamesPlayed ¶
func (g *GameCoordinator) SetGamesPlayed(appIds ...uint64)
Sets you in the given games. Specify none to quit all games.
func (*GameCoordinator) Write ¶
func (g *GameCoordinator) Write(msg gamecoordinator.IGCMsg)
type PacketHandler ¶
type ProxyConnection ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
csgo
|
|
dota
|
|
This program generates the protobuf and SteamLanguage files from the SteamKit data.
|
This program generates the protobuf and SteamLanguage files from the SteamKit data. |
Includes helper types for working with JSON data
|
Includes helper types for working with JSON data |
This package includes some basics for the Steam protocol.
|
This package includes some basics for the Steam protocol. |
steamlang
Contains code generated from SteamKit's SteamLanguage data.
|
Contains code generated from SteamKit's SteamLanguage data. |
Utilities for reading and writing of binary data
|
Utilities for reading and writing of binary data |
tf2
|
|