network

package
v1.0.138 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 0 Imported by: 0

README

Gravity Network Interface

This package defines the minimal network interface required by the gravity client for network device operations.

Concrete implementations should be provided by consuming applications.

Interface

The NetworkInterface provides methods for:

  • Reading packets from the network device
  • Writing packets to the network device
  • Managing the network interface lifecycle

Usage

Implement this interface in your application:

type MyNetworkInterface struct {
    // your fields
}

func (t *MyNetworkInterface) Read() ([]byte, error) {
    // your implementation
}

func (t *MyNetworkInterface) Write(packet []byte) error {
    // your implementation
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NetworkInterface

type NetworkInterface interface {
	// RouteTraffic configures routing for the specified network ranges
	RouteTraffic(nets []string) error

	// UnrouteTraffic removes all routing configurations
	UnrouteTraffic() error

	// Read reads a packet from the network interface into the provided buffer
	Read(buffer []byte) (int, error)

	// Write writes a packet to the network interface
	Write(packet []byte) (int, error)

	// Running returns true if the network interface is currently running
	Running() bool

	// Start starts the network interface and calls the handler with each outbound packet.
	// The packet passed to the handler is NOT a copy, so it must be copied if used after the handler returns.
	Start(handler func(packet []byte))
}

NetworkInterface defines the minimal interface required by the gravity client for network operations. Concrete implementations should be provided by consuming applications.

Jump to

Keyboard shortcuts

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