netutil

package
v0.0.0-...-5a547ea Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const EmptyIP = "0.0.0.0"

Variables

This section is empty.

Functions

func ClientIP

func ClientIP(r *http.Request) string

ClientIP implements a best effort algorithm to return the real client IP, it parses X-Real-IP and X-Forwarded-For in order to work properly with reverse-proxies such us: nginx or haproxy.

func FreePort

func FreePort() (port int, err error)

FreePort returns an address of TCP free port from the kernel.

func GetHost

func GetHost(addr string) string

GetHost returns ip from addr that real client IP like '127.0.0.1:80'

func GetIP

func GetIP(addr string) string

GetIP same as GetHost

func GetPort

func GetPort(addr string) string

GetHost returns port from addr that real client IP like '127.0.0.1:80'

func IP

func IP() string

IP returns the current IP address.

func IPTail

func IPTail() string

IPTail returns the end of the current IP address. like: 4 in 192.168.1.4

Types

This section is empty.

Jump to

Keyboard shortcuts

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