Documentation ¶
Overview ¶
Package internal contains the TCP/UDP connection, setups TUN/TAP Device, handles DNS packets.
Index ¶
- Variables
- func CalcChecksum(sum uint) []byte
- func CreateUDPConnection(peerUDPport int) (*net.UDPConn, error)
- func RecvEtherPacket(fd int, b []byte) error
- func RecvIPv4RawSocket(sip string) (int, error)
- func SendEtherPacket(fd int, b []byte) error
- func SendIPv4RawSocket(dip string) (int, error)
- func SendPacket4(fd int, b []byte, dip []byte) error
- func SumbyteArr(arr []byte) uint
- func ToPacket(value interface{}) []byte
- func UintTo2byte(data uint16) []byte
- func UintTo3byte(data uint32) []byte
- func UintTo4byte(data uint32) []byte
- type Device
- func (device *Device) Close()
- func (device *Device) CreateDescriptor()
- func (device *Device) CreateTunInterface()
- func (device *Device) NewPeer()
- func (device *Device) ReadIPv4Packet(b []byte)
- func (device *Device) ReadIPv6Packet(b []byte)
- func (device *Device) RoutineSequentialReceiver()
- func (device *Device) RoutineSequentialSender()
- type Peer
- type TunInterface
Constants ¶
This section is empty.
Variables ¶
var VIPv4NetworkAddress string = "198.18.0.0/16"
rfc3330, rfc2544. Using the Documentation addresses and prefixes.
var VIPv6NetworkAddress string = "2001:0db8:c0ff:ee00::/64"
Functions ¶
func CalcChecksum ¶
func CreateUDPConnection ¶
CreateUDPConnection creates a UDP connection with the peer node.
func RecvEtherPacket ¶
RecvEtherPacket uses a receive socket to receive an ether packet.
func RecvIPv4RawSocket ¶
RecvIPv4RawSocket creates a raw socket for receiving IPv4 packet.
func SendEtherPacket ¶
SendEtherPacket uses a send socket to send an ether packet.
func SendIPv4RawSocket ¶
SendIPv4RawSocket creates a raw socket for sending IPv4 packet.
func SendPacket4 ¶
SendPacket4 sends IPv4 packet.
func SumbyteArr ¶
func UintTo2byte ¶
func UintTo3byte ¶
func UintTo4byte ¶
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 (*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) ReadIPv6Packet ¶
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 TunInterface ¶
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.