internal

package
v0.0.0-...-96e3f98 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package internal contains the TCP/UDP connection, setups TUN/TAP Device, handles DNS packets.

Index

Constants

This section is empty.

Variables

View Source
var VIPv4NetworkAddress string = "198.18.0.0/16"

rfc3330, rfc2544. Using the Documentation addresses and prefixes.

View Source
var VIPv6NetworkAddress string = "2001:0db8:c0ff:ee00::/64"

Functions

func CalcChecksum

func CalcChecksum(sum uint) []byte

func CreateUDPConnection

func CreateUDPConnection(peerUDPport int) (*net.UDPConn, error)

CreateUDPConnection creates a UDP connection with the peer node.

func RecvEtherPacket

func RecvEtherPacket(fd int, b []byte) error

RecvEtherPacket uses a receive socket to receive an ether packet.

func RecvIPv4RawSocket

func RecvIPv4RawSocket(sip string) (int, error)

RecvIPv4RawSocket creates a raw socket for receiving IPv4 packet.

func SendEtherPacket

func SendEtherPacket(fd int, b []byte) error

SendEtherPacket uses a send socket to send an ether packet.

func SendIPv4RawSocket

func SendIPv4RawSocket(dip string) (int, error)

SendIPv4RawSocket creates a raw socket for sending IPv4 packet.

func SendPacket4

func SendPacket4(fd int, b []byte, dip []byte) error

SendPacket4 sends IPv4 packet.

func SumbyteArr

func SumbyteArr(arr []byte) uint

func ToPacket

func ToPacket(value interface{}) []byte

func UintTo2byte

func UintTo2byte(data uint16) []byte

func UintTo3byte

func UintTo3byte(data uint32) []byte

func UintTo4byte

func UintTo4byte(data uint32) []byte

Types

type Device

type Device struct {
	EnvIPver int

	// Real Interface
	IfIndex      *net.Interface
	LocalIPv4    net.IP
	LocalIPv6    net.IP
	LocalUDPPort uint16

	// TUN/TAP Interface
	Tun struct {
		Device *TunInterface
		VIP    string
		// contains filtered or unexported fields
	}

	// Stores destination information for Chorus applications
	Chorus struct {
		PeerIP   net.IP
		PeerPort int
	}

	Peer *Peer
	// contains filtered or unexported fields
}

func NewDevice

func NewDevice(intf string) (device *Device)

NewDevice defines device information.

func (*Device) Close

func (device *Device) Close()

Close closes device's queue, workers.

func (*Device) CreateDescriptor

func (device *Device) CreateDescriptor()

CreateDescriptor creates socket descriptor.

func (*Device) CreateTunInterface

func (device *Device) CreateTunInterface()

CreateTunInterface creates a TUN/TAP interface.

func (*Device) NewPeer

func (device *Device) NewPeer()

NewPeer creates peer network information and UDP connections.

func (*Device) ReadIPv4Packet

func (device *Device) ReadIPv4Packet(b []byte)

func (*Device) ReadIPv6Packet

func (device *Device) ReadIPv6Packet(b []byte)

func (*Device) RoutineSequentialReceiver

func (device *Device) RoutineSequentialReceiver()

RoutineSequentialReceiver forwards the peer's packets obtained from the real interface to the virtual interface.

func (*Device) RoutineSequentialSender

func (device *Device) RoutineSequentialSender()

RoutineSequentialSender sends packets obtained from a virtual interface to the peer.

type Peer

type Peer struct {
	// Network information
	PeerEndPoint net.UDPAddr

	// UDP connection
	ConnUDP *net.UDPConn
}

type TunInterface

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

TunInterface manages Tunnel device.

func NewTunInterface

func NewTunInterface(name string, address string, prefix string) (*TunInterface, error)

NewTunInterface returns Tunnel device.

func (*TunInterface) Close

func (iface *TunInterface) Close()

Close function closes the virtual interface.

func (*TunInterface) Read

func (iface *TunInterface) Read(buf []byte) (int, error)

Read function read the virtual interface.

func (*TunInterface) Up

func (iface *TunInterface) Up() error

Up function ups a virtual interface.

func (*TunInterface) Write

func (iface *TunInterface) Write(buf []byte) (int, error)

Write function write the virtual interface.

Directories

Path Synopsis
Package logger contains logging tools.
Package logger contains logging tools.

Jump to

Keyboard shortcuts

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