Documentation
¶
Index ¶
- Constants
- Variables
- func ReadProxies(configPathConfig string, proxyUrl *url.URL) (map[string]CProxy, error)
- func SetCacheTimeout(t time.Duration)
- func TestURLAvailable(urls []string, proxy C.Proxy, timeout time.Duration) map[string]bool
- type CProxy
- type CProxyWithResult
- type GPTResult
- type Options
- type ProxyProvider
- type RawConfig
- type RequestOption
- type Result
- type SortField
- type Test
- func (t *Test) AliveProxies() ([]CProxy, error)
- func (t *Test) AliveProxiesToJson() ([]byte, error)
- func (t *Test) AliveProxiesWithResult() ([]CProxyWithResult, error)
- func (t *Test) LogAlive()
- func (t *Test) LogNum()
- func (t *Test) LogResults()
- func (t *Test) Proxies() map[string]CProxy
- func (t *Test) TestSpeed() ([]Result, error)
- func (t *Test) WriteToCsv(names ...string) error
- func (t *Test) WriteToYaml(names ...string) error
- type XcResponse
Constants ¶
View Source
const ( SortFieldBandwidth SortField = "b" // 带宽 SortFieldBandwidth2 SortField = "bandwidth" // 带宽 SortFieldTTFB SortField = "t" // 延迟 SortFieldTTFB2 SortField = "ttfb" GPTTestURLAndroid = "https://android.chat.openai.com" GPTTestURLIOS = "https://ios.chat.openai.com/" GPTTestURLWeb = "https://chatgpt.com/" GPTTrace = "https://chat.openai.com/cdn-cgi/trace" DefaultLivenessAddr = "https://speed.cloudflare.com/__down?bytes=%d" )
Variables ¶
View Source
var (
ErrSpeedNotTest = errors.New("请先测速")
)
Functions ¶
func ReadProxies ¶
ReadProxies 从网络下载或者本地读取配置文件 configPathConfig 是配置地址,多个之间用 | 分割
func SetCacheTimeout ¶ added in v0.1.2
Types ¶
type CProxyWithResult ¶ added in v0.0.2
type GPTResult ¶
type Options ¶
type Options struct { LivenessAddr string `json:"liveness_addr"` // 测速时调用的地址,格式如 https://speed.cloudflare.com/__down?bytes=%d DownloadSize int `json:"download_size"` // 测速时下载的文件大小,单位为 bit(使用默认cloudflare的话),默认下载10M Timeout time.Duration `json:"timeout"` // 每个代理测速的超时时间 ConfigPath string `json:"config_path"` // 配置文件地址,可以为 URL 或者本地路径,多个使用 | 分隔 NameRegexContain string `json:"name_regex_contain"` // 通过名字过滤代理,只测试过滤部分,格式为正则,默认全部测 NameRegexNonContain string `json:"name_regex_not_contain"` // 通过名字过滤代理,跳过过滤部分,格式为正则 SortField SortField `json:"sort_field"` // 排序方式,b 带宽 t 延迟 Concurrent int `json:"concurrent"` // 测速时候的下载并发数 TestGPT bool `json:"test_gpt"` // 是否检测节点支持 GPT URLForTest []string `json:"url_for_test"` // 测试 URL 是否可访问 ProxyUrl string `json:"proxy_url"` // ConfigPath 为网络链接时可使用指定代理下载 }
type ProxyProvider ¶ added in v0.1.14
type ProxyProvider struct {
Url string `json:"url"`
}
type RawConfig ¶
type RawConfig struct { Providers map[string]ProxyProvider `yaml:"proxy-providers"` Proxies []map[string]any `yaml:"proxies"` }
type RequestOption ¶ added in v0.1.7
type RequestOption struct { Method string URL string Body []byte JSON interface{} // 传递这个参数可以为任意可 json 序列化值,会自动加上 Content-Type, 并覆盖 Body 内容 Headers map[string]string Timeout time.Duration // 单次请求超时时间 // 重试相关 RetryTimes int // 重试次数 RetryTimeOut time.Duration // 重试超时时间 // 详细日志 Verbose bool // 代理链接 ProxyUrl *url.URL }
type Result ¶
type Result struct { Name string Bandwidth float64 TTFB time.Duration Delay uint16 GPTResult URLForTest map[string]bool }
func TestProxyConcurrent ¶
type Test ¶
type Test struct {
// contains filtered or unexported fields
}
func (*Test) AliveProxiesToJson ¶
AliveProxiesToJson 可访问的节点, 返回 JSON string
func (*Test) AliveProxiesWithResult ¶ added in v0.0.2
func (t *Test) AliveProxiesWithResult() ([]CProxyWithResult, error)
AliveProxiesWithResult 可访问的节点以及结果
func (*Test) LogResults ¶
func (t *Test) LogResults()
func (*Test) WriteToCsv ¶
func (*Test) WriteToYaml ¶
type XcResponse ¶ added in v0.1.7
func Request ¶ added in v0.1.7
func Request(option *RequestOption) (*XcResponse, error)
Click to show internal directories.
Click to hide internal directories.