server

package
v0.0.0-...-a9387a1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrongUserPassword = logex.Define("wrong username or password")
	ErrNotReady          = logex.Define("not ready")
)
View Source
var Slogan = `
   _  _______  ________
  / |/ / __/ |/_/_  __/
 /    / _/_>  <  / /   
/_/|_/___/_/|_| /_/    
`

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug      bool `desc:"turn on debug"`
	DebugStack bool `default:"true"`
	DebugFlow  bool
	DebugTun   bool

	ChannelType string `name:"chantype" default:"tcp"`

	HTTP     string    `desc:"listen http port" default:":11311"`
	HTTPAes  string    `name:"key" desc:"http aes key; required"`
	HTTPCert string    `desc:"https cert file path"`
	HTTPKey  string    `desc:"https key file path"`
	Sock     string    `desc:"unixsock for interactive with" default:"/tmp/next.sock"`
	MTU      int       `default:"1500"`
	Net      *ip.IPNet `default:"10.8.0.1/24"`
	Pprof    string    `default:":10060"`
	DevId    int

	DBPath string `desc:"filepath to persist user info" default:"nextuser"`
}

func (*Config) FlaglyDesc

func (c *Config) FlaglyDesc() string

func (*Config) FlaglyHandle

func (c *Config) FlaglyHandle(f *flow.Flow, h *flagly.Handler) error

func (*Config) FlaglyVerify

func (c *Config) FlaglyVerify() error

type Dchan

type Dchan struct {
}

type HttpApi

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

func NewHttpApi

func NewHttpApi(f *flow.Flow, listen string, users *uc.Users, ct *clock.Clock, key []byte, cfg *mchan.SvrConf, delegate HttpDelegate) *HttpApi

func (*HttpApi) Auth

func (h *HttpApi) Auth(req *mchan.Req) interface{}

func (*HttpApi) Run

func (h *HttpApi) Run() error

func (*HttpApi) Time

func (h *HttpApi) Time(req *mchan.Req) interface{}

type HttpDelegate

type HttpDelegate interface {
	GetChannelType() string
	AllocIP() *ip.IP
	GetGateway() *ip.IPNet
	GetMTU() int
	GetDataChannel() int
	OnNewUser(userId int)
}

type Server

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

func New

func New(cfg *Config, f *flow.Flow) *Server

func (*Server) AllocIP

func (s *Server) AllocIP() *ip.IP

func (*Server) Close

func (s *Server) Close()

func (*Server) GetAllDataChannel

func (s *Server) GetAllDataChannel() []int

func (*Server) GetChannelType

func (s *Server) GetChannelType() string

func (*Server) GetDataChannel

func (s *Server) GetDataChannel() int

func (*Server) GetGateway

func (s *Server) GetGateway() *ip.IPNet

func (*Server) GetMTU

func (s *Server) GetMTU() int

func (*Server) GetUserChannelFromDataChannel

func (s *Server) GetUserChannelFromDataChannel(id int) (
	fromUser packet.RecvChan, toUser packet.SendChan, err error)

controller -> user -> datachannel

func (*Server) GetUserToken

func (s *Server) GetUserToken(id int) ([]byte, error)

func (*Server) OnDChanUpdate

func (s *Server) OnDChanUpdate(port []int)

func (*Server) OnNewChannel

func (s *Server) OnNewChannel(ch dchan.Channel)

func (*Server) OnNewUser

func (s *Server) OnNewUser(userId int)

func (*Server) Run

func (s *Server) Run()

type Shell

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

func NewShell

func NewShell(svr *Server, sock string) (*Shell, error)

func (*Shell) Close

func (s *Shell) Close()

type ShellCLI

type ShellCLI struct {
	Help  flagly.CmdHelp `flagly:"handler"`
	User  ShellUser      `flagly:"handler"`
	Debug *ShellDebug    `flagly:"handler"`
	Dchan *Dchan         `flagly:"handler"`
}

type ShellDebug

type ShellDebug struct {
	Goroutine *ShellDebugGoroutine `flagly:"handler"`
	Log       *ShellDebugLog       `flagly:"handler"`
}

type ShellDebugGoroutine

type ShellDebugGoroutine struct {
	Find string `type:"[0]"`
}

func (ShellDebugGoroutine) FlaglyHandle

func (s ShellDebugGoroutine) FlaglyHandle(rl *readline.Instance) error

type ShellDebugLog

type ShellDebugLog struct {
	Level string `type:"[0]" select:"debug,info,warn,error"`
}

func (ShellDebugLog) FlaglyHandle

func (s ShellDebugLog) FlaglyHandle(rl *readline.Instance) error

type ShellUser

type ShellUser struct {
	Show *ShellUserShow `flagly:"handler"`
	Add  *ShellUserAdd  `flagly:"handler"`
}

type ShellUserAdd

type ShellUserAdd struct {
	Name string `type:"[0]"`
}

func (*ShellUserAdd) FlaglyHandle

func (c *ShellUserAdd) FlaglyHandle(s *Server, rl *readline.Instance) error

type ShellUserShow

type ShellUserShow struct {
	All bool `name:"a"`
}

func (ShellUserShow) FlaglyHandle

func (su ShellUserShow) FlaglyHandle(s *Server, rl *readline.Instance) error

type Tun

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

func (*Tun) Close

func (t *Tun) Close()

func (*Tun) ReadChan

func (t *Tun) ReadChan() <-chan []byte

func (*Tun) Run

func (t *Tun) Run()

func (*Tun) WriteChan

func (t *Tun) WriteChan() chan<- []byte

Jump to

Keyboard shortcuts

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