openwrt

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Overview

Package openwrt provides utilities for accessing and controlling Router routers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HostIsOpenWrtRouter

func HostIsOpenWrtRouter(ctx context.Context, host *ssh.Conn) (bool, error)

HostIsOpenWrtRouter determines whether the remote host is an OpenWrt router.

Types

type Router

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

Router controls an OpenWrt router and stores the router state.

func NewRouter

func NewRouter(ctx, daemonCtx context.Context, host *ssh.Conn, name string) (*Router, error)

NewRouter prepares initial test AP state (e.g., initializing wiphy/wdev). ctx is the deadline for the step and daemonCtx is the lifetime for background daemons.

func (*Router) Close

func (r *Router) Close(ctx context.Context) error

Close cleans the resource used by Router.

func (*Router) CollectLogs

func (r *Router) CollectLogs(ctx context.Context) error

CollectLogs downloads log files from router to OutDir.

func (*Router) ReconfigureHostapd

func (r *Router) ReconfigureHostapd(ctx context.Context, hs *hostapd.Server, conf *hostapd.Config) (*hostapd.Server, error)

ReconfigureHostapd restarts the hostapd server with the new config. It preserves the interface and the name of the old hostapd server.

func (*Router) ReserveForStopCapture

func (r *Router) ReserveForStopCapture(ctx context.Context, capturer *pcap.Capturer) (context.Context, context.CancelFunc)

ReserveForStopCapture returns a shortened ctx with cancel function.

func (*Router) ReserveForStopRawCapturer

func (r *Router) ReserveForStopRawCapturer(ctx context.Context, capturer *pcap.Capturer) (context.Context, context.CancelFunc)

ReserveForStopRawCapturer returns a shortened ctx with cancel function. The shortened ctx is used for running things before r.StopRawCapture to reserve time for it.

func (*Router) RouterName

func (r *Router) RouterName() string

RouterName returns the name of the managed router device.

func (*Router) RouterType

func (r *Router) RouterType() support.RouterType

RouterType returns the router type.

func (*Router) StartCapture

func (r *Router) StartCapture(ctx context.Context, name string, ch int, freqOps []iw.SetFreqOption, pcapOps ...pcap.Option) (_ *pcap.Capturer, retErr error)

StartCapture starts a packet capturer.

func (*Router) StartDHCP

func (r *Router) StartDHCP(ctx context.Context, name, iface string, ipStart, ipEnd, serverIP, broadcastIP net.IP, mask net.IPMask) (_ *dhcp.Server, retErr error)

StartDHCP starts the DHCP server and configures the server IP.

func (*Router) StartHostapd

func (r *Router) StartHostapd(ctx context.Context, name string, conf *hostapd.Config) (*hostapd.Server, error)

StartHostapd starts the hostapd server.

func (*Router) StartRawCapturer

func (r *Router) StartRawCapturer(ctx context.Context, name, iface string, ops ...pcap.Option) (*pcap.Capturer, error)

StartRawCapturer starts a capturer on an existing interface on the router instead of a monitor type interface.

func (*Router) StopCapture

func (r *Router) StopCapture(ctx context.Context, capturer *pcap.Capturer) error

StopCapture stops the packet capturer and releases related resources.

func (*Router) StopDHCP

func (r *Router) StopDHCP(ctx context.Context, ds *dhcp.Server) error

StopDHCP stops the DHCP server and flushes the interface.

func (*Router) StopHostapd

func (r *Router) StopHostapd(ctx context.Context, hs *hostapd.Server) error

StopHostapd stops the hostapd server.

func (*Router) StopRawCapturer

func (r *Router) StopRawCapturer(ctx context.Context, capturer *pcap.Capturer) (retErr error)

StopRawCapturer stops the packet capturer (no extra resources to release).

Directories

Path Synopsis
Package uci contains utility functions to wrap around the uci program.
Package uci contains utility functions to wrap around the uci program.

Jump to

Keyboard shortcuts

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