Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyBPF(rawConn *ipv4.RawConn, server *Server, client *Peer)
- func GetClientIP(dstIP net.IP) net.IP
- func Handshake(conn *ipv4.RawConn, privkey Key, server *Server, client *Peer) (sendCipher, recvCipher *auth.CipherState, index uint32, err error)
- func HostToAddr(hostStr string) *net.IPAddr
- func MakePacket(payload []byte, server *Server, client *Peer) []byte
- func ParseResponse(response []byte) (net.IP, uint16)
- func RecvDataPacket(cipher *auth.CipherState, conn *ipv4.RawConn, server *Server, client *Peer) (body, header []byte, packetType byte, n int, err error)
- func RecvPacket(conn *ipv4.RawConn, server *Server, client *Peer) ([]byte, int, error)
- func SendDataPacket(cipher *auth.CipherState, index uint32, data []byte, conn *ipv4.RawConn, ...) error
- func SendPacket(packet []byte, conn *ipv4.RawConn, server *Server, client *Peer) error
- func SetupRawConn(server *Server, client *Peer) *ipv4.RawConn
- type Key
- type Peer
- type Server
Constants ¶
View Source
const ( // EmptyUDPSize is the size of an empty UDP packet EmptyUDPSize = 28 // PacketHandshakeInit identifies handhshake initiation packets PacketHandshakeInit byte = 1 // PacketHandshakeResp identifies handhshake response packets PacketHandshakeResp byte = 2 // PacketData identifies regular data packets PacketData byte = 3 )
Variables ¶
View Source
var ( // ErrPacketType is returned when an unexepcted packet type is enountered ErrPacketType = errors.New("client/network: incorrect packet type") // ErrNonce is returned when the nonce on a packet isn't valid ErrNonce = errors.New("client/network: invalid nonce") // RekeyDuration is the time after which keys are invalid and a new handshake is required. RekeyDuration = 5 * time.Minute )
Functions ¶
func GetClientIP ¶
GetClientIP gets source ip address that will be used when sending data to dstIP
func Handshake ¶
func Handshake(conn *ipv4.RawConn, privkey Key, server *Server, client *Peer) (sendCipher, recvCipher *auth.CipherState, index uint32, err error)
Handshake performs a Noise-IK handshake with the Server
func HostToAddr ¶
HostToAddr resolves a hostname, whether DNS or IP to a valid net.IPAddr
func MakePacket ¶
MakePacket constructs a request packet to send to the server
func ParseResponse ¶
ParseResponse takes a response packet and parses it into an IP and port. There's no error checking, we assume that data passed in is valid
func RecvDataPacket ¶
func RecvDataPacket(cipher *auth.CipherState, conn *ipv4.RawConn, server *Server, client *Peer) (body, header []byte, packetType byte, n int, err error)
RecvDataPacket recieves a UDP packet from server
func RecvPacket ¶
RecvPacket recieves a UDP packet from server
func SendDataPacket ¶
func SendDataPacket(cipher *auth.CipherState, index uint32, data []byte, conn *ipv4.RawConn, server *Server, client *Peer) error
SendDataPacket encrypts and sends packet to the Server
func SendPacket ¶
SendPacket sends packet to the Server
Types ¶
Click to show internal directories.
Click to hide internal directories.