steam

package module
v0.0.0-...-1e32cd5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2018 License: MIT Imports: 14 Imported by: 5

README

go-steam

go-steam is a Go library for querying Source servers.

Requirements

  • Go 1.1 or above

Installation

go get -u github.com/sostronk/go-steam

To use the build in steam utility, install it using:

go get -u github.com/sostronk/go-steam/cmd/steam

License

This code is free software; you can redistribute it and/or modify it under the terms of the MIT License. A copy of this license can be found in the included LICENSE file.

Documentation

Overview

Package steam allows querying of Source servers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRCONAuthFailed = errors.New("steam: authentication failed")

	ErrRCONNotInitialized     = errors.New("steam: rcon is not initialized")
	ErrInvalidResponseType    = errors.New("steam: invalid response type from server")
	ErrInvalidResponseID      = errors.New("steam: invalid response id from server")
	ErrInvalidResponseTrailer = errors.New("steam: invalid response trailer from server")
)

Errors introduced by the steam client.

Functions

func SetLog

func SetLog(l *logrus.Logger)

SetLog overrides the logger used by the steam client.

Types

type ConnectOption

type ConnectOption func(*connectOptions)

ConnectOption configures how we set up the connection.

func WithDialFn

func WithDialFn(fn DialFn) ConnectOption

WithDialFn returns a ConnectOption which sets a dialFn for establishing connection to the server.

func WithRCONPassword

func WithRCONPassword(password string) ConnectOption

WithRCONPassword returns a ConnectOption which sets a rcon password for authenticating the connection to the server.

type DialFn

type DialFn func(network, address string) (net.Conn, error)

The DialFn type is an adapter to allow the use of a custom network dialing mechanism when required. For example, this will come useful inside a environment like AppEngine which does not permit direct socket connections and requires the usage of a custom dialer.

type Environment

type Environment int

Environment indicates the server's host environment.

const (
	// EInvalid indicates a invalid host environment.
	EInvalid Environment = iota

	// ELinux indicates that the server is hosted on Linux.
	ELinux
	// EWindows indicates that the server is hosted on Windows.
	EWindows
	// EMac indicates that the server is hosted on Mac OS X.
	EMac
)

func (Environment) String

func (e Environment) String() string

type InfoResponse

type InfoResponse struct {
	Protocol    int
	Name        string
	Map         string
	Folder      string
	Game        string
	ID          int
	Players     int
	MaxPlayers  int
	Bots        int
	ServerType  ServerType
	Environment Environment
	Visibility  Visibility
	VAC         VAC
	Version     string

	Port    int
	SteamID int64

	SourceTVPort int
	SourceTVName string

	Keywords string
	GameID   int64
}

InfoResponse represents a response to a info query.

func (*InfoResponse) String

func (r *InfoResponse) String() string

type Player

type Player struct {
	Name     string
	Score    int
	Duration float64
}

Player represents a player entity in the server.

type PlayersInfoResponse

type PlayersInfoResponse struct {
	Players []*Player
}

PlayersInfoResponse represents a response to a player info query.

type Server

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

Server represents a Source engine game server.

func Connect

func Connect(addr string, opts ...ConnectOption) (_ *Server, err error)

Connect to the source server.

func (*Server) Close

func (s *Server) Close()

Close releases the resources associated with this server.

func (*Server) Info

func (s *Server) Info() (*InfoResponse, error)

Info retrieves server information.

func (*Server) Ping

func (s *Server) Ping() (time.Duration, error)

Ping returns the RTT (round-trip time) to the server.

func (*Server) PlayersInfo

func (s *Server) PlayersInfo() (*PlayersInfoResponse, error)

PlayersInfo retrieves player information from the server.

func (*Server) Send

func (s *Server) Send(cmd string) (string, error)

Send RCON command to the server.

func (*Server) Stats

func (s *Server) Stats() (*StatsResponse, error)

Stats retrieves server stats.

func (*Server) String

func (s *Server) String() string

type ServerType

type ServerType int

ServerType indicates the type of the server.

const (
	// STInvalid describes a invalid server type.
	STInvalid ServerType = iota

	// STDedicated indicates a dedicated server type.
	STDedicated
	// STNonDedicated indicates a non dedicated server type.
	STNonDedicated
	// STProxy indicates a proxy server type.
	STProxy
)

func (ServerType) String

func (st ServerType) String() string

type StatsResponse

type StatsResponse struct {
	CPU     int
	NetIn   float64
	NetOut  float64
	Uptime  int
	Maps    int
	FPS     float64
	Players int

	Sv          float64
	SvDeviation float64

	Tick float64
}

StatsResponse represents a stats response from server.

srcds typically sends the following output:

CPU   NetIn   NetOut    Uptime  Maps   FPS   Players  Svms    +-ms   ~tick
10.0 241763.2 1518923.5   10419    58  127.98      16    3.72    1.56    0.36

func (*StatsResponse) String

func (r *StatsResponse) String() string

type VAC

type VAC int

VAC indicates the status of the Valve Anti Cheat system.

const (
	// VACInvalid indicates a invalid VAC configuration.
	VACInvalid VAC = iota

	// VACUnsecured indicates a insecure server (VAC disabled).
	VACUnsecured
	// VACSecure indicates a secure server (VAC enabled).
	VACSecure
)

func (VAC) String

func (v VAC) String() string

type Visibility

type Visibility int

Visibility indicates the visibility of the server.

const (
	// VInvalid indicates a invalid visibility.
	VInvalid Visibility = iota

	// VPublic indicates a publicly visibly server.
	VPublic
	// VPrivate indicates a private server.
	VPrivate
)

func (Visibility) String

func (v Visibility) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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