Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotOwned is returned when the authenticated account does not own the // requested app or depot. ErrNotOwned = errors.New("steam: account does not own app/depot") // ErrSteamGuardRequired is returned when the account has Steam Guard enabled // and the login cannot proceed without a guard code. ErrSteamGuardRequired = errors.New("steam: steam guard code required") // ErrInvalidCredentials is returned when username/password are rejected. ErrInvalidCredentials = errors.New("steam: invalid credentials") // ErrRateLimited is returned when Steam throttles our requests. ErrRateLimited = errors.New("steam: rate limited by Steam") // ErrSessionNotReady is returned when the CM session has not reached the // Ready state before the context deadline expires. ErrSessionNotReady = errors.New("steam: CM session not ready") // ErrChunkCorrupt is returned when a downloaded chunk fails SHA1 verification. ErrChunkCorrupt = errors.New("steam: chunk SHA1 mismatch — data corrupt") // ErrManifestDecrypt is returned when manifest decryption or decompression fails. ErrManifestDecrypt = errors.New("steam: manifest decrypt/decompress failed") // ErrNoCMServers is returned when the CM server list cannot be fetched. ErrNoCMServers = errors.New("steam: no CM servers available") // ErrWorkshopItemNotFound is returned when the WebAPI cannot find the // requested workshop item. ErrWorkshopItemNotFound = errors.New("steam: workshop item not found") // ErrDepotKeyDenied is returned when Steam denies the depot decryption key // request (access denied / not owned). ErrDepotKeyDenied = errors.New("steam: depot key access denied") // ErrEncryptionHandshake is returned when the CM encryption handshake fails. ErrEncryptionHandshake = errors.New("steam: CM encryption handshake failed") )
Sentinel errors returned by Client methods.
Functions ¶
This section is empty.
Types ¶
type AppDownloadRequest ¶
type AppDownloadRequest struct {
// AppID is the Steam application ID to download.
AppID uint32
// DepotIDs optionally restricts which depots to download. When nil, all
// depots eligible for the current platform and language are downloaded.
DepotIDs []uint32
// Branch is the beta branch name. Leave empty or "public" for the default branch.
Branch string
// BranchPassword is required for password-protected beta branches.
BranchPassword string
// OS filters depots by target OS: "windows", "linux", or "macos". Leave
// empty to auto-detect the OS this process is running on (via
// runtime.GOOS). Depots without OS metadata (shared/common depots) are
// always included regardless of this filter.
//
// DownloadApp rejects the request before downloading anything if OS is
// set to a value other than the three above, or if it's empty and
// runtime.GOOS isn't one Steam supports (e.g. freebsd) -- there is no
// "download every platform" fallback.
OS string
// Language filters language depots. Leave empty for no language filtering.
Language string
// TargetDir is the directory where content will be written.
// Existing files are diffed against the manifest; only changed chunks are downloaded.
TargetDir string
// ValidateOnly skips writing files — only verifies on-disk chunks against the manifest.
ValidateOnly bool
}
AppDownloadRequest describes a Steam app content download.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the entry point for Steam content downloads. Create one with New(); use DownloadApp or DownloadWorkshopItem to fetch content.
func New ¶
New creates a Client and establishes CM connections. It blocks until both sessions are ready or ctx is cancelled.
func (*Client) DownloadApp ¶
DownloadApp downloads (or updates) the content of a Steam app. It returns a channel of Progress events; the channel is closed when the download completes or fails.
The caller must drain the channel. Cancelling ctx stops the download and closes the channel.
func (*Client) DownloadWorkshopItem ¶
func (c *Client) DownloadWorkshopItem(ctx context.Context, req WorkshopDownloadRequest) (<-chan Progress, error)
DownloadWorkshopItem downloads a Steam Workshop item into req.TargetDir. An authenticated session is required; workshop items are never anonymous.
type Config ¶
type Config struct {
// Username and Password are required for authenticated downloads (apps that
// require ownership, or workshop items).
// Leave empty to use an anonymous session (public free-to-play games only).
Username string
Password string
// CachePath is the directory used to persist sessions, depot keys, and CDN
// tokens between runs. Defaults to the OS temp directory if empty.
CachePath string
// CellID is the Steam CDN cell used for server selection. 0 selects automatically.
CellID uint32
// MaxParallelChunks is the maximum number of concurrent chunk downloads.
// Defaults to 16 if zero.
MaxParallelChunks int64
// MaxParallelManifests is the maximum number of manifests downloaded concurrently.
// Defaults to 4 if zero.
MaxParallelManifests int64
// SteamGuardCallback is called when Steam requires a Guard code during login.
// Use InteractiveSteamGuard(), SteamGuardCodeGenerate(secret), or a custom
// func — for example one that fetches and parses the guard email automatically.
// Defaults to UnknownSteamGuard() which returns an error, so Steam Guard
// failures are surfaced immediately rather than hanging.
SteamGuardCallback SteamGuardCallback
// CMServers overrides the CM server list (useful for testing).
CMServers []string
// Log is the logger used by the client. Defaults to slog.Default().
Log *slog.Logger
}
Config controls Client behaviour.
type Progress ¶
type Progress struct {
Phase Phase
// TotalBytes is the total uncompressed bytes to download (0 until diffing is done).
TotalBytes int64
// DoneBytes is the number of uncompressed bytes written so far.
DoneBytes int64
// TotalChunks is the total number of chunks to fetch (0 until diffing is done).
TotalChunks int
// DoneChunks is the number of chunks successfully written.
DoneChunks int
// CurrentFile is the file path currently being written (relative to TargetDir).
CurrentFile string
// Err is non-nil when the download failed. The progress channel is closed
// immediately after emitting a Progress with Err set.
Err error
}
Progress is emitted on the channel returned by DownloadApp / DownloadWorkshopItem. All size fields are in bytes. The channel is closed when Phase == PhaseComplete or when an error occurs (Err != nil).
type SteamGuardCallback ¶
SteamGuardCallback is called when Steam requires a Guard code during login. The callback should return the 5-character alphanumeric code, or an error. It is invoked for both email-based and TOTP-based Steam Guard.
func InteractiveSteamGuard ¶
func InteractiveSteamGuard() SteamGuardCallback
InteractiveSteamGuard returns a SteamGuardCallback that prompts the user to type the Steam Guard code on standard input. Works for both email and TOTP guard when running interactively in a terminal.
func SteamGuardCodeGenerate ¶
func SteamGuardCodeGenerate(sharedSecret string) SteamGuardCallback
SteamGuardCodeGenerate returns a SteamGuardCallback that automatically generates a Steam Guard code from a TOTP shared secret (mobile authenticator). sharedSecret is the base64-encoded secret shown during authenticator setup.
func UnknownSteamGuard ¶
func UnknownSteamGuard() SteamGuardCallback
UnknownSteamGuard returns a SteamGuardCallback that always returns an error. This is the default when no SteamGuardCallback is provided in Config, so that Steam Guard failures produce a clear message rather than hanging forever.
type WorkshopDownloadRequest ¶
type WorkshopDownloadRequest struct {
// ItemID is the PublishedFileID (workshop item ID).
ItemID uint64
// TargetDir is the directory where workshop files will be written.
TargetDir string
}
WorkshopDownloadRequest describes a Steam Workshop item download.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
app-download
command
|
|
|
guard
command
|
|
|
workshop-download
command
|
|
|
internal
|
|
|
cdn
Package cdn implements the Steam Content Delivery Network (CDN) client for downloading depot manifests and content chunks.
|
Package cdn implements the Steam Content Delivery Network (CDN) client for downloading depot manifests and content chunks. |
|
cm
Package cm implements the Steam CM (Connection Manager) TCP protocol, including the AES encryption handshake, proto message framing, heartbeat, and automatic reconnect with exponential back-off.
|
Package cm implements the Steam CM (Connection Manager) TCP protocol, including the AES encryption handshake, proto message framing, heartbeat, and automatic reconnect with exponential back-off. |
|
proto
Package proto contains Steam network protocol message types and wire encoding.
|
Package proto contains Steam network protocol message types and wire encoding. |
|
workshop
Package workshop resolves Steam Workshop item metadata via the Web API.
|
Package workshop resolves Steam Workshop item metadata via the Web API. |
|
Package mock provides in-memory test doubles for go-steam internals.
|
Package mock provides in-memory test doubles for go-steam internals. |