quake3_rcon

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 5 Imported by: 2

README

Quake3 Rcon Go

This project is an implementation of quake3 rcon using golang.

Developped mainly for Urban Terror by Antoine Méresse (IG: Flirow)

Usage

Download

go get github.com/AntoineMeresse/quake3-rcon-go@latest
Main Usage

import (
	quake3_rcon "github.com/AntoineMeresse/quake3-rcon-go"
)

func main() {

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // ~~~~~~~~~~~~~ Setup ~~~~~~~~~~~~~~
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    rcon := quake3_rcon.Rcon{ServerIp: "localhost", ServerPort: 27960, Password: "toreplace", Connection: nil}

    rcon.Connect()
    defer rcon.CloseConnection()
    
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // ~~~~~~~~~~~~ Commands ~~~~~~~~~~~~
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    // Example of command which doesn't require to handle response:
	res := rcon.RconCommand("bigtext Hello")

	// Example of command which might require to handle response:
	res = rcon.RconCommand("sv_fps")
	responseType, datas := quake3_rcon.SplitReadInfos(res)
}
Other useful code sample

If you need to do some processing base on response datas:

responseType, datas := quake3_rcon.SplitReadInfos(res)
fmt.Printf("[Response] Type: %s, datas: %v", responseType, datas) 

// Will produce:

// [Response] Type: print, datas: ["sv_fps" is:"125^7" default:"20^7"]

[Debugging] Shorter command with some nice printing. /!\ Does not return anything /!\

quake3_rcon.PrintSplitReadInfos(res)
    
// Will produce:

// ~~~~~~~~~~ Print Read Infos ~~~~~~~~~~
// Type: print
// Line: 1
//    |---->  1) "sv_fps" is:"125^7" default:"20^7"

Licence

This project is released under MIT Licence.

Contribute

If you find any bugs or want to improve this software :

  • Feel free to contact me on discord: fliro
  • Open & submit a PR

Documentation

Index

Constants

View Source
const BufferSize = 8192

Variables

View Source
var PacketPrefix = []byte{'\xff', '\xff', '\xff', '\xff'}

Functions

func PrintSplitReadInfos

func PrintSplitReadInfos(infos string)

func SplitReadInfos

func SplitReadInfos(readstr string) (responseType string, datas []string)

Types

type Rcon

type Rcon struct {
	ServerIp   string
	ServerPort string
	Password   string
	Connection net.Conn
}

func (*Rcon) CloseConnection

func (rcon *Rcon) CloseConnection()

func (*Rcon) Connect

func (rcon *Rcon) Connect()

func (Rcon) RconCommand

func (rcon Rcon) RconCommand(command string) (res string)

func (Rcon) RconCommandExtractValue added in v1.0.1

func (rcon Rcon) RconCommandExtractValue(command string) string

func (Rcon) Read

func (rcon Rcon) Read() (response string)

func (Rcon) Send

func (rcon Rcon) Send(cmd string)

Jump to

Keyboard shortcuts

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