gtund

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(dst, src net.Conn)

func GetPublicIP

func GetPublicIP() string

func Main

func Main()

Types

type Config

type Config struct {
	Name            string           `toml:"name"`
	ServerConfig    *ServerConfig    `toml:"server"`
	DHCPConfig      *DHCPConfig      `toml:"dhcp"`
	InterfaceConfig *InterfaceConfig `toml:"interface"`
	RegistryConfig  *RegistryConfig  `toml:"registry"`
	ReverseConfig   *ReverseConfig   `toml:"reverse"`
}

func ParseConfig

func ParseConfig(path string) (*Config, error)

func (*Config) String

func (c *Config) String() string

type DHCP

type DHCP struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewDHCP

func NewDHCP(cfg *DHCPConfig) (*DHCP, error)

func (*DHCP) RecycleIP

func (dhcp *DHCP) RecycleIP(ip string)

func (*DHCP) SelectIP

func (dhcp *DHCP) SelectIP() (string, error)

type DHCPConfig

type DHCPConfig struct {
	Gateway     string `toml:"gateway"`
	Nameserver  string `toml:"nameserver"`
	CIDR        string `toml:"cidr"`
	ClientCount int    `toml:"-"`
}

type Forward

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

func NewForward

func NewForward() *Forward

func (*Forward) Add

func (forward *Forward) Add(cip string, conn net.Conn)

func (*Forward) Broadcast

func (forward *Forward) Broadcast(sndqueue chan *GtunClientContext, buff []byte)

func (*Forward) Del

func (forward *Forward) Del(cip string)

func (*Forward) Get

func (forward *Forward) Get(cip string) (conn net.Conn)

func (*Forward) Peer

func (forward *Forward) Peer(sndqueue chan *GtunClientContext, dst string, buff []byte) error

type Frame

type Frame []byte

func (Frame) Invalid

func (f Frame) Invalid() bool

func (Frame) IsIPV4

func (f Frame) IsIPV4() bool

type GtunClientContext

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

type Interface

type Interface struct {
	*water.Interface
	// contains filtered or unexported fields
}

func NewInterface

func NewInterface(cfg *InterfaceConfig, ip, cidr string) (*Interface, error)

type InterfaceConfig

type InterfaceConfig struct {
	IsTap bool `toml:"istap"`
}

type Packet

type Packet []byte

func (Packet) Dst

func (p Packet) Dst() string

func (Packet) Invalid

func (p Packet) Invalid() bool

func (Packet) Src

func (p Packet) Src() string

func (Packet) Version

func (p Packet) Version() int

type Registry

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

func NewRegistry

func NewRegistry(cfg *RegistryConfig, service *Service) *Registry

func (*Registry) Run

func (r *Registry) Run() error

func (*Registry) Sync

func (g *Registry) Sync(inc int) error

type RegistryConfig

type RegistryConfig struct {
	HeartbeatInterval int    `toml:"interval"`
	Timeout           int    `toml:"timeout"`
	Addr              string `toml:"addr"`
	Token             string `toml:"token"`
	Must              bool   `toml:"must"`
}

type Reverse

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

func NewReverse

func NewReverse(cfg *ReverseConfig) *Reverse

func (*Reverse) LoadPolicy

func (r *Reverse) LoadPolicy(path string) ([]*ReversePolicy, error)

func (*Reverse) Run

func (r *Reverse) Run() error

type ReverseConfig

type ReverseConfig struct {
	Rule string `toml:"rule"`
}

type ReversePolicy

type ReversePolicy struct {
	Proto string `json:"proto"`
	From  string `json:"from"`
	To    string `to:"json"`
}

type Server

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

func NewServer

func NewServer(cfg *ServerConfig, dhcp *DHCP, iface *Interface, registry *Registry) (*Server, error)

func (*Server) Close

func (s *Server) Close()

func (*Server) Run

func (s *Server) Run() error

type ServerConfig

type ServerConfig struct {
	Listen      string   `toml:"listen"`
	AuthKey     string   `toml:"auth_key"`
	RouteUrl    string   `toml:"route_url"`
	Nameservers []string `toml:"nameservers"`
}

type Service

type Service struct {
	Name        string
	PublicIP    string
	Port        int
	CIDR        string
	ClientLimit int
	IsTap       bool
}

Jump to

Keyboard shortcuts

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