fastdialer

package
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: MIT Imports: 28 Imported by: 12

Documentation

Overview

fastdialer is a dialer package containing a dns/tls cache layer

Index

Constants

View Source
const HostsFilePath = "/etc/hosts"

HostsFilePath in unix file os

View Source
const ResolverFilePath = "/etc/resolv.conf"

ResolverFilePath in unix file os

Variables

View Source
var (
	CouldNotConnectError  = errors.New("could not connect to any address found for host")
	NoAddressFoundError   = errors.New("no address found for host")
	NoAddressAllowedError = errors.New("denied address found for host")
	NoPortSpecifiedError  = errors.New("port was not specified")
	MalformedIP6Error     = errors.New("malformed IPv6 address")
	ResolveHostError      = errors.New("could not resolve host")
	NoTLSHistoryError     = errors.New("no tls data history available")
	NoTLSDataError        = errors.New("no tls data found for the key")
	NoDNSDataError        = errors.New("no data found")
	AsciiConversionError  = errors.New("could not convert hostname to ASCII")
)
View Source
var DefaultOptions = Options{
	BaseResolvers:   DefaultResolvers,
	MaxRetries:      5,
	HostsFile:       true,
	ResolversFile:   true,
	CacheType:       Disk,
	DialerTimeout:   10 * time.Second,
	DialerKeepAlive: 10 * time.Second,
}

DefaultOptions of the cache

View Source
var DefaultResolvers = []string{
	"1.1.1.1:53",
	"1.0.0.1:53",
	"8.8.8.8:53",
	"8.8.4.4:53",
}

DefaultResolvers trusted

Functions

func AsTLSConfig

func AsTLSConfig(ztlsConfig *ztls.Config) (*tls.Config, error)

func AsZTLSConfig

func AsZTLSConfig(tlsConfig *tls.Config) (*ztls.Config, error)

func HandleHostLine

func HandleHostLine(raw string) (ip string, hosts []string)

HandleHostLine a hosts file line

func HandleResolverLine

func HandleResolverLine(raw string) (ip string)

HandleLine a resolver file line

func HasComment

func HasComment(raw string) bool

HasComment check if the line has a comment

func IsComment

func IsComment(raw string) bool

IsComment check if the file is a comment

func IsTLS13

func IsTLS13(config interface{}) bool

Types

type CacheType

type CacheType uint8
const (
	Memory CacheType = iota
	Disk
	Hybrid
)

type ContextOption

type ContextOption string
const (
	// SniName to use in tls connection
	SniName ContextOption = "sni-name"
	IP      ContextOption = "ip"
)

type Dialer

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

Dialer structure containing data information

func NewDialer

func NewDialer(options Options) (*Dialer, error)

NewDialer instance

func (*Dialer) Close

func (d *Dialer) Close()

Close instance and cleanups

func (*Dialer) Dial

func (d *Dialer) Dial(ctx context.Context, network, address string) (conn net.Conn, err error)

Dial function compatible with net/http

func (*Dialer) DialTLS

func (d *Dialer) DialTLS(ctx context.Context, network, address string) (conn net.Conn, err error)

DialTLS with encrypted connection

func (*Dialer) DialTLSWithConfig

func (d *Dialer) DialTLSWithConfig(ctx context.Context, network, address string, config *tls.Config) (conn net.Conn, err error)

DialTLS with encrypted connection

func (*Dialer) DialTLSWithConfigImpersonate

func (d *Dialer) DialTLSWithConfigImpersonate(ctx context.Context, network, address string, config *tls.Config, impersonate impersonate.Strategy, identity *impersonate.Identity) (conn net.Conn, err error)

DialTLSWithConfigImpersonate dials tls with impersonation

func (*Dialer) DialZTLS

func (d *Dialer) DialZTLS(ctx context.Context, network, address string) (conn net.Conn, err error)

DialZTLS with encrypted connection using ztls

func (*Dialer) DialZTLSWithConfig

func (d *Dialer) DialZTLSWithConfig(ctx context.Context, network, address string, config *ztls.Config) (conn net.Conn, err error)

DialZTLSWithConfig dials ztls with config

func (*Dialer) GetDNSData

func (d *Dialer) GetDNSData(hostname string) (*retryabledns.DNSData, error)

GetDNSData for the given hostname

func (*Dialer) GetDNSDataFromCache

func (d *Dialer) GetDNSDataFromCache(hostname string) (*retryabledns.DNSData, error)

GetDNSDataFromCache cached by the resolver

func (*Dialer) GetDialedIP

func (d *Dialer) GetDialedIP(hostname string) string

GetDialedIP returns the ip dialed by the HTTP client

func (*Dialer) GetTLSData

func (d *Dialer) GetTLSData(hostname string) (*cryptoutil.TLSData, error)

GetTLSData returns the tls data for a hostname

type DiskDBType

type DiskDBType uint8
const (
	LevelDB DiskDBType = iota
	Pogreb
)

type Options

type Options struct {
	BaseResolvers       []string
	MaxRetries          int
	HostsFile           bool
	ResolversFile       bool
	EnableFallback      bool
	Allow               []string
	Deny                []string
	CacheType           CacheType
	CacheMemoryMaxItems int // used by Memory cache type
	DiskDbType          DiskDBType
	WithDialerHistory   bool
	WithCleanup         bool
	WithTLSData         bool
	DialerTimeout       time.Duration
	DialerKeepAlive     time.Duration
	Dialer              *net.Dialer
	ProxyDialer         *proxy.Dialer
	WithZTLS            bool
	SNIName             string
	OnDialCallback      func(hostname, IP string)
	DisableZtlsFallback bool
}

Directories

Path Synopsis
ja3
ja3 is a package for creating JA3 fingerprints from TLS clients.
ja3 is a package for creating JA3 fingerprints from TLS clients.
impersonate
impersonate package contains strategy to impersonate a client and define an alias for the internal client tls spefications
impersonate package contains strategy to impersonate a client and define an alias for the internal client tls spefications

Jump to

Keyboard shortcuts

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