server

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCP = "tcp"
	UDP = "udp"
)

Variables

View Source
var (
	ErrNotConnected   = errors.New("not connected")
	ErrClientIsOnline = errors.New("client is online")
)

Functions

func NewKeyMap

func NewKeyMap() *keymap

Types

type App added in v1.2.0

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

func NewApp added in v1.2.0

func NewApp(configPath string) *App

func (*App) AddClient added in v1.2.0

func (a *App) AddClient(clientID string) error

func (*App) AddClientTunnel added in v1.2.0

func (a *App) AddClientTunnel(clientID string, tunnel config.Listener) error

func (*App) Config added in v1.2.0

func (a *App) Config() *config.ServerConfig

func (*App) GetClient added in v1.2.0

func (a *App) GetClient(clientID string) (*config.Client, error)

func (*App) GetClientTunnel added in v1.2.0

func (a *App) GetClientTunnel(clientID string, tunnelID string) (*config.Listener, error)

func (*App) GetClientTunnels added in v1.2.0

func (a *App) GetClientTunnels(clientID string) ([]*config.Listener, error)

func (*App) GetKey added in v1.2.0

func (a *App) GetKey(clientID string) (string, error)

func (*App) GetOnline added in v1.2.0

func (a *App) GetOnline(clientID string) (bool, error)

func (*App) RemoveClient added in v1.2.0

func (a *App) RemoveClient(clientID string) error

func (*App) RemoveClientTunnel added in v1.2.0

func (a *App) RemoveClientTunnel(clientID string, tunnelID string) error

func (*App) SaveConfig added in v1.2.0

func (a *App) SaveConfig() error

func (*App) Start added in v1.2.0

func (a *App) Start() error

type Gateway

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

func NewGateway

func NewGateway(conf config.Gateway, listenerMgr *ListenerMgr, sessionMgr *SessionManager) *Gateway

func (*Gateway) IsOnline added in v1.2.0

func (g *Gateway) IsOnline(clientID string) bool

func (*Gateway) Run

func (g *Gateway) Run() error

type IOdata

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

保存listener输入输出的数据总大小

func (*IOdata) AddInput

func (io *IOdata) AddInput(n int64)

func (*IOdata) AddOutput

func (io *IOdata) AddOutput(n int64)

func (*IOdata) GetInput

func (io *IOdata) GetInput() int64

func (*IOdata) GetOutput

func (io *IOdata) GetOutput() int64

type Listener

type Listener struct {
	Uuid string

	Encrypt bool
	Key     []byte
	// contains filtered or unexported fields
}

func NewListener

func NewListener(listenerConfig *config.Listener, key []byte, sessionMgr *SessionManager, udpSessionMgr *UDPSessionManage) *Listener

func (*Listener) Close

func (l *Listener) Close()

func (*Listener) ListenAndServe

func (l *Listener) ListenAndServe() error

type ListenerMgr added in v1.2.0

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

func NewListenerMgr added in v1.2.0

func NewListenerMgr(sessionMgr *SessionManager, udpSessionMgr *UDPSessionManage, keymap *keymap) *ListenerMgr

func (*ListenerMgr) AddClient added in v1.2.0

func (lm *ListenerMgr) AddClient(clientID string) error

func (*ListenerMgr) AddListener added in v1.2.0

func (lm *ListenerMgr) AddListener(clientID string, listenerConfig *config.Listener) error

func (*ListenerMgr) CheckExist added in v1.2.0

func (lm *ListenerMgr) CheckExist(clientID string) bool

func (*ListenerMgr) RemoveClient added in v1.2.0

func (lm *ListenerMgr) RemoveClient(clientID string) error

func (*ListenerMgr) RemoveListener added in v1.2.0

func (lm *ListenerMgr) RemoveListener(clientID string, tunnelID string) error

type Session

type Session struct {
	ClientID   string        // 客户端ID
	Connection *smux.Session // 双向连接 server <=> client
}

type SessionManager

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

func NewSessionManager

func NewSessionManager() *SessionManager

func (*SessionManager) AddSession

func (sm *SessionManager) AddSession(clientID string, conn net.Conn) (*Session, error)

func (*SessionManager) CheckAlive

func (sm *SessionManager) CheckAlive(clientID string)

检测到客户端离线后删除session

func (*SessionManager) GetSessionConnByID

func (sm *SessionManager) GetSessionConnByID(clientID string) (common.VeilConn, error)

type UDPSessionManage

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

管理UDP连接

func NewUDPSessionManage

func NewUDPSessionManage() *UDPSessionManage

func (*UDPSessionManage) Add

func (usm *UDPSessionManage) Add(key string, session *UDPsession)

func (*UDPSessionManage) CleanCache

func (usm *UDPSessionManage) CleanCache(key string)

func (*UDPSessionManage) Get

func (usm *UDPSessionManage) Get(key string) (*UDPsession, error)

type UDPsession

type UDPsession struct {
	RemoteAddr string
	LocalAddr  string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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