core

package
v0.0.0-...-38ee43f Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debugf

func Debugf(format string, args ...interface{})

func Debugln

func Debugln(args ...interface{})

Types

type AboutInfo

type AboutInfo struct {
	Version string `json:"version"`
}

type Config

type Config struct {
	DoLogs    bool
	ReadSaved bool
}
var DefaultConfig Config = Config{
	DoLogs:    false,
	ReadSaved: true,
}

type ConnLogger

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

func NewConnLogger

func NewConnLogger(source string, dest string) *ConnLogger

log file at ~/.gopolar/logs/

func (*ConnLogger) LogRecv

func (cl *ConnLogger) LogRecv(b []byte)

func (*ConnLogger) LogSend

func (cl *ConnLogger) LogSend(b []byte)

type CreateTunnelBody

type CreateTunnelBody struct {
	Name   string `json:"name"`
	Source string `json:"source"`
	Dest   string `json:"dest"`
}

type EditTunnelBody

type EditTunnelBody struct {
	NewName   string `json:"name"`
	NewSource string `json:"source"`
	NewDest   string `json:"dest"`
}

type Forwarder

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

forward one source to one or multiple dest

func NewForwarder

func NewForwarder(source netip.AddrPort) (*Forwarder, error)

func (*Forwarder) Add

func (fwd *Forwarder) Add(d string)

add a dest(e.g. 198.51.100.1:80) for this forwarder

func (*Forwarder) Remove

func (fwd *Forwarder) Remove(d string) bool

stop forwarding to a dest, does nothing if not found, return true if no dest remains after the operation, in which case the forwarder should be deleted

type Tunnel

type Tunnel struct {
	ID     uint64 `json:"id"`
	Name   string `json:"name"`
	Enable bool   `json:"enable"`
	Source string `json:"source"` // e.g. localhost:xxxx
	Dest   string `json:"dest"`   // e.g. 192.168.1.0:7878, localhost:7878
}

func (Tunnel) MustParseDest

func (t Tunnel) MustParseDest() netip.AddrPort

func (Tunnel) MustParseSource

func (t Tunnel) MustParseSource() netip.AddrPort

func (Tunnel) ParseDest

func (t Tunnel) ParseDest() (netip.AddrPort, error)

func (Tunnel) ParseSource

func (t Tunnel) ParseSource() (netip.AddrPort, error)

func (Tunnel) String

func (t Tunnel) String() string

type TunnelManager

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

func NewTunnelManager

func NewTunnelManager(cfg Config) *TunnelManager

init tunnels from config file, exit if any error occurs

func (*TunnelManager) AddTunnel

func (tm *TunnelManager) AddTunnel(nt Tunnel) (uint64, error)

returns error if tunnel already exists

func (*TunnelManager) ChangeTunnel

func (tm *TunnelManager) ChangeTunnel(id uint64, newName string, newSource string, newDest string) error

returns error if tunnel with id does not exist

func (*TunnelManager) GetTunnels

func (tm *TunnelManager) GetTunnels() []Tunnel

always return a list sorted by tunnel ID, never errors

func (*TunnelManager) RemoveTunnel

func (tm *TunnelManager) RemoveTunnel(id uint64) error

returns error if tunnel with id does not exist

func (*TunnelManager) Run

func (tm *TunnelManager) Run()

func (*TunnelManager) ToggleTunnel

func (tm *TunnelManager) ToggleTunnel(id uint64) error

returns error if tunnel with id does not exist

Jump to

Keyboard shortcuts

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