Documentation ¶
Index ¶
- Constants
- Variables
- func AuthFirstPacket(firstPacket []byte, transport Transport, sta *State) (info ClientInfo, finisher Responder, err error)
- func MakeUserPanel(manager usermanager.UserManager) *userPanel
- func Serve(l net.Listener, sta *State)
- type ActiveUser
- type ClientHello
- type ClientInfo
- type RawConfig
- type Responder
- type State
- type TLS
- type Transport
- type WebSocket
Constants ¶
const (
UNORDERED_FLAG = 0x01 // 0000 0001
)
Variables ¶
var ErrBadClientHello = errors.New("non (or malformed) ClientHello")
var ErrBadDecryption = errors.New("decryption/authentication faliure")
var ErrBadGET = errors.New("non (or malformed) HTTP GET")
var ErrBadProxyMethod = errors.New("invalid proxy method")
var ErrCiphertextLength = errors.New("ciphertext has the wrong length")
var ErrInvalidPubKey = errors.New("public key has invalid format")
var ErrReplay = errors.New("duplicate random")
var ErrTimestampOutOfWindow = errors.New("timestamp is outside of the accepting window")
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
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 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 ¶
ParseConfig reads the config file or semicolon-separated options and parse them into a RawConfig
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) UsedRandomCleaner ¶
func (sta *State) UsedRandomCleaner()
UsedRandomCleaner clears the cache of used random fields every replayCacheAgeLimit