proxy

package
v0.1.112 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CloudflareProvider provider = iota
	DNSPodProvider
	GoogleProvider
	Quad9Provider
)

DoH 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/123.0.0.0 Safari/537.36"

Variables

View Source
var (
	ResponseTypeA    = 1
	ResponseTypeAAAA = 28
)

Supported dns response types

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) {
	return &goproxy.ConnectAction{Action: goproxy.ConnectMitm, TLSConfig: CustomTLS(&goproxy.GoproxyCa)}, host
}

AlwaysHTTPMitm ...

View Source
var CACHE_DIR = ""

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 IPs added in v0.1.103

func IPs(resp *dns.Response) []string

func Reload

func Reload()

Reload ...

func TTL added in v0.1.103

func TTL(resp *dns.Response) int

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 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

type DoH added in v0.1.103

type DoH struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

DoH is doh client

func UseProviders added in v0.1.103

func UseProviders(provider ...provider) *DoH

func (*DoH) Close added in v0.1.103

func (c *DoH) Close()

Close close doh client

func (*DoH) Query added in v0.1.103

func (c *DoH) Query(ctx context.Context, d dns.Domain, t dns.Type, s ...dns.ECS) (*dns.Response, error)

Query do DoH query

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, dns.Domain, dns.Type, ...dns.ECS) (*dns.Response, error)
	String() string
}

Provider is the provider interface

func New added in v0.1.103

func New(provider provider) Provider

New returns a new DoH client, quad9 is default

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