cloudflare

package
v0.0.0-...-86ee089 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	URL     = defaultURL
	Timeout = defaultTimeout
	Disable = defaultDisableDownload

	TestCount = defaultTestNum
	MinSpeed  = defaultMinSpeed
)
View Source
var (
	Httping           bool = true
	HttpingStatusCode int
	HttpingCFColo     string
	HttpingCFColomap  *sync.Map
	OutRegexp         = regexp.MustCompile(`[A-Z]{3}`)
)
View Source
var (
	// TestAll test all ip
	TestAll = false
	// IPFile is the filename of IP Rangs
	IPFile = defaultInputFile
	IPText string
)
View Source
var (
	Routines      = defaultRoutines
	TCPPort   int = defaultPort
	PingTimes int = defaultPingTimes

	IpTotal atomic.Int64
	IpDone  atomic.Int64
)
View Source
var BetterIP string
View Source
var IsWatching = false
View Source
var ReCheck = make(chan bool)

Functions

func BuildCloudflareClient

func BuildCloudflareClient(ip *net.IPAddr) *http.Client

func CheckCF

func CheckCF()

func ExecuteCloudflareRequest

func ExecuteCloudflareRequest(req *http.Request) (*http.Response, error)

func InitRandSeed

func InitRandSeed()
func init() {
	defaultTransportDialContext := (&net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
	}).DialContext
	http.DefaultTransport.(*http.Transport).DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
		// 3. 获取 addr 的端口,有可能我们第一次访问它会重定向,端口变了
		// 所以这里的逻辑是防止它重定向的时候端口变了,这里 ip 还是绑定的
		// 之前端口,会导致错误 400
		if (strings.Contains(addr, "hiyai.cn") || strings.Contains(addr, "aider.email")) && BetterIP != "" {
			portSlice := strings.Split(addr, ":")
			port := portSlice[1]
			addr = BetterIP + ":" + port

			fmt.Println("=========================================================", BetterIP)
			return dialer.DialContext(ctx, network, addr)
		}
		return defaultTransportDialContext(ctx, network, addr)
	}
}

func MapColoMap

func MapColoMap() *sync.Map

func TestDownloadSpeed

func TestDownloadSpeed(ipSet models.PingDelaySet) (speedSet models.DownloadSpeedSet)

Types

type IPRanges

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

type Ping

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

func NewClient

func NewClient() *Ping

func NewPing

func NewPing() *Ping

func (*Ping) Run

func (p *Ping) Run() models.PingDelaySet

Jump to

Keyboard shortcuts

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