hlmux

package module
v0.0.0-...-68c50d2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

README

hlmux

Multiplexer for Half-Life games (and its mods)

hlmux logo

hlmux is a gateway of multiple upstream GoldSource servers, offering a mechanism to redirect a client among these upstreams.

⚠ THIS PROJECT IS STILL UNDER CONSTRUCTION.

Usage

hlmux is a Go package, and theoretically it's just a building block for a gateway application.

hlmuxd

For convenience, we offer an official gateway application hlmuxd to ease most users' pains. It also serves as an example to demonstrate the usage of hlmux.

  • Compilation
mkdir -p ./bin
go build -o ./bin ./cmd/hlmuxd
  • Sample configuration (config.json)
{
    "bind": "0.0.0.0:27015",
    "api": "0.0.0.0:27081",
    "ttl": "30",
    "upstreams": [
        {
            "name": "cs1",
            "address": "10.1.80.51:27001",
            "default": true
        },
        {
            "name": "cs2",
            "address": "10.1.80.51:27002"
        }
    ]
}
  • Running
./bin/hlmuxd -config config.json

# or without compilation
go run ./cmd/hlmuxd -config config.json

How does it work?

Valve has banned connect command for a long time (related issue) as a part of admin slowhacking mitigation. Many redirection plugins does not work any more, while they do serve as practical components, especially in community servers.

This project implements a gateway in front of multiple GoldSource game servers, so that the gateway can have its own decision on the traffic forwarding. After in-game plugins tell the gateway which nexthop the clients want, their traffic will be forwarded to the target server when they send handshakes next time.

The client side command retry is able to invoke re-handshaking (which is different from reconnect). Unfortunately, we have known that Valve's page is out of date by inspecting hw.so (or hw.dll on Windows) as shown below: retry is also banned, regardless of the value of cl_filterstuffcmd.

stuff text filter in hw.so

Good news is that there is still an approach to trick the clients into a state similar to a manually-issued retry. This is a sequential diagram of hlmux.

mechanism

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

func (*Conn) Client

func (c *Conn) Client() *net.UDPAddr

func (*Conn) Conn

func (c *Conn) Conn() *net.UDPConn

func (*Conn) NextUpstream

func (c *Conn) NextUpstream() *net.UDPAddr

func (*Conn) Proxy

func (c *Conn) Proxy() *net.UDPAddr

func (*Conn) Read

func (c *Conn) Read() ([]byte, error)

func (*Conn) RunForward

func (c *Conn) RunForward(conn *net.UDPConn) error

func (*Conn) SetNextUpstream

func (c *Conn) SetNextUpstream(upstream *net.UDPAddr)

func (*Conn) Stop

func (c *Conn) Stop() error

func (*Conn) Upstream

func (c *Conn) Upstream() *net.UDPAddr

func (*Conn) Write

func (c *Conn) Write(data []byte) error

type HandlerFunc

type HandlerFunc func(*Conn)

type HandlersChain

type HandlersChain []HandlerFunc

type Mux

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

func NewMux

func NewMux(upstream *net.UDPAddr) *Mux

func (*Mux) Connections

func (mux *Mux) Connections() []*Conn

func (*Mux) FindConnectionByClient

func (mux *Mux) FindConnectionByClient(client *net.UDPAddr) *Conn

func (*Mux) OnGetChallenge

func (mux *Mux) OnGetChallenge(handlers ...HandlerFunc)

func (*Mux) Run

func (mux *Mux) Run(address string) error

func (*Mux) SetDefaultUpstream

func (mux *Mux) SetDefaultUpstream(upstream *net.UDPAddr)

func (*Mux) SetLogger

func (mux *Mux) SetLogger(logger *log.Logger)

func (*Mux) SetTimeout

func (mux *Mux) SetTimeout(timeout time.Duration)

func (*Mux) SetWorkers

func (mux *Mux) SetWorkers(n int)

func (*Mux) Stop

func (mux *Mux) Stop()

type Reader

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

a wrapper of buffered IO reader

func NewReader

func NewReader(data []byte) *Reader

func (*Reader) Peek

func (rd *Reader) Peek(n int) ([]byte, error)

func (*Reader) PeekByte

func (rd *Reader) PeekByte() (byte, error)

func (*Reader) PeekUint16

func (rd *Reader) PeekUint16() (uint16, error)

func (*Reader) PeekUint32

func (rd *Reader) PeekUint32() (uint32, error)

func (*Reader) Read

func (rd *Reader) Read(p []byte) (n int, err error)

func (*Reader) ReadByte

func (rd *Reader) ReadByte() (byte, error)

func (*Reader) ReadBytes

func (rd *Reader) ReadBytes(delim byte) ([]byte, error)

func (*Reader) ReadLine

func (rd *Reader) ReadLine() (line []byte, isPrefix bool, err error)

func (*Reader) ReadRune

func (rd *Reader) ReadRune() (r rune, size int, err error)

func (*Reader) ReadSlice

func (rd *Reader) ReadSlice(delim byte) (line []byte, err error)

func (*Reader) ReadString

func (rd *Reader) ReadString(delim byte) (string, error)

func (*Reader) ReadUint16

func (rd *Reader) ReadUint16() (uint16, error)

func (*Reader) ReadUint32

func (rd *Reader) ReadUint32() (uint32, error)

func (*Reader) Size

func (rd *Reader) Size() int

func (*Reader) Unmunge2

func (rd *Reader) Unmunge2(seq uint32)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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