internal

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TunMtuSize is mtu size in TUN.
	TunMtuSize = 1500

	// TunPacketBufferSize is buffer size in TUN.
	TunPacketBufferSize = 4 * 1024

	// TunTxLen is a sending queue size in TUN.
	TunTxLen = 300
)
View Source
const (
	HS256 = "HS256"
)

Variables

View Source
var (
	ErrorUnknown              = errors.New("[ERR] Unknown")
	ErrorInvalidParams        = errors.New("[ERR] Invalid Params")
	ErrorUnauthorized         = errors.New("[ERR] Unauthorized")
	ErrorInvalidJWT           = errors.New("[ERR] Invalid JWT")
	ErrorInvalidContext       = errors.New("[ERR] Invalid Context")
	ErrorExceedClientPool     = errors.New("[ERR] Exceed Client Pool")
	ErrorCloseConnection      = errors.New("[ERR] Close Connection")
	ErrorReceiveUnknownPacket = errors.New("[ERR] Receive Unknown Packet")
	ErrorMismatchVpnIP        = errors.New("[ERR] Mismatch Vpn IP")
	ErrorStoppingServer       = errors.New("[ERR] Stopping Server")
	ErrorAlreadyRunning       = errors.New("[ERR] Already Running")
)

Functions

func AddRoute

func AddRoute(addr, viaAddr net.IP, tun string) error

AddRoute routes all traffic for addr via interface tunName.

func CommandExec

func CommandExec(command string, args []string) error

CommandExec executes command

func DecodeJWT

func DecodeJWT(data string, salt []byte) (*jwt.Token, error)

DecodeJWT is to decode jwt using HS256.

func DelRoute

func DelRoute(addr, viaAddr net.IP, tun string) error

DelRoute deletes the route in the system routing table to a specific destination.

func EncodeJWT

func EncodeJWT(claims *jwt.StandardClaims, salt []byte) (string, error)

EncodeJWT is to encode jwt using HS256.

func GenerateRandomString

func GenerateRandomString(size int) string

GenerateRandomString returns random string having `size` string length.

func GetIPByAddr

func GetIPByAddr(addr string) (net.IP, error)

GetIPByAddr returns ip.

func GetNetGateway

func GetNetGateway() (gw, dev string, err error)

GetNetGateway return net gateway (default route) and nic.

func IncreaseIP

func IncreaseIP(ip net.IP)

IncreaseIP is to increase 1.

func InterfaceToString

func InterfaceToString(i interface{}) string

InterfaceToString converts a value having interface type to string

func IsMatchedStringFromSlice

func IsMatchedStringFromSlice(s string, slice []string) bool

IsMatchedStringFromSlice checks whether to be matched string from slice or not.

func SetCommandLogger

func SetCommandLogger(logger *Logger)

SetCommandLogger is to set default command logger.

func SetDefaultGateway

func SetDefaultGateway(gw, tun string) error

SetDefaultGateway sets the systems gateway to the IP / device specified.

func SetDeleteDNS

func SetDeleteDNS() error

SetDeleteDNS sets google dns

func SetGoogleDNS

func SetGoogleDNS() error

SetGoogleDNS sets google dns

func SetPacketForward

func SetPacketForward(ok bool) error

SetPacketForward sets ip packet forward.

func SetPostRoutingMasquerade

func SetPostRoutingMasquerade(ok bool) error

SetPostRoutingMasquerade sets outbound packets masquerade.

func SetTunIP

func SetTunIP(tun string, localAddr net.IP, addr *net.IPNet) error

SetTunIP sets the local IP address of a network interface.

func SetTunStatus

func SetTunStatus(tun string, up bool) error

SetTunStatus is to up or down network device for TUN.

Types

type Logger

type Logger struct {
	*logrus.Logger
}

func NewLogger

func NewLogger(filePath string) (*Logger, error)

NewLogger is to return logrus logger.

func (*Logger) PanicWithError

func (l *Logger) PanicWithError(err error)

PanicWithMessage prints red message to stdout or file and then it raises a panic.

Jump to

Keyboard shortcuts

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