Documentation
¶
Overview ¶
mcr is an RCon client that provides useful methods for connecting to and managing game servers that support the source protocol
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Address() string
- func (c *Client) Close() error
- func (c *Client) Command(cmd string) (string, error)
- func (c *Client) CommandNoResponse(cmd string) error
- func (c *Client) Connect(password string) error
- func (c *Client) Connection() net.Conn
- func (c *Client) Port() int
- func (c *Client) RequestID() int32
- func (c *Client) SetRequestID(id int32)
- func (c *Client) Timeout() time.Duration
- type Option
Constants ¶
const ( //the server encountered an error while handling the last request FailurePacket = int32(-1) //represents any command structs as well as there responses CommandPacket = int32(2) //used for any packets in the authentication handshake AuthPacket = int32(3) //tcp constants Protocol = "tcp" PacketRequestSize = 10 //size of headers plus padding bytes, not including Size header per RCon standard PacketHeaderSize = 8 //size of headers not including Size header per RCon standard PacketPaddingSize = 2 //size of padding required after body //default client configuration values ResetID = 1 DefaultCap = 100 DefaultTimeout = time.Second * 10 DefaultPort = 61695 )
Variables ¶
var ( ErrClientNotConnected = errors.New("client not connected. The Connect method must be called before commands can be run") ErrIntOverflow = errors.New("integer overflowed 32 bits") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client contains the configuration and methods for the RCon connection
func NewClient ¶
NewClient creates a new remote console client configured with the supplied options. The Connect method must be called before the server can be interacted with.
func (*Client) Address ¶ added in v1.4.0
Address returns the current server address, this value cannot be updated after the connection is made. Instead, a new client should be created
func (*Client) Command ¶
Command sends the payload to the server and waits for the server response. The response packet is parsed and the body data is returned, an error is returned if the client has not connected before sending the packet.
func (*Client) CommandNoResponse ¶ added in v1.3.2
CommandNoResponse sends a payload to the server without waiting for a response, the client must be connected to the server before any commands can be sent.
func (*Client) Connect ¶
Connect sends the connection request to the server and authenticates the client. Ensure to call, or defer the call to, the Close method to clean up the connection after use
func (*Client) Connection ¶ added in v1.4.0
Connection returns the underlying client connection, this value cannot be updated after the server has been connected to. Instead, a new client must be created.
func (*Client) Port ¶ added in v1.4.0
Port returns the server port, this value cannot be updated after the connection is made. Instead, a new client should be created
func (*Client) SetRequestID ¶ added in v1.4.0
SetRequestID of the current packet.
type Option ¶ added in v0.2.0
type Option func(cn *Client)
func WithCap ¶ added in v0.2.1
set custom request ID cap, the request ID is the identifier used per-packet a max value is set to prevent any overflow issues
func WithConnection ¶ added in v1.1.1
enables use of a custom connection instead of the default one
func WithTimeout ¶ added in v0.2.0
set a specific timeout for the underlying connection, this timeout applies to the resolution of addresses and establishing the initial connection