server

package
v0.0.0-...-1bf96ee Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Mtu = 1500

Variables

View Source
var READBUFFERSIZE = 65535
View Source
var USERCHANBUFFERSIZE = 1024
View Source
var UserPrivileges []*innerNet.InnerNetPrivilegeDto

Functions

func Dnat

func Dnat(data []byte, dst string)

func InitInnerNetConfig

func InitInnerNetConfig(innerNetDataDto innerNet.SlaveInnerNetDataDto) error

func Snat

func Snat(data []byte, src string)

func StartServer

func StartServer(innerNetDataDto innerNet.SlaveInnerNetDataDto) (err error)

func StopServer

func StopServer() error

Types

type Dhcp

type Dhcp struct {
	InnerNetDataDto *innerNet.SlaveInnerNetDataDto
	Ip              uint32
	Mask            uint32
	UsedIps         map[uint32]bool
}

func NewDhcp

func NewDhcp(vpnDataDto *innerNet.SlaveInnerNetDataDto) *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]innerNet.InnerNetUserDto
	InnerNetDataDto *innerNet.SlaveInnerNetDataDto
	TunServer       *iface.TunServer
	DhcpServer      *Dhcp
	Mutex           sync.Mutex
}

todo: add sync.Mutx for Users change

func NewLoginManager

func NewLoginManager(innerNetDataDto innerNet.SlaveInnerNetDataDto) (*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, conn net.Conn) 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)

func (*LoginManager) Stop

func (lm *LoginManager) Stop()

type TcpServer

type TcpServer struct {
	Addr            string
	InnerNetDataDto *innerNet.SlaveInnerNetDataDto
	TcpListener     net.Listener
	LoginManager    *LoginManager
}

func NewTcpServer

func NewTcpServer(innerNetDataDto innerNet.SlaveInnerNetDataDto, loginManager *LoginManager) (*TcpServer, error)

func (*TcpServer) Start

func (ts *TcpServer) Start()

func (*TcpServer) Stop

func (ts *TcpServer) Stop()

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)
	HeartbeatTime time.Time
	Privileges    []*innerNet.InnerNetPrivilegeDto
}

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