Net

package
v0.0.0-...-7e13a3b Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SOCKS4 = iota
	SOCKS4A
	SOCKS5
)

Constants to choose which version of SOCKS protocol to use.

View Source
const (
	Http                  = "http"
	Https                 = "https"
	Socks4                = "socks4"
	Socks5                = "socks5"
	Socks                 = "socks"
	EaMobile              = "http://cdn.skum.eamobile.com"
	Google                = "https://www.google.com"
	MM20Init              = `https://mm20.prod.fuel.ddns.ea.com/g/game/content/Init`
	Facebook              = "https://www.facebook.com"
	MAXGoRoutinesPoolSize = 1000
)

Variables

View Source
var (
	RegexpIp     = regexp.MustCompile(`((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))`)
	RegexpIpPort = regexp.MustCompile(`((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))):([0-9]+)`)
)
View Source
var RegexpCenter = `(.+?)`
View Source
var UserAgentRandom string
View Source
var UserAgents = []string{
	"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
	"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
	"Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
	"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
	"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
	"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
	"Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
	"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
	"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36",
	"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36",
	"Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36",
	"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36",
}
View Source
var W = library{
	Check:  Check.New(),
	Log:    Log.New(),
	Random: Random.New(),
}

Functions

func DialSocksProxy

func DialSocksProxy(socksType int, proxy string) func(string, string) (net.Conn, error)

DialSocksProxy returns the dial function to be used in http.Transport object. Argument socksType should be one of SOCKS4, SOCKS4A and SOCKS5. Argument proxy should be in this format "127.0.0.1:1080".

func SDial

func SDial(proxyURI string) func(string, string) (net.Conn, error)

Dial returns the dial function to be used in http.Transport object. Argument proxyURI should be in the format: "socks5://user:password@127.0.0.1:1080?timeout=5s". The protocol could be socks5, socks4 and socks4a.

Types

type Auth

type Auth struct {
	Username string
	Password string
}

type Config

type Config struct {
	Proto   int
	Host    string
	Auth    Auth
	Timeout time.Duration
}

type HttpRequestCtx

type HttpRequestCtx struct {
	Client      *http.Client
	StopCode    int
	Method      string
	Url         string
	Head        map[string]string
	RequestBody interface{}
}

type IpInfo

type IpInfo struct {
	IpPort               string        `json:"ip_port"`
	Protocol             string        `json:"protocol"`
	Country              string        `json:"country"`
	Speed                float64       `json:"speed"`
	BadCount             int           `json:"bad_count"`
	SuccessCount         int           `json:"success_count"`
	CheckCount           int           `json:"check_count"`
	AvgResponseTime      float64       `json:"avg_response_time"`
	LastCheckTimeStamp   time.Duration `json:"last_check_time_stamp"`
	LastSuccessTimeStamp time.Duration `json:"last_success_time_stamp"`
	Useful               bool          `json:"useful"`
}

type KeyValueIpInfo

type KeyValueIpInfo struct {
	Key   string
	Value IpInfo
}

type Net

type Net interface {
	CreatClient(data ProxyInfo) (ok bool)
	IsCookieInJar(jar *cookiejar.Jar, cookieName, Host string) (ok bool)
	CreatTransport(data ProxyInfo) (ok bool)
	IntegerToIP(ip int64) string
	CheckProtocol(Protocol, IpPort string) (ok bool)
	IsKnownProtocol(Protocol string) bool
	RegexpWebBodyBlocks(tagName string) string
	HttpRequest(data *HttpRequestCtx) (Response *http.Response, err error)
	HttpReadRequestBody(data *HttpRequestCtx) (buf []byte, err error)
	ClientGet() *http.Client
	ClientSet(c *http.Client)
	ClientInit()
	TCP.TCP
	UDP.UDP
}

func New

func New() Net

type ObjTransport

type ObjTransport struct {
	Transport *http.Transport
	// contains filtered or unexported fields
}

type ProxyInfo

type ProxyInfo struct {
	ProxyProtocol string
	ProxyIpPort   string
}

Directories

Path Synopsis
TCP
UDP

Jump to

Keyboard shortcuts

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