webtunnelcommon

package
v0.0.0-...-9606b86 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package webtunnelcommon package has common utils/structs for client/server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenMACAddr

func GenMACAddr() net.HardwareAddr

GenMACAddr generate a random private MAC address for GW server to handle ARP etc.

func GetIntCfg

func GetIntCfg(name string) (net.HardwareAddr, []net.IP, error)

GetIntCfg returns the hardware address and IPs for the interface.

func GetMacbyName

func GetMacbyName(name string) net.HardwareAddr

GetMacbyName returns the mac address of the interface by name. eg. eth0.

func IsConfigured

func IsConfigured(ifName string, ip string) bool

IsConfigured checks if interface ifName is configured with ip.

func PrintPacketEth

func PrintPacketEth(pkt []byte, tag string)

PrintPacketEth prints the Ethernet packet.

func PrintPacketIPv4

func PrintPacketIPv4(pkt []byte, tag string)

PrintPacketIPv4 prints the IPv4 packet.

Types

type ClientConfig

type ClientConfig struct {
	IP          string      `json:"ip"`          // IP address of client.
	Netmask     string      `json:"netmask"`     // Netmask of interface.
	RoutePrefix []string    `json:"routeprefix"` // Network prefix to route.
	GWIp        string      `json:"gwip"`        // Gateway IP address.
	DNS         []string    `json:"dns"`         // DNS IPs
	ServerInfo  *ServerInfo `json:"serverinfo"`  // Server Information for debug or troubleshooting
}

ClientConfig represents the struct to pass config from server to client.

type Interface

type Interface interface {
	io.ReadWriteCloser
	IsTUN() bool
	IsTAP() bool
	Name() string
}

Interface represents the network interface.

func NewWaterInterface

func NewWaterInterface(c water.Config) (Interface, error)

NewWaterInterface returns an initialized network interface.

type ServerInfo

type ServerInfo struct {
	Hostname string `json:"hostname"` // for now only provide gw hostname to client
	Session  string `json:"session"`  // session tracker from server
}

ServerInfo represents the struct provided to the client for debuging purpose

Jump to

Keyboard shortcuts

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