network

package
v0.0.0-...-6125e6c Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Copyright (c) 2025, Ben Walton All rights reserved.

Copyright (c) 2025, Ben Walton All rights reserved.

Index

Constants

View Source
const (
	KEY_BYTES = 16
	MTU       = 1280
)
View Source
const (
	CLIENT = iota
	SERVER = 1 << 7
)
View Source
const (
	NONCE_BYTES = 12
	// With GCM, we can safely use 64-bits of a counter because
	// there is no chance of a collision. We're sending messages
	// in both directions here, so give a very ample 2^62 messages
	// per side. Client and server always distinguish themselves
	// by adding a 0 or a 1 to the nonce value so even as they
	// re-use this counter int, the actual nonce will always be
	// distinct and thus still safe.
	MAX_NONCE_VAL = 1 << 62
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GConn

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

func NewClient

func NewClient(addr, key string) (*GConn, error)

func NewServer

func NewServer(ip, prng string) (*GConn, error)

NewServer takes an ip to listen on and port range "n:m" and returns a GConn object listening to a port in that range or an error if it can't listen.

func (*GConn) Base64Key

func (gc *GConn) Base64Key() string

func (*GConn) Close

func (gc *GConn) Close() error

func (*GConn) LocalPort

func (gc *GConn) LocalPort() int

func (*GConn) Read

func (gc *GConn) Read(extbuf []byte) (int, error)

func (*GConn) RemoteAddr

func (gc *GConn) RemoteAddr() string

func (*GConn) Write

func (gc *GConn) Write(msg []byte) (int, error)

Jump to

Keyboard shortcuts

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