accelerator

package module
v0.0.0-...-b991a16 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: AGPL-3.0 Imports: 33 Imported by: 0

README

Accelerator

A simple game accelerator

build:
apt-get libpcap-dev
yum install libpcap-devel
On Windows, must enable Windows firewall for filter
outbound packets, include RST about TCP(not need rule).
add rule ICMPv4 destination unreachable(type 3, code 3),
add rule ICMPv6 destination unreachable(type 1, code 4),
On Linux, must use iptables/ip6tables for filter outbound
packets, include RST about TCP and ICMPv4/ICMPv6.
iptables -A OUTPUT -p tcp -m tcp --tcp-flags RST RST -j DROP
iptables -A OUTPUT -p icmp -m icmp --icmp-type 3 -j DROP
ip6tables -A OUTPUT -p tcp -m tcp --tcp-flags RST RST -j DROP
ip6tables -A OUTPUT -p icmpv6 -m icmpv6 --icmpv6-type 1 -j DROP
recommend enable TCP BBR for better effect(IPv4&IPv6)

sudo sysctl -w net.ipv4.tcp_congestion_control=bbr

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePasswordHash

func GeneratePasswordHash(password []byte) string

GeneratePasswordHash is used to generate password hash.

Types

type Client

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

Client is the accelerator client.

func NewClient

func NewClient(cfg *ClientConfig) (*Client, error)

NewClient is used to create a new client from configuration.

func (*Client) Close

func (client *Client) Close() error

Close is used to close accelerator client.

func (*Client) Run

func (client *Client) Run() error

Run is used to run the accelerator client.

type ClientConfig

type ClientConfig struct {
	Common struct {
		Interface string `toml:"interface"`
		PassHash  string `toml:"pwd_hash"`
		LogPath   string `toml:"log_path"`
	} `toml:"common"`

	Client struct {
		Mode         string   `toml:"mode"`
		ConnPoolSize int      `toml:"conn_pool_size"`
		Timeout      duration `toml:"timeout"`
	} `toml:"client"`

	TCP struct {
		RemoteNetwork string `toml:"remote_network"`
		RemoteAddress string `toml:"remote_address"`
		LocalNetwork  string `toml:"local_network"`
		LocalAddress  string `toml:"local_address"`
	} `toml:"tcp"`

	UDP struct {
		RemoteNetwork string `toml:"remote_network"`
		RemoteAddress string `toml:"remote_address"`
		LocalNetwork  string `toml:"local_network"`
		LocalAddress  string `toml:"local_address"`
	} `toml:"udp"`

	TLS struct {
		ClientCert string `toml:"client_cert"`
		ClientKey  string `toml:"client_key"`
		RootCA     string `toml:"root_ca"`
	} `toml:"tls"`

	TAP struct {
		ComponentID string `toml:"component_id"`
		DeviceName  string `toml:"device_name"`
	} `toml:"tap"`
}

ClientConfig contains accelerator client configurations.

type Server

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

Server is the accelerator server.

func NewServer

func NewServer(cfg *ServerConfig) (*Server, error)

NewServer is used to create a new server from configuration.

func (*Server) Close

func (srv *Server) Close() error

Close is used to close accelerator server.

func (*Server) Run

func (srv *Server) Run()

Run is used to run the accelerator server.

type ServerConfig

type ServerConfig struct {
	Common struct {
		Interface string `toml:"interface"`
		PassHash  string `toml:"pwd_hash"`
		LogPath   string `toml:"log_path"`
	} `toml:"common"`

	Server struct {
		ConnPoolSize   int      `toml:"conn_pool_size"`
		NumFrameSender int      `toml:"num_frame_sender"`
		Timeout        duration `toml:"timeout"`
	} `toml:"server"`

	TCP struct {
		Enabled bool   `toml:"enabled"`
		Network string `toml:"network"`
		Address string `toml:"address"`
	} `toml:"tcp"`

	UDP struct {
		Enabled bool   `toml:"enabled"`
		Network string `toml:"network"`
		Address string `toml:"address"`
	} `toml:"udp"`

	TLS struct {
		ServerCert string `toml:"server_cert"`
		ServerKey  string `toml:"server_key"`
		ClientCA   string `toml:"client_ca"`
	} `toml:"tls"`

	NAT struct {
		Enabled bool     `toml:"enabled"`
		Timeout duration `toml:"timeout"`

		MAC struct {
			Local   string `toml:"local"`
			Gateway string `toml:"gateway"`
		} `toml:"mac"`

		IPv4 struct {
			Enabled bool   `toml:"enabled"`
			Local   string `toml:"local"`
			Gateway string `toml:"gateway"`
		} `toml:"ipv4"`

		IPv6 struct {
			Enabled bool   `toml:"enabled"`
			Local   string `toml:"local"`
			Gateway string `toml:"gateway"`
		} `toml:"ipv6"`
	} `toml:"nat"`
}

ServerConfig contains accelerator server configurations.

Directories

Path Synopsis
cmd
testtool

Jump to

Keyboard shortcuts

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