Documentation
¶
Index ¶
- Constants
- Variables
- type ClientPacket
- type ClientPacketType
- type RemoteConsole
- func (rc *RemoteConsole) Authenticate(password string) (err error)
- func (rc *RemoteConsole) Close() (err error)
- func (rc *RemoteConsole) Dial(address string) (err error)
- func (rc *RemoteConsole) Execute(command string) (response string, err error)
- func (rc *RemoteConsole) LocalAddr() (addr net.Addr)
- func (rc *RemoteConsole) RemoteAddr() (addr net.Addr)
- type RemoteConsoleSettings
- type ServerPacket
- type ServerPacketType
Constants ¶
const ( // PacketTerminatorSize is the number of bytes the terminator (0x00) at the end of the packet uses. PacketTerminatorSize int32 = 2 // PacketHeaderSize is the number of bytes the ID and Type fields use in bytes, both of which are 32-bit signed integers. PacketHeaderSize int32 = 8 //ID and Type, both 32-bit signed integers // PacketMaximumBodySize is the number of bytes the Body of the packet uses in bytes, it's 4096 minus the header and terminator. PacketMaximumBodySize int32 = 4096 - PacketHeaderSize - PacketTerminatorSize // PacketMaximumSize is the total number of bytes a full packet may contain. PacketMaximumSize int32 = 4 + PacketHeaderSize + PacketMaximumBodySize + PacketTerminatorSize )
const ( // DefaultDialTimeout is the timeout set for a zero value timeout, disabling it requires it be set to -1. DefaultDialTimeout = 5 * time.Second // DefaultReadDeadline is the deadline for reading from the socket, disabling it requires it be set to -1. DefaultReadDeadline = 5 * time.Second // DefaultWriteDeadline is the deadline for writing to the socket, disabling it requires it be set to -1. DefaultWriteDeadline = 5 * time.Second )
Variables ¶
var ( ErrInvalidPacketTerminator = errors.New("the packet was not terminated correctly") ErrInvalidResponseToAuthPacket = errors.New("the server responded with an invalid packet type for a auth packet") ErrAuthPacketFailed = errors.New("the authentication attempt with the server failed") ErrInvalidPacketIDInResponse = errors.New("the server replied with a packet ID not in our request") ErrCommandEmpty = errors.New("the command must not be a blank string") ErrCommandTooLong = errors.New("the supplied command was too long") ErrInvalidPacketType = errors.New("packet type is invalid") ErrInvalidPacketTypeRust = errors.New("packet type is invalid (rust undocumented)") ErrAlreadyConnected = errors.New("remote console is already connected") ErrAlreadyAuthenticated = errors.New("remote console is already authenticated") )
Functions ¶
This section is empty.
Types ¶
type ClientPacket ¶
type ClientPacket struct { ID int32 Type ClientPacketType Body string }
ClientPacket represents an outgoing packet from the client to the remote server.
func (*ClientPacket) Size ¶
func (cp *ClientPacket) Size() int32
Size calculates the size of the packet.
func (*ClientPacket) WriteTo ¶
func (cp *ClientPacket) WriteTo(rc *RemoteConsole) (n int64, err error)
WriteTo writes this packet to the underlying connection.
type ClientPacketType ¶
type ClientPacketType int32
ClientPacketType represents the packet types that can be sent by the client to the server.
const ( // TODO: Implement this response check. // CheckResponse is a SERVERDATA_RESPONSE_VALUE packet type, used for multi-packet response checking. CheckResponse ClientPacketType = 0 // ExecuteCommand represents the SERVERDATA_EXECCOMMAND packet type. ExecuteCommand ClientPacketType = 2 // Auth represents the SERVERDATA_AUTH packet type. Auth ClientPacketType = 3 )
type RemoteConsole ¶
type RemoteConsole struct {
// contains filtered or unexported fields
}
func NewRemoteConsole ¶
func NewRemoteConsole(address string, password string, settings RemoteConsoleSettings) (rc *RemoteConsole, err error)
NewRemoteConsole creates a new remote console, dials it, and authenticates it.
func (*RemoteConsole) Authenticate ¶
func (rc *RemoteConsole) Authenticate(password string) (err error)
Authenticate sends the authentication packet.
func (*RemoteConsole) Close ¶
func (rc *RemoteConsole) Close() (err error)
Close forwards the Close() method from the underlying net.Conn.
func (*RemoteConsole) Dial ¶
func (rc *RemoteConsole) Dial(address string) (err error)
Dial sets up the connection and dials it.
func (*RemoteConsole) Execute ¶
func (rc *RemoteConsole) Execute(command string) (response string, err error)
Execute runs a command on the remote console.
func (*RemoteConsole) LocalAddr ¶
func (rc *RemoteConsole) LocalAddr() (addr net.Addr)
LocalAddr returns the LocalAddr() from the underlying net.Conn.
func (*RemoteConsole) RemoteAddr ¶
func (rc *RemoteConsole) RemoteAddr() (addr net.Addr)
RemoteAddr returns the RemoteAddr() from the underlying net.Conn.
type RemoteConsoleSettings ¶
type ServerPacket ¶
type ServerPacket struct { Size int32 ID int32 Type ServerPacketType BodyBytes []byte }
ServerPacket represents packets received from the server.
func NewServerPacketFromRemoteConsole ¶
func NewServerPacketFromRemoteConsole(rc *RemoteConsole) (n int64, packet *ServerPacket, err error)
NewServerPacketFromRemoteConsole reads the data from the socket and decodes it into a ServerPacket.
func (*ServerPacket) Body ¶
func (sp *ServerPacket) Body() string
Body converts the BodyBytes into a string.
type ServerPacketType ¶
type ServerPacketType int32
ServerPacketType represents the packet types that can be received by the client from the server.
const ( // ResponseValue represents the SERVERDATA_RESPONSE_VALUE packet type. ResponseValue ServerPacketType = 0 // AuthResponse represents the SERVERDATA_AUTH_RESPONSE packet type. AuthResponse ServerPacketType = 2 // RustUndocumentedPacket represents the unknown packet type from Rust with an ID of 4. RustUndocumentedPacket ServerPacketType = 4 )