network

package
v0.0.0-...-d2bd7e9 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAPConfig       = errors.New("invalid wireless wireless access point")
	ErrServiceAlreadyRunning = errors.New("hotspot service is already running")
)
View Source
var ErrAllAccessPointsInUse = errors.New("all wireless access points are currently in use")
View Source
var ErrConnectionFailed = errors.New("failed to connect to network")
View Source
var ErrNetworkNotFound = errors.New("specified network not found")
View Source
var ErrNoAccessPointFound = errors.New("no wireless access point found")

Functions

This section is empty.

Types

type APConfig

type APConfig struct {
	Name        string
	Interface   string `yaml:"interface" json:"interface"`
	SSID        string `yaml:"ssid" json:"ssid"`
	Password    string `yaml:"password" json:"password"`
	CountryCode string `yaml:"country_code" json:"countryCode"`
	Security    string `yaml:"security" json:"security"` // "open", "wpa2"
	Gateway     string `yaml:"gateway" json:"gateway"`
	DHCPRange   string `yaml:"dhcp_range" json:"dhcpRange"`
	PortalPort  string `yaml:"portal_port" json:"portalPort"`
}

APConfig represents the configuration for a wireless access point

func (APConfig) Validate

func (c APConfig) Validate() error

type APService

type APService interface {
	Start(ctx context.Context, config APConfig) error
	Stop(ctx context.Context) error
	IsRunning() bool
}

func NewAPService

func NewAPService() APService

type FireWallDirection

type FireWallDirection int
const (
	INCOMING FireWallDirection = iota
	OUTGOING
	BOTH
)

func (FireWallDirection) String

func (d FireWallDirection) String() string

type FireWallProtocol

type FireWallProtocol int
const (
	TCP FireWallProtocol = iota
	UDP
	ANY
)

func (FireWallProtocol) ToString

func (p FireWallProtocol) ToString() string

type FireWallRule

type FireWallRule struct {
	Direction FireWallDirection
	Interface string
	Port      string
	Protocol  FireWallProtocol
}

func GetRequiredFirewallRules

func GetRequiredFirewallRules(iFace string, portalPort string) []FireWallRule

func (FireWallRule) Apply

func (p FireWallRule) Apply(iFace string) error

func (FireWallRule) ToArgs

func (p FireWallRule) ToArgs(iFace string) []string

type IPTablesRule

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

func CleanupIPTablesRules

func CleanupIPTablesRules(iFace, portalPort string) []IPTablesRule

func CreateIPTablesRules

func CreateIPTablesRules(iFace, portalPort string) []IPTablesRule

func NewIPTablesRule

func NewIPTablesRule(args ...string) IPTablesRule

func (IPTablesRule) Apply

func (r IPTablesRule) Apply() error

type InterfaceManager

type InterfaceManager interface {
	ListWirelessInterfaces() ([]WirelessInterface, error)
	GetBestAPInterface() (*WirelessInterface, error)
	ListAvailableNetworks(interfaceName string) ([]WirelessNetwork, error)
	ConnectToNetwork(interfaceName, ssid, password string) error
}

func NewInterfaceManager

func NewInterfaceManager() InterfaceManager

NewInterfaceManager creates a new instance of InterfaceManager

type WirelessInterface

type WirelessInterface struct {
	Name       string `json:"name"`
	SupportAP  bool   `json:"support_ap"`
	InUse      bool   `json:"in_use"`
	MACAddress string `json:"mac_address"`
}

type WirelessNetwork

type WirelessNetwork struct {
	SSID        string `json:"ssid"`
	DisplayName string `json:"display_name"` // Human-readable name (same as SSID for now)
	BSSID       string `json:"bssid"`
	Signal      int    `json:"signal"`
	Security    string `json:"security"`
	Frequency   string `json:"frequency"`
	Channel     string `json:"channel"`
}

Jump to

Keyboard shortcuts

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