Documentation
¶
Overview ¶
This file defines all Messages exchanged between router and proxy.
Index ¶
- Constants
- Variables
- func IfaceSetup(name string) *water.Interface
- func ToIP(address string) (net.IP, error)
- type Balancer
- type ChallengeMsg
- type ChallengeResponseMsg
- type Channel
- type ChannelIO
- type Chunk
- type Config
- type ConnManager
- func (cm *ConnManager) AllocChunk() *Chunk
- func (cm *ConnManager) Close()
- func (cm *ConnManager) Latencies() []time.Duration
- func (cm *ConnManager) Log(level int, format string, v ...any)
- func (cm *ConnManager) QueueAges() []int
- func (cm *ConnManager) ReceiveSpeeds() []float32
- func (cm *ConnManager) Receiver(iface io.ReadWriteCloser)
- func (cm *ConnManager) Sender(iface io.ReadWriteCloser)
- func (cm *ConnManager) Start() *ConnManager
- type Message
- type PingMsg
- type PongMsg
- type PrioBalancer
- type RelativeBalancer
- type SpeedMsg
- type SpeedTestMsg
- type Wrapped
Constants ¶
const ( HEARTBEAT = 20 * time.Second // 2 * time.Minute INACTIVE = 30 * time.Second //3 * time.Minute MIN_SPEED = 128 * 1024 / 8 // 128kbps SPEED_WINDOW = 500 * time.Millisecond )
const ( // AppVersion contains current application version for -version command flag AppVersion = "0.2.2" MIN_SEND_LIMIT = 2 * MTU DEBUG2 = 5 DEBUG = 4 INFO = 3 ERROR = 2 FATAL = 1 )
const ( MTU = 1500 // BSIZE is size of buffer to receive packets // (little bit bigger than maximum) BUFFERSIZE = MTU + 218 + 2 + 8 SOCKET_BUFFER = 1024 * 1024 )
const (
CONFFILE = "gobonding.yml"
)
Variables ¶
var Epoch = epoch
Functions ¶
func IfaceSetup ¶
ifaceSetup returns new interface OR PANIC!
Types ¶
type Balancer ¶
type Balancer interface {
// Returns the amount of byte to send through the channel
CalcSendLimit(chl *Channel, cm *ConnManager) int
}
Interface for different balancing strategies
type ChallengeMsg ¶
type ChallengeMsg struct {
Challenge string
}
Authentification challenge
func Challenge ¶
func Challenge() *ChallengeMsg
func ChallengeFromChunk ¶
func ChallengeFromChunk(chunk *Chunk, size int) *ChallengeMsg
func (*ChallengeMsg) Buffer ¶
func (m *ChallengeMsg) Buffer() []byte
func (*ChallengeMsg) CreateResponse ¶
func (m *ChallengeMsg) CreateResponse(privKey *rsa.PrivateKey) *ChallengeResponseMsg
func (*ChallengeMsg) String ¶
func (msg *ChallengeMsg) String() string
type ChallengeResponseMsg ¶
type ChallengeResponseMsg struct {
Response string
}
Authentification Response
func (*ChallengeResponseMsg) Buffer ¶
func (m *ChallengeResponseMsg) Buffer() []byte
func (*ChallengeResponseMsg) String ¶
func (msg *ChallengeResponseMsg) String() string
type Channel ¶
type Channel struct {
Id uint16
// interface to the socket
Io ChannelIO
// time between two received packets
Latency time.Duration
// for proxy: If true channel is authenticated
Authenticated bool
ReceiveSpeed float32 // bytes per second
SendSpeed float32
// contains filtered or unexported fields
}
Represents an UDP connection to the peer.
func NewChannel ¶
func NewChannel(cm *ConnManager, id uint16, io ChannelIO, isProxy bool) *Channel
type Chunk ¶
type Chunk struct {
Data [BUFFERSIZE]byte
Size uint16
Age Wrapped
}
A tunneled IP package
type Config ¶
type Config struct {
// Name of the TUN adapter
TunName string
// If not empty the path to a monitor file
MonitorPath string
// The Tick interval to update the monitor file
MonitorTick string
// The name of the channel balancer
Balancer string
// The start Port the proxy is listening to
ProxyStartPort int
// A map ifacename or ipaddress of the wan device to ip address of proxy server
Channels map[string]string
// Public Key for authentication
PublicKey string
// Private key for authentication
PrivateKey string `yaml:",omitempty"`
}
func LoadConfig ¶
type ConnManager ¶
type ConnManager struct {
Channels []*Channel
Config *Config
Balancer Balancer
ChunksToWrite chan *Chunk
Logger func(level int, format string, v ...any)
// contains filtered or unexported fields
}
ConnManager is responsible for tunneling and distributing the IP packets through multiple UDP channels.
func NewConnManager ¶
func NewConnManager(ctx context.Context, config *Config) *ConnManager
func (*ConnManager) AllocChunk ¶
func (cm *ConnManager) AllocChunk() *Chunk
func (*ConnManager) Close ¶
func (cm *ConnManager) Close()
func (*ConnManager) Latencies ¶
func (cm *ConnManager) Latencies() []time.Duration
func (*ConnManager) QueueAges ¶
func (cm *ConnManager) QueueAges() []int
func (*ConnManager) ReceiveSpeeds ¶
func (cm *ConnManager) ReceiveSpeeds() []float32
func (*ConnManager) Receiver ¶
func (cm *ConnManager) Receiver(iface io.ReadWriteCloser)
A go routine that received IP Packets from channels, sort them and write to tunnel interface.
func (*ConnManager) Sender ¶
func (cm *ConnManager) Sender(iface io.ReadWriteCloser)
A go routine that reads IP Packets from tunnel interface and distributes them to channels via a weighted round robin strategie.
func (*ConnManager) Start ¶
func (cm *ConnManager) Start() *ConnManager
type PrioBalancer ¶
type PrioBalancer struct{}
The fastest channel gets 90% of the IP packets all other 10%
func (*PrioBalancer) CalcSendLimit ¶
func (b *PrioBalancer) CalcSendLimit(chl *Channel, cm *ConnManager) int
type RelativeBalancer ¶
type RelativeBalancer struct{}
Distributes the IP packets according to the last measured channel speeds.
func (*RelativeBalancer) CalcSendLimit ¶
func (b *RelativeBalancer) CalcSendLimit(chl *Channel, cm *ConnManager) int
type SpeedMsg ¶
type SpeedMsg struct {
Speed float32
}
Sends the receiving speed in bytes/sec to the peer.
func SpeedFromChunk ¶
type SpeedTestMsg ¶
type SpeedTestMsg struct {
// the age of the last Chunk package of this speed test
Age Wrapped
// the local start time
Timestamp time.Duration
// the transferred bytes
Size uint32
}
Sends data to the peer for measuring the receiving speed.
func SpeedTestFromChunk ¶
func SpeedTestFromChunk(chunk *Chunk) *SpeedTestMsg
func (*SpeedTestMsg) Buffer ¶
func (m *SpeedTestMsg) Buffer() []byte
func (*SpeedTestMsg) String ¶
func (msg *SpeedTestMsg) String() string

