Documentation ¶
Overview ¶
Package parlnet provides IP-related functions with few dependencies beyond the net package
Index ¶
- Constants
- func CheckRedirect(req *http.Request, via []*http.Request) (err error)
- func Get(requestURL string, tlsConfig *tls.Config, ctx context.Context) (resp *http.Response, err error)
- func IPAddr(IP net.IP, index IfIndex, zone string) (ipa *net.IPAddr, err error)
- func IPNetString(ipNet net.IPNet) (s string)
- func InvertMask(IPMask net.IPMask) (out net.IPMask)
- func IsBroadcast(IP net.IP, IPMask net.IPMask) (isBroadcast bool)
- func IsDirect(IP net.IP, mask *net.IPMask) bool
- func IsDirectIPNet(IPNet *net.IPNet) bool
- func IsIPv4(ip net.IP) (isIPv4 bool)
- func IsIPv6(ip net.IP) (isIPv6 bool)
- func IsNetwork(IP net.IP, IPMask net.IPMask) (isNetwork bool)
- func IsNzIP(ip net.IP) bool
- func IsZeros(p net.IP) bool
- func NewTLSConfig(cert *x509.Certificate) (tlsConfig *tls.Config)
- func NewTransport(tlsConfig *tls.Config) (httpTransport *http.Transport)
- type Callback
- type Destination
- type HandlerFunc
- type Http
- func (hp *Http) CloseErr()
- func (hp *Http) HandleFunc(pattern string, handler HandlerFunc)
- func (hp *Http) Listen() (errCh <-chan error)
- func (hp *Http) Listener() (listener net.Listener, err error)
- func (hp *Http) SendErr(err error)
- func (hp *Http) Shutdown()
- func (hp *Http) SubListen() (errCh <-chan error)
- func (hp *Http) WaitForUp() (isUp bool, addr net.Addr)
- type HttpClient
- type Https
- type IfIndex
- type LinkAddr
- type Message
- type NextHop
- type Route
- type Socket
- type Tcp
- type UDP
- type UDPFunc
Constants ¶
const ( // DefaultRouteIPv4 is the default route 0/0 for IPv4 DefaultRouteIPv4 = "0.0.0.0/0" // VPNRoute0IPv4 is overriding VPN route 0/1 for IPv4 VPNRoute0IPv4 = "0.0.0.0/1" // VPNRoute128IPv4 is overriding VPN route 128/1 for IPv4 VPNRoute128IPv4 = "128.0.0.0/1" // DefaultRouteIPv6 is the default route ::/0 for IPv6 DefaultRouteIPv6 = "::/0" // VPNRouteIPv6 is overriding VPN route ::/3 for IPv6 VPNRouteIPv6 = "::/3" )
const (
TCPNetwork = "tcp"
)
Variables ¶
This section is empty.
Functions ¶
func InvertMask ¶
InvertMask inverts the bits of a mask the mask for 1.2.3.4/24 is normally ffffff00 or []byte{255, 255, 255, 0}
func IsBroadcast ¶
IsBroadcast determines IP is the last address for Mask for 1.2.3.4/24 the network address 1.2.3.255 returns true
func IsDirectIPNet ¶
IsDirectIPNet determines if the IPNET represents a direct route
func IsNetwork ¶
IsNetwork determines if IP is the network address (all zeros) for this Mask for 1.2.3.4/24 the network address 1.2.3.0 returns true
func NewTLSConfig ¶
func NewTLSConfig(cert *x509.Certificate) (tlsConfig *tls.Config)
Types ¶
type Callback ¶
type Callback func(msg Message)
Callback allows for processing of routing message,eg. populating a map
type Destination ¶
Destination contains IP, Zone and Mask
func NewDestination ¶
func NewDestination(IPAddr *net.IPAddr, IPMask *net.IPMask) (d *Destination)
NewDestination instantiates Destination
func (Destination) Key ¶
func (d Destination) Key() string
Key is a string suitable as a key in a map
func (Destination) String ¶
func (d Destination) String() (s string)
type HandlerFunc ¶
type HandlerFunc func(http.ResponseWriter, *http.Request)
type Http ¶
type Http struct { Network string // "tcp", "tcp4", "tcp6", "unix" or "unixpacket" http.Server ListenInvoked parl.AtomicBool ReadyWg sync.WaitGroup ErrCh chan<- error ErrChMutex sync.Mutex ErrChClosed parl.AtomicBool net.Addr // interface IsListening parl.AtomicBool IsShutdown parl.AtomicBool }
func (*Http) HandleFunc ¶
func (hp *Http) HandleFunc(pattern string, handler HandlerFunc)
type HttpClient ¶
func NewHttpClient ¶
func NewHttpClient(tlsConfig *tls.Config) (httpClient *HttpClient)
type Https ¶
type Https struct { Http Cert parlca.CertificateDER Private crypto.Signer }
type IfIndex ¶
type IfIndex int
IfIndex is a dynamic reference to a network interface on Linux systems
type LinkAddr ¶
type LinkAddr struct { Index IfIndex // 0 is none Name string // "" none Hw net.HardwareAddr // []byte }
LinkAddr contains an Ethernet mac address, its interface name and interface index
func NewLinkAddr2 ¶
func NewLinkAddr2(index IfIndex, name string, hw net.HardwareAddr) *LinkAddr
NewLinkAddr2 instantiates LinkAddr
func (*LinkAddr) UpdateName ¶
UpdateName attempts to populate interface name if not already present
type NextHop ¶
type NextHop struct { /* if NextHop is an address on the local host or on a local subnet, Gateway is nil LinkAddr describes the local interface Src is the address on that local interface If Nexthop is remote, beyond any local subnet, Gateway is an IP on a local subnet LinkAddr describes the local interface for that subnet Src is the address on that local interface */ Gateway net.IPAddr LinkAddr Src net.IPAddr // the source ip to use on LinkAddr }
NextHop describes a route target
func NewNextHop ¶
NewNextHop assembles a route destination
func NewNextHop2 ¶
NewNextHop2 assembles a route destination based on IfIndex
func (*NextHop) HasGateway ¶
HasGateway determines if next hop uses a remote gateway
type Route ¶
type Route struct { Destination NextHop }
Route describes a routing table route with destination and next hop
type Socket ¶
type Socket struct { *net.TCPListener // contains filtered or unexported fields }
Socket embeds net.TCPListener
func ListenTCP4 ¶
ListenTCP4 listens on local network interfaces with ipv4 tcp socket: ":8080" or "1.2.3.4:80"
func (*Socket) RunHandler ¶
RunHandler handles inbound connections
type UDP ¶
type UDP struct { Network string F UDPFunc MaxSize int net.UDPAddr // struct IP Port Zone ListenInvoked parl.AtomicBool StartingListen sync.WaitGroup ErrCh chan<- error IsListening parl.AtomicBool NetUDPConn *net.UDPConn Addr net.Addr IsShutdown parl.AtomicBool // contains filtered or unexported fields }