xnet

package
v0.0.0-...-849f898 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIdlePort

func GetLocalIdlePort() (int, error)

GetLocalIdlePort ...

func IsPrivateIP

func IsPrivateIP(ip string) bool

IsPrivateIP 比较高效的 private ip 判断

func IsPrivateIPEx

func IsPrivateIPEx(ip string) bool

IsPrivateIPEx 判断是否是 private ip

Types

type EasyHTTP

type EasyHTTP struct {
	// contains filtered or unexported fields
}

EasyHTTP easy http request

func NewEasyHTTP

func NewEasyHTTP() *EasyHTTP

NewEasyHTTP construct a new EasyHTTP

func (*EasyHTTP) Get

func (s *EasyHTTP) Get(urlPath string) ([]byte, error)

Get ...

func (*EasyHTTP) HTTProxy

func (s *EasyHTTP) HTTProxy(rw http.ResponseWriter, req *http.Request, targetHostSchemed string)

HTTProxy 转发http请求

arg: targetHostSchemed, examples "https://baog.xxxx.com"

func (*EasyHTTP) Options

func (s *EasyHTTP) Options(options *HTTPOptions) *EasyHTTP

Options return a new EasyHTTP with options in input

func (*EasyHTTP) PostJSON

func (s *EasyHTTP) PostJSON(urlPath string, data interface{}) ([]byte, error)

PostJSON post json

func (*EasyHTTP) PostWwwForm

func (s *EasyHTTP) PostWwwForm(urlPath string, data map[string]string) ([]byte, error)

PostWwwForm post x-www-form-urlencoded

func (*EasyHTTP) SetOptions

func (s *EasyHTTP) SetOptions(options *HTTPOptions)

SetOptions set options for http request

type HTTPOptions

type HTTPOptions struct {
	Host        string
	UserAgent   string
	ConnTimeout time.Duration
}

HTTPOptions options for http request

type HTTPRealIP

type HTTPRealIP struct {
}

HTTPRealIP implemention of the interface IRealIP

func (*HTTPRealIP) ClientIP

func (m *HTTPRealIP) ClientIP(r *http.Request) string

ClientIP get client ip

func (*HTTPRealIP) ClientPublicIP

func (m *HTTPRealIP) ClientPublicIP(r *http.Request) string

ClientPublicIP get client's public ip addr

func (*HTTPRealIP) IsPrivateIP

func (m *HTTPRealIP) IsPrivateIP(ip string) bool

IsPrivateIP check the ip address whether priviate or not

func (*HTTPRealIP) RealIP

func (m *HTTPRealIP) RealIP(r *http.Request) string

RealIP try to get the client's public address ip, if not, get the private one

func (*HTTPRealIP) RemoteIP

func (m *HTTPRealIP) RemoteIP(r *http.Request) string

RemoteIP get remote ip from http.Request

type IRealIP

type IRealIP interface {
	IsPrivateIP(ip string) bool
	RealIP(r *http.Request) string
	ClientIP(r *http.Request) string
	ClientPublicIP(r *http.Request) string
}

IRealIP interface for ip options

Jump to

Keyboard shortcuts

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