neoreg

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: GPL-3.0 Imports: 19 Imported by: 0

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

func (mt *MT19937) Float64() 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

func (mt *MT19937) GetRandBits(k int) *big.Int

GetRandBits(k) 模拟 Python getrandbits(k),返回一个大整数。

func (*MT19937) Seed

func (mt *MT19937) Seed(seed int64)

func (*MT19937) SeedFromBigInt

func (mt *MT19937) SeedFromBigInt(bigSeed *big.Int)

func (*MT19937) Uint32

func (mt *MT19937) Uint32() uint32

type NeoregClient

type NeoregClient struct {
	Proxy *url.URL
	Conf  *NeoregConf
}

NeoregClient 实现了Client接口

func (*NeoregClient) Dial

func (c *NeoregClient) Dial(network, address string) (net.Conn, error)

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 NewNeoregRand

func NewNeoregRand(key string) *NeoregRand

NewRandGenerator 创建 NeoregRand 实例

func (*NeoregRand) Base64Chars

func (rg *NeoregRand) Base64Chars(chars []rune)

Base64Chars 模拟 Python 的 shuffle

func (*NeoregRand) RandValue

func (rg *NeoregRand) RandValue() string

Jump to

Keyboard shortcuts

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