hubnet

package
v0.0.0-...-2920ad6 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package hubnet with functions to get the outbound network interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBearerToken

func GetBearerToken(req *http.Request) (string, error)

GetBearerToken returns the bearer token from the HTTP request authorization header Returns an error if no token present or token isn't a bearer token

func GetInterfaces

func GetInterfaces(address string) ([]net.Interface, error)

GetInterfaces returns a list of active network interfaces excluding the loopback interface

address to only return the interface that serves the given IP address

func GetOutboundIP

func GetOutboundIP(destination string) net.IP

GetOutboundIP returns the default outbound IP address to reach the given hostname. This uses 1.1.1.1 as the default destination. TODO: use the default gateway address instead so this works without internet access.

Use a local hostname if a subnet other than the default one should be used. Use "" for the default route address

destination to reach or "" to use 1.1.1.1 (no connection will be established)

func GetOutboundInterface

func GetOutboundInterface(address string) (interfaceName string, macAddress string, ipAddr net.IP)

GetOutboundInterface Get preferred outbound network interface of this machine Credits: https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go and https://qiita.com/shaching/items/4c2ee8fd2914cce8687c

Types

This section is empty.

Jump to

Keyboard shortcuts

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