gordafarid

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package gordafarid implements the Gordafarid protocol, a custom network protocol for secure communication.

Package gordafarid implements the Gordafarid protocol for secure communication.

Package gordafarid implements the Gordafarid protocol, a custom network protocol for secure communication.

Index

Constants

View Source
const (

	// HashSize defines the size of the hash used in the greeting header.
	// It is set to the size of SHA-256 hash, which is 32 bytes.
	HashSize = sha256.Size
)

Constants used in the Gordafarid protocol

View Source
const InitPasswordSize = 32

Variables

This section is empty.

Functions

func Dial

func Dial(addr string, dialAccountConfig *dialAccountConfig, dialConnConfig *dialConnConfig) (net.Conn, error)

Dial establishes a Gordafarid connection using the background context.

func DialContext

func DialContext(ctx context.Context, addr string, dialAccountConfig *dialAccountConfig, dialConnConfig *dialConnConfig) (net.Conn, error)

DialContext establishes a Gordafarid connection with the given context and configuration.

func NewDialAccountConfig

func NewDialAccountConfig(account Credential, initPassword, cryptoAlgorithm string) *dialAccountConfig

NewDialAccountConfig creates a new DialAccountConfig instance.

func NewDialConnConfig

func NewDialConnConfig(addr *protocol.AddressHeader) *dialConnConfig

NewDialConnConfig creates a new DialConnConfig instance.

func WrapTCP

func WrapTCP(conn net.Conn, dialAccountConfig *dialAccountConfig, dialConnConfig *dialConnConfig) (net.Conn, error)

WrapTCP wraps an existing TCP connection with Gordafarid protocol using the background context.

func WrapTCPContext

func WrapTCPContext(ctx context.Context, conn net.Conn, dialAccountConfig *dialAccountConfig, dialConnConfig *dialConnConfig) (net.Conn, error)

WrapTCPContext wraps an existing TCP connection with Gordafarid protocol using the given context.

Types

type Config

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

Config holds the internal connection's configuration.

type Conn

type Conn struct {
	net.Conn // Embedded net.Conn for underlying network operations
	// contains filtered or unexported fields
}

Conn represents a connection using the Gordafarid protocol. It wraps a standard net.Conn and adds protocol-specific functionality.

func (*Conn) GetHandshakeComplete

func (c *Conn) GetHandshakeComplete() bool

GetHandshakeComplete returns the current handshake completion status. It returns true if the handshake has been completed, false otherwise.

func (*Conn) GetHandshakeResult

func (c *Conn) GetHandshakeResult() (protocol.AddressHeader, error)

GetHandshakeResult returns the address header from the request after ensuring that the handshake is complete. This is useful for obtaining information about the client's requested destination.

func (*Conn) Handshake

func (c *Conn) Handshake() error

Handshake initiates the handshake process for the connection. It uses a background context and delegates to HandshakeContext.

func (*Conn) HandshakeContext

func (c *Conn) HandshakeContext(ctx context.Context) error

HandshakeContext performs the handshake process with a provided context. The context allows for cancellation and timeout control of the handshake operation.

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

Read reads data from the connection. It ensures that the handshake is complete before reading.

func (*Conn) SetHandshakeComplete

func (c *Conn) SetHandshakeComplete()

SetHandshakeComplete marks the handshake as complete for the connection. This method is used to indicate that the initial handshake process has finished successfully.

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

Write writes data to the connection. It ensures that the handshake is complete before writing.

type Credential

type Credential struct {
	Username string
	Password string
}

Credential represents a username and password pair for authentication.

func NewCredential

func NewCredential(username, password string) Credential

NewCredential creates a new Credential instance with the given username and password.

type Dialer

type Dialer struct {
	net.Dialer
	// contains filtered or unexported fields
}

Dialer represents a Gordafarid dialer for establishing connections.

func NewDialer

func NewDialer(accountConfig *dialAccountConfig, connConfig *dialConnConfig) *Dialer

NewDialer creates a new Gordafarid Dialer instance.

func (*Dialer) Dial

func (d *Dialer) Dial(dialConnConfig *dialConnConfig, addr string) (net.Conn, error)

Dial establishes a Gordafarid connection to the specified address.

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, dialConnConfig *dialConnConfig, addr string) (net.Conn, error)

DialContext establishes a Gordafarid connection to the specified address with the given context.

func (*Dialer) WrapTCP

func (d *Dialer) WrapTCP(dialConnConfig *dialConnConfig, conn net.Conn) (net.Conn, error)

WrapTCP wraps an existing TCP connection with Gordafarid protocol using the background context.

func (*Dialer) WrapTCPContext

func (d *Dialer) WrapTCPContext(ctx context.Context, dialConnConfig *dialConnConfig, conn net.Conn) (net.Conn, error)

WrapTCPContext wraps an existing TCP connection with Gordafarid protocol.

type Hash

type Hash [HashSize]byte

Hash represents a SHA-256 hash value.

type Listener

type Listener struct {
	net.Listener
	// contains filtered or unexported fields
}

Listener wraps a net.Listener with Gordafarid-specific functionality.

func Listen

func Listen(laddr string, config *ServerConfig) (*Listener, error)

Listen creates a new Gordafarid listener on the specified network address.

func NewListener

func NewListener(underlyingListener net.Listener, config *ServerConfig) *Listener

NewListener creates a new Gordafarid Listener wrapping the provided net.Listener.

func (*Listener) Accept

func (l *Listener) Accept() (*Conn, error)

Accept waits for and returns the next connection to the listener.

type ServerConfig

type ServerConfig struct {
	Credentials         []Credential // Server-side credentials for authentication
	EncryptionAlgorithm string       // Encryption algorithm to be used
	InitPassword        string       // Initial password for decrypting the client's initial greeting
	HandshakeTimeout    int          // Server handshake timeout in seconds
}

ServerConfig holds the configuration options for a Gordafarid server.

func NewServerConfig

func NewServerConfig(credentials []Credential, encryptionAlgorithm, initPassword string, handshakeTimeout int) *ServerConfig

NewServerConfig creates a new ServerConfig instance with the provided parameters.

Directories

Path Synopsis
The cipher_conn package provides encrypted connection using the AEAD cipher.
The cipher_conn package provides encrypted connection using the AEAD cipher.
crypto
aead
Package aead package provides AEAD cryptographic functionality for the Gordafarid project.
Package aead package provides AEAD cryptographic functionality for the Gordafarid project.
aes_gcm
Package aes_gcm provides encryption and decryption functions using AES-GCM.
Package aes_gcm provides encryption and decryption functions using AES-GCM.
Package nonce_cache provides a mechanism for managing nonce storage and checking for replay attacks.
Package nonce_cache provides a mechanism for managing nonce storage and checking for replay attacks.

Jump to

Keyboard shortcuts

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