http

package
v0.0.0-...-ed82f56 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxBody int64 = 1024 * 1024 * 1024 // 1GB

Variables

View Source
var DnsResolver = &net.Resolver{
	Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
		d := &net.Dialer{
			Timeout:   30 * time.Second,
			KeepAlive: 30 * time.Second,
			DualStack: true,
		}
		i := int(atomic.AddUint64(&currentResolverIndex, 1)) % len(dnsResolvers)
		return d.DialContext(ctx, "udp", dnsResolvers[i]+":53")
	},
}

DNSResolver resolves DNS nameservers randomly that previously loaded.

View Source
var FasthttpDialer = &fasthttp.TCPDialer{
	Concurrency:      1000,
	DNSCacheDuration: fasthttp.DefaultDNSCacheDuration * 60,
	Resolver:         DnsResolver,
}

Functions

func FasthttpHTTPDialerProxy

func FasthttpHTTPDialerProxy(proxy string) fasthttp.DialFunc

FasthttpHTTPDialer returns a fasthttp.DialFunc that dials using the provided HTTP proxy.

Example usage:

c := &fasthttp.Client{
	Dial: fasthttpproxy.FasthttpHTTPDialer("username:password@localhost:9050"),
}

func FasthttpHTTPDialerProxyTimeout

func FasthttpHTTPDialerProxyTimeout(proxy string, timeout time.Duration) fasthttp.DialFunc

FasthttpHTTPDialerTimeout returns a fasthttp.DialFunc that dials using the provided HTTP proxy using the given timeout.

Example usage:

c := &fasthttp.Client{
	Dial: fasthttpproxy.FasthttpHTTPDialerTimeout("username:password@localhost:9050", time.Second * 2),

func FetchReliableDNSRecords

func FetchReliableDNSRecords(url string) ([]string, error)

func Get

func Get(requestURI string) ([]byte, int, error)

func GetFast

func GetFast(requestURI string) ([]byte, int, error)

func GetProxyUrl

func GetProxyUrl() func(*http.Request) (*url.URL, error)

Types

type DNSRecord

type DNSRecord struct {
	IP          string  `json:"ip"`
	Name        string  `json:"name"`
	ASNumber    int     `json:"as_number"`
	ASOrg       string  `json:"as_org"`
	CountryID   string  `json:"country_id"`
	City        string  `json:"city"`
	Version     string  `json:"version"`
	Error       string  `json:"error"`
	DNSSEC      bool    `json:"dnssec"`
	Reliability float64 `json:"reliability"`
	CheckedAt   string  `json:"checked_at"`
	CreatedAt   string  `json:"created_at"`
}

Jump to

Keyboard shortcuts

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