proxy

package
v0.1.119 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllProviders dohprovider = iota
	CloudflareProvider
	GoogleProvider
	Quad9Provider
	OpenNameServerProvider
	CustomProvider
)

CustomDNS Providers enum

View Source
const CACHE_TTL = 24 * time.Hour // 24 hour caching
View Source
const CONFIG_FILE_NAME = "antizapret_config.gob" // Using gob for caching
View Source
const HASH_MASK = (1 << TABLE_LEN_BITS) - 1
View Source
const TABLE_LEN_BITS = 18

variables for unlzp function

View Source
const USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36"

Variables

View Source
var (

	// Proxy ...
	Proxy = goproxy.NewProxyHttpServer()

	// ProxyPort ...
	ProxyPort = 65222
)
View Source
var AlwaysHTTPMitm goproxy.FuncHttpsHandler = func(host string, ctx *goproxy.ProxyCtx) (*goproxy.ConnectAction, string) {

	ctx.UserData = proxyUser(ctx.Req)
	return &goproxy.ConnectAction{Action: goproxy.ConnectMitm, TLSConfig: CustomTLS(&goproxy.GoproxyCa)}, host
}

AlwaysHTTPMitm ...

View Source
var CACHE_DIR = ""

Default DoH Providers list

Functions

func CustomDialContext

func CustomDialContext(ctx context.Context, network, addr string) (net.Conn, error)

CustomDialContext ...

func CustomTLS

func CustomTLS(ca *tls.Certificate) func(host string, ctx *goproxy.ProxyCtx) (*tls.Config, error)

CustomTLS ...

func GetClient

func GetClient() *http.Client

GetClient ...

func GetDirectClient

func GetDirectClient() *http.Client

GetDirectClient ...

func GetProxyClient added in v0.1.119

func GetProxyClient() *http.Client

GetProxyClient returns the client sending requests through the internal proxy whenever it is enabled, like Burst requests, so they get the same browser fingerprint.

func IPs added in v0.1.103

func IPs(ips []net.IPAddr) []string

func NewDNSProvider added in v0.1.114

func NewDNSProvider(provider string) (uri string, p *net.Resolver, err error)

NewDNSProvider returns a new DNS client, local resolv is default

func NewDoHProvider added in v0.1.114

func NewDoHProvider(provider dohprovider) (uri string, p *net.Resolver, err error)

NewDoHProvider returns a new DoH client, quad9 is default

func Reload

func Reload()

Reload applies proxy configuration: DNS resolvers, the direct client upstream proxy and the internal proxy server lifecycle.

func StartRecording added in v0.1.119

func StartRecording(tag string)

StartRecording records requests, made with "tag" as proxy user name, like http://tag:@127.0.0.1:65222

func StopProxy added in v0.1.115

func StopProxy()

StopProxy shuts down the running proxy, if any.

Types

type AntizapretConfig added in v0.1.112

type AntizapretConfig struct {
	CreatedAt                time.Time
	Domains                  []DomainEntry  // Use slice to preserve order of TLD
	Special                  []SpecialEntry // Use slice to preserve order
	DIpaddr                  []uint32       // IP addresses stored as big-endian uint32
	PatternsDomainsLzp       []PatternEntry // Use slice to preserve order
	PatternsMaskLzp          []PatternEntry // Use slice to preserve order
	ThreePartSuffixesPattern string
	ProxyURL                 string
}

type AntizapretProxy added in v0.1.112

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

AntizapretProxy struct

func NewAntizapretProxy added in v0.1.112

func NewAntizapretProxy() *AntizapretProxy

Constructor for AntizapretProxy

func (*AntizapretProxy) Detect added in v0.1.112

func (ap *AntizapretProxy) Detect(host string) string

Detect if a host needs proxying Returns the proxy URL string if proxy is needed, otherwise returns an empty string.

func (*AntizapretProxy) ProxyURL added in v0.1.112

func (ap *AntizapretProxy) ProxyURL(r *http.Request) (*url.URL, error)

ProxyURL is used for Transport.Proxy

func (*AntizapretProxy) Update added in v0.1.112

func (ap *AntizapretProxy) Update()

type CustomDNS added in v0.1.114

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

CustomDNS is custom DNS client

func UseDNSProviders added in v0.1.114

func UseDNSProviders(provider ...string) *CustomDNS

func UseDoHProviders added in v0.1.114

func UseDoHProviders(provider ...dohprovider) *CustomDNS

func (*CustomDNS) Query added in v0.1.114

func (c *CustomDNS) Query(ctx context.Context, d string) ([]net.IPAddr, error)

Query do DoH query

type CustomDNSProvider added in v0.1.114

type CustomDNSProvider struct {
	*net.Resolver
	URI string
}

type CustomProxy

type CustomProxy struct {
	Server    *http.Server
	IsErrored bool
}

CustomProxy stores http.Server with field showing there was an error while listening.

func StartProxy

func StartProxy() *CustomProxy

StartProxy starts HTTP/HTTPS proxy for debugging. Repeated calls return the proxy that is already running.

type DomainEntry added in v0.1.112

type DomainEntry struct {
	TLD     string
	Lengths []LengthEntry // Use slice to preserve order
}

type LengthEntry added in v0.1.112

type LengthEntry struct {
	Length     int
	Data       []string
	DataLength int
}

type PatternEntry added in v0.1.112

type PatternEntry struct {
	Key   string
	Value string
}

Structs to hold the configuration data

type Provider added in v0.1.103

type Provider interface {
	Query(context.Context, string) ([]net.IPAddr, error)
	String() string
}

Provider is the provider interface

type RecordedRequest added in v0.1.119

type RecordedRequest struct {
	Method string
	URL    string
	Status int
	Error  string
}

RecordedRequest is a request, that went through internal proxy with a recorded tag

func StopRecording added in v0.1.119

func StopRecording(tag string) []RecordedRequest

StopRecording returns requests recorded for the tag

type SpecialEntry added in v0.1.112

type SpecialEntry struct {
	Netaddr string
	Netmask int
}

Jump to

Keyboard shortcuts

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