commons

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Commons between Bismuth Client and Server

This houses common internal libraries and constants between the bismuth client and server. For most of the time, you're probably going to want the connection handler, which is in conn.go.

Documentation

Index

Constants

View Source
const (
	// SendPublicKey: Sending public key back and forth
	SendPublicKey = iota
	// SwitchToSymmetricKey: Sent by the client along with the symmetric key that is going to be used
	SwitchToSymmetricKey
	// ClientSendHost: Currently unimplemented.
	// Client sends what host they are connecting to.
	ClientSendHost
	// GetSigningServers: Currently unimplemented.
	// Gets the signing servers trusting/signing the current server.
	GetSigningServers
	// GetTrustedDomains: Currently unimplemented.
	// Gets the domains that are supported by this certificate (should be cross-checked)
	GetTrustedDomains
	// InitiateForwarding: Starts forwarding traffic over this protocol.
	InitiateForwarding
)

Commands

View Source
const (
	BitLimit24 = 16_777_215
	BitLimit16 = 65535
)

Unsigned integer limits

View Source
const (
	// Default and only encryption algorithm
	XChaCha20Poly1305 = iota
)

Encryption algorithms

Variables

View Source
var ConnStandardMaxBufSize = 65535

Maximum size for a TCP packet

Functions

func Int24ToInt32

func Int24ToInt32(b []byte) uint32

Converts a 24 bit unsigned integer stored in a big-endian byte array to a 32 bit unsigned integer.

func Int32ToInt24

func Int32ToInt24(b []byte, int uint32)

Converts a 32 bit unsigned integer to a 24 bit unsigned integer in a byte array using big-endian ordering.

Types

type BismuthConn

type BismuthConn struct {
	Aead       cipher.AEAD
	PassedConn net.Conn

	// Maximum buffer size to be used to internally buffer packets
	MaxBufSize int
	// If true, it enables using the content buffer maximum size
	// instead of the TCP packet maximum size
	AllowNonstandardPacketSizeLimit bool
	// contains filtered or unexported fields
}

Connection used after both the Bismuth client and server negotiate and start transmitting data.

Note that using this has the same API as the net.Conn, but it isn't conformant to the interface due to using pointers rather than copies to access the struct.

If you need the same interface, wrap this in WrappedBismuthConn. Wrapping BismuthConn is done automatically by the client and server.

func (*BismuthConn) Close

func (bmConn *BismuthConn) Close() error

func (*BismuthConn) DoInitSteps

func (bmConn *BismuthConn) DoInitSteps()

func (*BismuthConn) LocalAddr

func (bmConn *BismuthConn) LocalAddr() net.Addr

func (*BismuthConn) Read

func (bmConn *BismuthConn) Read(b []byte) (n int, err error)

Reads from the Bismuth connection, using both the buffered and network methods

func (*BismuthConn) ReadFromBuffer

func (bmConn *BismuthConn) ReadFromBuffer(b []byte) (n int, err error)

Reads specifically from the buffer only. If nothing is in the buffer, nothing is returned.

func (*BismuthConn) ReadFromNetwork

func (bmConn *BismuthConn) ReadFromNetwork(b []byte) (n int, err error)

Reads specifically from the network. Be careful as using only this may overflow the buffer.

func (*BismuthConn) RemoteAddr

func (bmConn *BismuthConn) RemoteAddr() net.Addr

func (*BismuthConn) ResizeContentBuf

func (bmConn *BismuthConn) ResizeContentBuf() error

After you update the property `bmConn.MaxBufSize`, call this function to resize the content buffer

func (*BismuthConn) SetDeadline

func (bmConn *BismuthConn) SetDeadline(time time.Time) error

func (*BismuthConn) SetReadDeadline

func (bmConn *BismuthConn) SetReadDeadline(time time.Time) error

func (*BismuthConn) SetWriteDeadline

func (bmConn *BismuthConn) SetWriteDeadline(time time.Time) error

func (*BismuthConn) Write

func (bmConn *BismuthConn) Write(b []byte) (n int, err error)

Encrypts and sends off a message

type BismuthConnWrapped

type BismuthConnWrapped struct {
	Bismuth *BismuthConn
}

Wrapped BismuthConn struct. This is conformant to net.Conn, unlike above. To get the raw Bismuth struct, just get the Bismuth property:

`bmConn.Bismuth` -> `BismuthConn`

func (BismuthConnWrapped) Close

func (bmConn BismuthConnWrapped) Close() error

func (BismuthConnWrapped) LocalAddr

func (bmConn BismuthConnWrapped) LocalAddr() net.Addr

func (BismuthConnWrapped) Read

func (bmConn BismuthConnWrapped) Read(b []byte) (n int, err error)

func (BismuthConnWrapped) RemoteAddr

func (bmConn BismuthConnWrapped) RemoteAddr() net.Addr

func (BismuthConnWrapped) SetDeadline

func (bmConn BismuthConnWrapped) SetDeadline(time time.Time) error

func (BismuthConnWrapped) SetReadDeadline

func (bmConn BismuthConnWrapped) SetReadDeadline(time time.Time) error

func (BismuthConnWrapped) SetWriteDeadline

func (bmConn BismuthConnWrapped) SetWriteDeadline(time time.Time) error

func (BismuthConnWrapped) Write

func (bmConn BismuthConnWrapped) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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