core

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSum added in v1.0.3

func CheckSum(buf []byte) uint16

Types

type Config

type Config struct {
	ServerConfig     ServerConfig      `yaml:"server"`
	DHCPConfig       DHCPConfig        `yaml:"dhcp"`
	ResolverConfig   ResolverConfig    `yaml:"resolver"`
	TCPForwardConfig TCPForwardConfig  `yaml:"tcpforward"`
	UDPForwardConfig UDPForwardConfig  `yaml:"udpforward"`
	Plugins          map[string]string `yaml:"plugin"`
}

func ParseConfig

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

func (*Config) String

func (c *Config) String() string

type DHCP

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

func NewDHCP

func NewDHCP(cidr string) (*DHCP, error)

func (*DHCP) GetCIDR

func (g *DHCP) GetCIDR() string

func (*DHCP) ReleaseIP

func (g *DHCP) ReleaseIP(ip string)

func (*DHCP) SelectIP

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

type DHCPConfig

type DHCPConfig struct {
	Cidr string `yaml:"cidr"`
	IP   string `yaml:"ip"`
}

type Resolver

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

func NewResolve

func NewResolve(endpoints []string) (*Resolver, error)

func (*Resolver) ApplyDomain

func (r *Resolver) ApplyDomain(domain, ip string) error

type ResolverConfig

type ResolverConfig struct {
	EtcdEndpoints []string `yaml:"etcdEndpoints"`
}

type Server

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

func NewServer

func NewServer(cfg ServerConfig,
	dhcp *DHCP,
	resolver *Resolver) *Server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

type ServerConfig

type ServerConfig struct {
	ListenAddr string `yaml:"listen"`
	AuthKey    string `yaml:"authKey"`
	Domain     string `yaml:"domain"`
}

type Session

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

Session defines each opennotr_client to opennotr_server connection

type SessionManager added in v1.0.3

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

SessionManager defines the session info add/delete/get actions

func GetSessionManager added in v1.0.3

func GetSessionManager() *SessionManager

GetSessionManager returs the singleton of session manager

func (*SessionManager) AddSession added in v1.0.3

func (mgr *SessionManager) AddSession(vip string, sess *Session)

func (*SessionManager) DeleteSession added in v1.0.3

func (mgr *SessionManager) DeleteSession(vip string)

func (*SessionManager) GetSession added in v1.0.3

func (mgr *SessionManager) GetSession(vip string) *Session

type TCPForward added in v1.0.3

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

func NewTCPForward added in v1.0.3

func NewTCPForward(cfg TCPForwardConfig) *TCPForward

func (*TCPForward) Listen added in v1.0.3

func (f *TCPForward) Listen() (net.Listener, error)

func (*TCPForward) Serve added in v1.0.3

func (f *TCPForward) Serve(listener net.Listener) error

type TCPForwardConfig added in v1.0.3

type TCPForwardConfig struct {
	ListenAddr   string `yaml:"listen"`
	ReadTimeout  int    `yaml:"readTimeout"`
	WriteTimeout int    `yaml:"writeTimeout"`
}

type UDPForward added in v1.0.3

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

func NewUDPForward added in v1.0.3

func NewUDPForward(cfg UDPForwardConfig) *UDPForward

func (*UDPForward) Listen added in v1.0.3

func (f *UDPForward) Listen() (*net.UDPConn, error)

Listen listens a udp port, since that we use tproxy to redirect traffic to this listened udp port so the socket should set to ip transparent option

func (*UDPForward) Serve added in v1.0.3

func (f *UDPForward) Serve(lconn *net.UDPConn) error

type UDPForwardConfig added in v1.0.3

type UDPForwardConfig struct {
	ListenAddr     string `yaml:"listen"`
	ReadTimeout    int    `yaml:"readTimeout"`
	WriteTimeout   int    `yaml:"writeTimeout"`
	SessionTimeout int    `yaml:"sessionTimeout"`
}

Jump to

Keyboard shortcuts

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