Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultTimeout = 5 * time.Second DefaultMaxRetry = 10 DefaultInterval = 100 * time.Millisecond DefaultReadBufferSize = 32 * 1024 BASE64CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" )
Functions ¶
This section is empty.
Types ¶
type MT19937 ¶
type MT19937 struct {
// contains filtered or unexported fields
}
MT19937 封装了一个 32 位的 Mersenne Twister 状态,与 CPython random 模块对齐。
func NewMT19937 ¶
func NewMT19937() *MT19937
New 返回一个新的 MT19937 实例,默认用 seed=5489 初始化, 这是经典参考实现的默认做法(Python 中若不指定 seed,会从系统熵源播种)。
func (*MT19937) Float64 ¶
Float64 对应 CPython 的 random_random():
double random_random() { a = genrand_uint32() >> 5; // 取高 27 bit b = genrand_uint32() >> 6; // 取高 26 bit return (a * 67108864.0 + b) / 9007199254740992.0; // 2^53 = 9007199254740992 }
func (*MT19937) GetRandBits ¶
GetRandBits(k) 模拟 Python getrandbits(k),返回一个大整数。
func (*MT19937) SeedFromBigInt ¶
type NeoregClient ¶
type NeoregClient struct { Proxy *url.URL Conf *NeoregConf }
NeoregClient 实现了Client接口
type NeoregConf ¶
type NeoregConf struct { Dial func(ctx context.Context, network, address string) (net.Conn, error) Protocol string // http/https EncodeMap map[byte]byte DecodeMap map[byte]byte Key string Rand *NeoregRand Timeout time.Duration MaxRetry int Interval time.Duration ReadBufferSize int // contains filtered or unexported fields }
NeoregConf 配置结构
func NewConfFromURL ¶
func NewConfFromURL(proxyURL *url.URL) (*NeoregConf, error)
NewConfFromURL 从URL中解析用户名密码生成配置
type NeoregRand ¶
type NeoregRand struct {
// contains filtered or unexported fields
}
func (*NeoregRand) Base64Chars ¶
func (rg *NeoregRand) Base64Chars(chars []rune)
Base64Chars 模拟 Python 的 shuffle
func (*NeoregRand) RandValue ¶
func (rg *NeoregRand) RandValue() string
Click to show internal directories.
Click to hide internal directories.