fireness

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

README

fireness

Network development helper.

Installation

go get -u github.com/coolstina/fireness

Features

DomainParse(DNS)

The IP address that is used to resolve the domain name to which it is mapped.

ClientIP

Get the http request X-Real-IP or X-Forwarded-For IP address.

IP detection
  • IsIP: Check whether the IP address is real ip.
  • IsIPv4: Check whether the IP address is IPv4.
  • IsIPv6: Check whether the IP address is real ip.
  • Localhost: Get localhost IP list.
IP conversion
  • IPv4ToInt: Convert IPv4 address string to integer.
  • IntToIPv4: Convert IP integer to IPv4 address string.

License

Author

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDomainParse = fmt.Errorf("domain parse failed")
View Source
var ErrNotfoundClientIP = fmt.Errorf("not found client ip")

Functions

func BigIntToIPv6 added in v1.4.0

func BigIntToIPv6(ipaddr *big.Int) net.IP

BigIntToIPv6 Convert IP address of version 6 from big integer to net.IP.

func ClientIP

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

func IPv4ToInt

func IPv4ToInt(ip string) uint32

IPv4ToInt Convert IPv4 address string to integer.

func IPv6ToBigInt added in v1.4.0

func IPv6ToBigInt(ip net.IP) *big.Int

IPv6ToBigInt Convert IPv6 address string to integer.

func IntToIPv4

func IntToIPv4(ip uint32) string

IntToIPv4 Convert IP integer to IPv4 address string.

func IsIP

func IsIP(addr string) bool

IsIP Check whether the IP address is real ip.

func IsIPv4

func IsIPv4(addr string) bool

IsIPv4 Check whether the IP address is IPv4.

func IsIPv6

func IsIPv6(addr string) bool

IsIPv6 Check whether the IP address is IPv6.

Types

type DomainParsed

type DomainParsed struct {
	Original string `json:"original"`
	IPS      IPList `json:"ips"`
}

DomainParsed parsed domain result structure definition.

func DomainParse

func DomainParse(domain string) (*DomainParsed, error)

DomainParse parse domain to IP address.

func NewDomainParsedWithOriginal

func NewDomainParsedWithOriginal(domain string) *DomainParsed

NewDomainParsedWithOriginal returns a new DomainParsed instance with original domain string.

func (*DomainParsed) FirstIP

func (d *DomainParsed) FirstIP() string

FirstIP returns the IPS list first IP address.

func (*DomainParsed) IPv4s added in v1.3.1

func (d *DomainParsed) IPv4s() IPList

IPv4s returns an IPv4 list.

func (*DomainParsed) IPv6s added in v1.3.1

func (d *DomainParsed) IPv6s() IPList

IPv6s returns an IPv6 list.

func (*DomainParsed) String

func (d *DomainParsed) String() string

String implement Stringer interface.

type IPList added in v1.3.1

type IPList []string

IPList IP list structure definition.

func (IPList) IsEmpty added in v1.3.1

func (iplist IPList) IsEmpty() bool

IsEmpty detect IP list is empty.

func (IPList) IsNil added in v1.3.1

func (iplist IPList) IsNil() bool

IsNil detect IP list is nil.

type LocalhostList added in v1.3.2

type LocalhostList []string

LocalhostList localhost IP list structure definition.

func Localhost added in v1.3.2

func Localhost(options ...LocalhostOption) (LocalhostList, error)

Localhost Get localhost IP list.

func (LocalhostList) First added in v1.3.2

func (list LocalhostList) First() string

First returns localhost IP list first element.

type LocalhostOption added in v1.3.2

type LocalhostOption interface {
	// contains filtered or unexported methods
}

LocalhostOption implement Option model.

func WithLocalhostExclude added in v1.3.2

func WithLocalhostExclude(excludes ...string) LocalhostOption

WithLocalhostExclude Get IP list exclude specify IP.

func WithLocalhostExcludeIPv4 added in v1.3.2

func WithLocalhostExcludeIPv4(exclude bool) LocalhostOption

WithLocalhostExcludeIPv4 Get IP list exclude IPv4 address.

func WithLocalhostExcludeIPv6 added in v1.3.2

func WithLocalhostExcludeIPv6(exclude bool) LocalhostOption

WithLocalhostExcludeIPv6 Get IP list exclude IPv6 address.

type LocalhostOptionFunc added in v1.3.2

type LocalhostOptionFunc func(option *localhostOption)

LocalhostOptionFunc Options function structure.

Jump to

Keyboard shortcuts

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