Categorygithub.com/gorcon/websocket
modulepackage
0.1.0
Repository: https://github.com/gorcon/websocket.git
Documentation: pkg.go.dev

# README

Websocket

golangci-lint Go Report Card Build Status Coverage GoDoc

Rust Web RCON Protocol implementation in Go.

Supported Games

  • Rust (add +rcon.web 1 to the args when starting the server)

Install

go get github.com/gorcon/websocket

See Changelog for release details.

Usage

package main

import (
	"log"
	"fmt"

	"github.com/gorcon/websocket"
)

func main() {
	conn, err := websocket.Dial("127.0.0.1:28016", "password")
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	response, err := conn.Execute("status")
	if err != nil {
		log.Fatal(err)
	}
	
	fmt.Println(response)	
}

Requirements

Go 1.15 or higher

Contribute

Contributions are more than welcome!

If you think that you have found a bug, create an issue and publish the minimum amount of code triggering the bug so it can be reproduced.

If you want to fix the bug then you can create a pull request. If possible, write a test that will cover this bug.

License

MIT License, see LICENSE

# Functions

Dial creates a new authorized WebSocket dialer connection.
SetDeadline injects read/write Timeout to Settings.
SetDialTimeout injects dial Timeout to Settings.

# Constants

DefaultDeadline provides default deadline to tcp read/write operations.
DefaultDialTimeout provides default auth timeout to remote server.
MaxCommandLen is an artificial restriction, but it will help in case of random large queries.

# Variables

DefaultSettings provides default deadline settings to Conn.
ErrAuthFailed is returned when the package id from authentication response is -1.
ErrCommandEmpty is returned when executed command length equal 0.
ErrCommandTooLong is returned when executed command length is bigger than MaxCommandLen characters.

# Structs

Conn represents a WebSocket connection.
Message is both requests and responses are sent as packets wia WebSocket.
Settings contains option to Conn.

# Type aliases

Option allows to inject settings to Settings.