server

package
v0.0.0-...-5f124ca Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNORDERED_FLAG = 0x01 // 0000 0001
)

Variables

View Source
var ErrBadClientHello = errors.New("non (or malformed) ClientHello")
View Source
var ErrBadDecryption = errors.New("decryption/authentication faliure")
View Source
var ErrBadGET = errors.New("non (or malformed) HTTP GET")
View Source
var ErrBadProxyMethod = errors.New("invalid proxy method")
View Source
var ErrCiphertextLength = errors.New("ciphertext has the wrong length")
View Source
var ErrInvalidPubKey = errors.New("public key has invalid format")
View Source
var ErrReplay = errors.New("duplicate random")
View Source
var ErrTimestampOutOfWindow = errors.New("timestamp is outside of the accepting window")
View Source
var ErrUnrecognisedProtocol = errors.New("unrecognised protocol")

Functions

func AuthFirstPacket

func AuthFirstPacket(firstPacket []byte, transport Transport, sta *State) (info ClientInfo, finisher Responder, err error)

AuthFirstPacket checks if the first packet of data is ClientHello or HTTP GET, and checks if it was from a Cloak client if it is from a Cloak client, it returns the ClientInfo with the decrypted fields. It doesn't check if the user is authorised. It also returns a finisher callback function to be called when the caller wishes to proceed with the handshake

func MakeUserPanel

func MakeUserPanel(manager usermanager.UserManager) *userPanel

func Serve

func Serve(l net.Listener, sta *State)

Types

type ActiveUser

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

func (*ActiveUser) CloseSession

func (u *ActiveUser) CloseSession(sessionID uint32, reason string)

CloseSession closes a session and removes its reference from the user

func (*ActiveUser) GetSession

func (u *ActiveUser) GetSession(sessionID uint32, config mux.SessionConfig) (sesh *mux.Session, existing bool, err error)

GetSession returns the reference to an existing session, or if one such session doesn't exist, it queries the UserManager for the authorisation for a new session. If a new session is allowed, it creates this new session and returns its reference

func (*ActiveUser) NumSession

func (u *ActiveUser) NumSession() int

NumSession returns the number of active sessions

type ClientHello

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

ClientHello contains every field in a ClientHello message

type ClientInfo

type ClientInfo struct {
	UID              []byte
	SessionId        uint32
	ProxyMethod      string
	EncryptionMethod byte
	Unordered        bool
	Transport        Transport
}

type RawConfig

type RawConfig struct {
	ProxyBook    map[string][]string
	BindAddr     []string
	BypassUID    [][]byte
	RedirAddr    string
	PrivateKey   []byte
	AdminUID     []byte
	DatabasePath string
	KeepAlive    int
	CncMode      bool
}

func ParseConfig

func ParseConfig(conf string) (raw RawConfig, err error)

ParseConfig reads the config file or semicolon-separated options and parse them into a RawConfig

type Responder

type Responder = func(originalConn net.Conn, sessionKey [32]byte, randSource io.Reader) (preparedConn net.Conn, err error)

type State

type State struct {
	ProxyBook   map[string]net.Addr
	ProxyDialer common.Dialer

	WorldState common.WorldState
	AdminUID   []byte

	BypassUID map[[16]byte]struct{}
	StaticPv  crypto.PrivateKey

	// TODO: this doesn't have to be a net.Addr; resolution is done in Dial automatically
	RedirHost   net.Addr
	RedirPort   string
	RedirDialer common.Dialer

	UsedRandom map[[32]byte]int64

	Panel *userPanel
	// contains filtered or unexported fields
}

State type stores the global state of the program

func InitState

func InitState(preParse RawConfig, worldState common.WorldState) (sta *State, err error)

InitState process the RawConfig and initialises a server State accordingly

func (*State) IsBypass

func (sta *State) IsBypass(UID []byte) bool

IsBypass checks if a UID is a bypass user

func (*State) UsedRandomCleaner

func (sta *State) UsedRandomCleaner()

UsedRandomCleaner clears the cache of used random fields every replayCacheAgeLimit

type TLS

type TLS struct{}

func (TLS) String

func (TLS) String() string

type Transport

type Transport interface {
	// contains filtered or unexported methods
}

type WebSocket

type WebSocket struct{}

func (WebSocket) String

func (WebSocket) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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