netutils

package
v0.0.0-...-6d3478e Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnToHTTP

func ConnToHTTP(src net.Conn, destReq *http.Request, destRes http.ResponseWriter) error

ConnToHTTP proxies a requests from a net.Conn to a destination request, writing the response to provided ResponseWriter.

func CopyUDPAddr

func CopyUDPAddr(addr *net.UDPAddr) *net.UDPAddr

CopyUDPAddr returns a new copy of a giving UDPAddr.

func GetAddr

func GetAddr(addr string) string

GetAddr takes the giving address string and if it has no ip or use the zeroth ip format, then modifies the ip with the current systems ip.

func GetClustersFriends

func GetClustersFriends(clusterPort int, routes []*url.URL) ([]*url.URL, error)

GetClustersFriends returns a giving set of routes from the provided port number.

func GetInterfaceIPs

func GetInterfaceIPs() ([]net.IP, error)

GetInterfaceIPs returns the list of IP of the giving interfaces found in the system.

func GetMainIP

func GetMainIP() (string, error)

GetMainIP returns the giving system IP by attempting to connect to a imaginary ip and returns the giving system ip.

func GetMainIPByInterface

func GetMainIPByInterface() (string, error)

GetMainIPByInterface returns the giving ip of the current system by looping through all interfaces returning the first ipv4 found that is not on the loopback interface.

func GetURLIP

func GetURLIP(ipStr string) ([]net.IP, error)

GetURLIP returns a giving ip addres if the ip string is not an ip address.

func HTTPToConn

func HTTPToConn(srcReq *http.Request, srcRes http.ResponseWriter, dest net.Conn) error

HTTPToConn proxies a src Request to a net.Con connection and writes back the response to the src Response.

func IsIPInList

func IsIPInList(list1 []net.IP, list2 []net.IP) bool

IsIPInList returns true/false if the giving ip list were equal.

func LoadTLS

func LoadTLS(cert string, key string, ca string) (*tls.Config, error)

LoadTLS loads a tls.Config from a key and cert file path

func MakeListener

func MakeListener(protocol string, addr string, conf *tls.Config) (net.Listener, error)

MakeListener returns a new net.Listener requests.

func NewConn

func NewConn(protocol string, addr string) (net.Conn, error)

NewConn returns a tls.Conn object from the provided parameters.

func NewHTTPServer

func NewHTTPServer(l net.Listener, handle http.Handler, c *tls.Config) (*http.Server, net.Listener, error)

NewHTTPServer returns a new http.Server using the provided listener

func NewKeepAliveListener

func NewKeepAliveListener(tl *net.TCPListener) net.Listener

NewKeepAliveListener returns a new net.Listener from underline net.TCPListener where produced net.Conns respect keep alive regualations.

func ProxyHTTPRequest

func ProxyHTTPRequest(src net.Conn, dest net.Conn) error

ProxyHTTPRequest copies a http request from a src net.Conn connection to a destination net.Conn.

func TCPListener

func TCPListener(addr string, conf *tls.Config) (net.Listener, error)

TCPListener returns a new net.Listener requests.

func TLSCipher

func TLSCipher(cs uint16) string

TLSCipher returns a cipher string version based on the supplied hex value.

func TLSConn

func TLSConn(protocol string, addr string, conf *tls.Config) (*tls.Conn, error)

TLSConn returns a tls.Conn object from the provided parameters.

func TLSFromConn

func TLSFromConn(tl *tls.Conn, addr string) (*tls.Conn, error)

TLSFromConn returns a new tls.Conn using the address and the certicates from the provided *tls.Conn.

func TLSVersion

func TLSVersion(ver uint16) string

TLSVersion returns a string version number based on the tls version int.

func UpgradeConnToTLS

func UpgradeConnToTLS(conn net.Conn, cm *tls.Config) (net.Conn, error)

UpgradeConnToTLS upgrades the giving tcp connection to use a tls based connection encrypted by the giving tls.Config.

Types

This section is empty.

Jump to

Keyboard shortcuts

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