egress

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package egress 查询出口的公网 IP,并按本地 IP 库推出出口所在的国家、时区与语言

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prefetch added in v0.3.9

func Prefetch(proxy string)

Prefetch 在本地 IPv4 库缺失或过期时经 proxy 开始后台下载,proxy 为空时直连

Types

type Download added in v0.3.9

type Download struct {
	Received int64 `json:"received"`
	Total    int64 `json:"total"`
}

Download 是正在进行的 IP 库下载的已收与总字节,总字节未知时为 0

type Exit

type Exit struct {
	IP       string `json:"ip"`
	Country  string `json:"country"`
	Timezone string `json:"timezone"`
	Locale   string `json:"locale"`
}

Exit 是一个出口的公网 IP 与按 IP 定位的国家、时区和语言

func Environment

func Environment(ctx context.Context, proxy string, locale string, timezone string) (Exit, error)

Environment 返回账户的语言与时区:两项都给出时原样返回,否则经 proxy 查询出口,未给出的项取出口所在地的语言与时区

func Lookup

func Lookup(ctx context.Context, proxy string) (Exit, error)

Lookup 经 proxy 取得出口公网 IP,再按本地 IP 库推出国家、时区与该国最常用的语言;proxy 为空时直连,IP 库缺失时等进程内共用的一轮下载结束,这一轮经其他出口失败时经 proxy 再下载,IP 库过期时立即用现有的库查询并在后台更新

type Preparation added in v0.3.9

type Preparation struct {
	Ready     bool      `json:"ready"`
	Preparing bool      `json:"preparing"`
	Download  *Download `json:"download,omitempty"`
	Error     string    `json:"error,omitempty"`
}

Preparation 是 IP 库的准备状态:本地 IPv4 库是否已有、是否正在下载、正在进行的下载与最近一轮下载失败的原因

func PreparationState added in v0.3.9

func PreparationState() Preparation

PreparationState 返回 IP 库的准备状态,同时下载多个地址族时合计已收与总字节,收到下载响应前 Download 为 nil,各地址族最近一轮的失败原因依次合并

Jump to

Keyboard shortcuts

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