socket

package module
v0.0.0-...-788cc7f Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 5 Imported by: 3

README

Wrap over Linux raw socket

High level implementation of raw linux socket with pure Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

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

func New

func New(opts ...InterfaceOption) (*Interface, error)

func (*Interface) CIDR

func (i *Interface) CIDR() string

CIDR returns cidr associated with this device

func (*Interface) Close

func (i *Interface) Close() error

func (*Interface) FD

func (i *Interface) FD() int

FD returns file descriptor of raw socket

func (*Interface) GetHardwareAddr

func (i *Interface) GetHardwareAddr() net.HardwareAddr

func (*Interface) Name

func (i *Interface) Name() string

Name returns name of device

func (*Interface) Read

func (i *Interface) Read(buf []byte) (int, error)

func (*Interface) Write

func (i *Interface) Write(buf []byte) (int, error)

type InterfaceOption

type InterfaceOption func(*Interface)

func WithCIDR

func WithCIDR(cidr string) InterfaceOption

Option for IP address with mask, `10.58.0.1/24` by default

func WithDefaultGateway

func WithDefaultGateway() InterfaceOption

Option for setting default gateway

func WithDevice

func WithDevice(dev string) InterfaceOption

Option for network device, `tap_netstack` by deafult

func WithTimeout

func WithTimeout(t time.Duration) InterfaceOption

Option to set timeout for read and write for interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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