Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPBinUtil ¶
HTTPBinUtil get and parse the request header by requesting `http(s)://httpbin.org`
func (HTTPBinUtil) GetRequestHeaders ¶
func (u HTTPBinUtil) GetRequestHeaders() (headers HTTPRequestHeaders, err error)
GetRequestHeaders implements RequestHeadersGetter.GetRequestHeaders
func (HTTPBinUtil) GetRequestHeadersUsingProxy ¶
func (u HTTPBinUtil) GetRequestHeadersUsingProxy(proxyURL string) (headers HTTPRequestHeaders, err error)
GetRequestHeadersUsingProxy implements RequestHeadersGetter.GetRequestHeaderUsingProxy
type HTTPRequestHeaders ¶
type HTTPRequestHeaders struct { XForwardedFor string `json:"X-Forwarded-For"` // e.g. "1.2.3.4, 5.6.7.8, 1.2.3.4" XRealIP string `json:"X-Real-Ip"` // e.g. "1.2.3.4" Via string `json:"Via"` // e.g. "1.1 squid" }
HTTPRequestHeaders 代表发起HTTP请求时的请求头部分信息 其中`X-Forwarded-For`和`X-Real-Ip`可以计算出Client的公网IP `Via` 一般是在HTTP请求经由代理转发后增加的字段
func (HTTPRequestHeaders) ParsePublicIP ¶
func (h HTTPRequestHeaders) ParsePublicIP() (net.IP, error)
ParsePublicIP resolves the public IP address of the Client based on Headers First parse the IP of the first record of the `X-Forwarded-For` field parse the `X-Real-Ip` field value if it does not exist If all parsing fails, return nil
type RateLimiter ¶
type RateLimiter struct { // Delay is the duration to wait before do next operation. Delay time.Duration // Parallelism is the number of the maximum allowed concurrent operate. Parallelism int // contains filtered or unexported fields }
RateLimiter contains some rate limit to control the rate of some operations, such as network request frequency, etc.
func (*RateLimiter) Init ¶
func (l *RateLimiter) Init()
Init initializes the private members of RateLimiter.
type RequestHeadersGetter ¶
type RequestHeadersGetter interface { GetRequestHeaders() (headers HTTPRequestHeaders, err error) GetRequestHeadersUsingProxy(proxyURL string) (headers HTTPRequestHeaders, err error) }
RequestHeadersGetter 获取HTTP请求头的接口。