server

package
v0.0.0-...-a69ce32 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var READBUFFERSIZE = 65535
View Source
var UDPCHANBUFFERSIZE = 1024
View Source
var USERCHANBUFFERSIZE = 1024

Functions

func Dnat

func Dnat(data []byte, dst string)

func Snat

func Snat(data []byte, src string)

Types

type Dhcp

type Dhcp struct {
	Cfg     *config.Config
	Ip      uint32
	Mask    uint32
	UsedIps map[uint32]bool
}

func NewDhcp

func NewDhcp(cfg *config.Config) *Dhcp

func (*Dhcp) ApplyIp

func (dhcp *Dhcp) ApplyIp() (string, error)

func (*Dhcp) ReleaseIp

func (dhcp *Dhcp) ReleaseIp(ip string)

type LoginManager

type LoginManager struct {
	//key: clientProtocol:clientIP:clientPort  value: key for AES
	Users      map[string]*User
	Tokens     map[string]bool
	Cfg        *config.Config
	TunServer  *tun.TunServer
	DhcpServer *Dhcp

	Mutex sync.Mutex
}

todo: add sync.Mutx for Users change

func NewLoginManager

func NewLoginManager(cfg *config.Config) (*LoginManager, error)

func (*LoginManager) GetUser

func (lm *LoginManager) GetUser(client string) *User

func (*LoginManager) Login

func (lm *LoginManager) Login(client string, protocol string, token string) error

func (*LoginManager) Logout

func (lm *LoginManager) Logout(client string)

func (*LoginManager) Start

func (lm *LoginManager) Start()

func (*LoginManager) StartClient

func (lm *LoginManager) StartClient(client string, conn net.Conn)

type PTcpServer

type PTcpServer struct {
	Addr         string
	Cfg          *config.Config
	PTcpListener net.Listener
	LoginManager *LoginManager
}

func NewPTcpServer

func NewPTcpServer(cfg *config.Config, loginManager *LoginManager) (*PTcpServer, error)

func (*PTcpServer) Start

func (ts *PTcpServer) Start()

func (*PTcpServer) Stop

func (ts *PTcpServer) Stop()

type TcpServer

type TcpServer struct {
	Addr         string
	Cfg          *config.Config
	TcpListener  net.Listener
	LoginManager *LoginManager
}

func NewTcpServer

func NewTcpServer(cfg *config.Config, loginManager *LoginManager) (*TcpServer, error)

func (*TcpServer) Start

func (ts *TcpServer) Start()

func (*TcpServer) Stop

func (ts *TcpServer) Stop()

type UdpServer

type UdpServer struct {
	Addr          string
	UdpConn       *net.UDPConn
	LoginManager  *LoginManager
	TunToConnChan chan string
	ConnToTunChan chan string
	RouteMap      *cache.Cache
}

func NewUdpServer

func NewUdpServer(cfg *config.Config, loginManager *LoginManager) (*UdpServer, error)

func (*UdpServer) Start

func (us *UdpServer) Start() error

func (*UdpServer) Stop

func (us *UdpServer) Stop() error

type User

type User struct {
	Client        string
	Protocol      string
	RemoteTunIp   string
	LocalTunIp    string
	Token         string
	Key           string
	TunToConnChan chan string
	ConnToTunChan chan string
	Conn          net.Conn
	Logout        func(client string)
}

func NewUser

func NewUser(client string, protocol string, tun string, token string, conn net.Conn, logout func(string)) *User

func (*User) Close

func (user *User) Close()

func (*User) Start

func (user *User) Start()

Jump to

Keyboard shortcuts

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