tls

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ForceALPN_TRANSPORT_PREFERENCE_TAKE_PRIORITY = tlspb.ForceALPN_TRANSPORT_PREFERENCE_TAKE_PRIORITY
	ForceALPN_NO_ALPN                            = tlspb.ForceALPN_NO_ALPN
	ForceALPN_UTLS_PRESET                        = tlspb.ForceALPN_UTLS_PRESET
)

Variables

View Source
var ErrInvalidLen = errors.New("goech: invalid length")
View Source
var ModernFingerprints = map[string]*utls.ClientHelloID{

	"hellofirefox_99":         &utls.HelloFirefox_99,
	"hellofirefox_102":        &utls.HelloFirefox_102,
	"hellofirefox_105":        &utls.HelloFirefox_105,
	"hellofirefox_120":        &utls.HelloFirefox_120,
	"hellochrome_83":          &utls.HelloChrome_83,
	"hellochrome_87":          &utls.HelloChrome_87,
	"hellochrome_96":          &utls.HelloChrome_96,
	"hellochrome_100":         &utls.HelloChrome_100,
	"hellochrome_102":         &utls.HelloChrome_102,
	"hellochrome_106_shuffle": &utls.HelloChrome_106_Shuffle,
	"hellochrome_120":         &utls.HelloChrome_120,
	"hellochrome_131":         &utls.HelloChrome_131,
	"helloios_13":             &utls.HelloIOS_13,
	"helloios_14":             &utls.HelloIOS_14,
	"helloedge_85":            &utls.HelloEdge_85,
	"helloedge_106":           &utls.HelloEdge_106,
	"hellosafari_16_0":        &utls.HelloSafari_16_0,
	"hello360_11_0":           &utls.Hello360_11_0,
	"helloqq_11_1":            &utls.HelloQQ_11_1,
}
View Source
var OtherFingerprints = map[string]*utls.ClientHelloID{

	"hellogolang":            &utls.HelloGolang,
	"hellorandomized":        &utls.HelloRandomized,
	"hellorandomizedalpn":    &utls.HelloRandomizedALPN,
	"hellorandomizednoalpn":  &utls.HelloRandomizedNoALPN,
	"hellofirefox_auto":      &utls.HelloFirefox_Auto,
	"hellofirefox_55":        &utls.HelloFirefox_55,
	"hellofirefox_56":        &utls.HelloFirefox_56,
	"hellofirefox_63":        &utls.HelloFirefox_63,
	"hellofirefox_65":        &utls.HelloFirefox_65,
	"hellochrome_auto":       &utls.HelloChrome_Auto,
	"hellochrome_58":         &utls.HelloChrome_58,
	"hellochrome_62":         &utls.HelloChrome_62,
	"hellochrome_70":         &utls.HelloChrome_70,
	"hellochrome_72":         &utls.HelloChrome_72,
	"helloios_auto":          &utls.HelloIOS_Auto,
	"helloios_11_1":          &utls.HelloIOS_11_1,
	"helloios_12_1":          &utls.HelloIOS_12_1,
	"helloandroid_11_okhttp": &utls.HelloAndroid_11_OkHttp,
	"helloedge_auto":         &utls.HelloEdge_Auto,
	"hellosafari_auto":       &utls.HelloSafari_Auto,
	"hello360_auto":          &utls.Hello360_Auto,
	"hello360_7_5":           &utls.Hello360_7_5,
	"helloqq_auto":           &utls.HelloQQ_Auto,

	"hellochrome_100_psk":              &utls.HelloChrome_100_PSK,
	"hellochrome_112_psk_shuf":         &utls.HelloChrome_112_PSK_Shuf,
	"hellochrome_114_padding_psk_shuf": &utls.HelloChrome_114_Padding_PSK_Shuf,
	"hellochrome_115_pq":               &utls.HelloChrome_115_PQ,
	"hellochrome_115_pq_psk":           &utls.HelloChrome_115_PQ_PSK,
	"hellochrome_120_pq":               &utls.HelloChrome_120_PQ,
}
View Source
var PresetFingerprints = map[string]*utls.ClientHelloID{

	"chrome":           &utls.HelloChrome_Auto,
	"firefox":          &utls.HelloFirefox_Auto,
	"safari":           &utls.HelloSafari_Auto,
	"ios":              &utls.HelloIOS_Auto,
	"android":          &utls.HelloAndroid_11_OkHttp,
	"edge":             &utls.HelloEdge_Auto,
	"360":              &utls.Hello360_Auto,
	"qq":               &utls.HelloQQ_Auto,
	"random":           nil,
	"randomized":       nil,
	"randomizednoalpn": nil,
	"unsafe":           nil,
}

Functions

func BuildCertificates

func BuildCertificates(certConfigs []*Certificate) ([]tls.Certificate, error)

func CalculatePEMCertChainSHA256Hash

func CalculatePEMCertChainSHA256Hash(certContent []byte) string

func CertsToCertPool

func CertsToCertPool(certs [][]byte) (*x509.CertPool, error)

func ConvertToGoECHKeys

func ConvertToGoECHKeys(data []byte) ([]tls.EncryptedClientHelloKey, error)

func GenerateCertChainHash

func GenerateCertChainHash(rawCerts [][]byte) []byte

func GetFingerprint

func GetFingerprint(name string) (fingerprint *utls.ClientHelloID, found bool)

func GetTLSConfig added in v1.1.2

func GetTLSConfig(c *TlsConfig, opts ...Option) (*tls.Config, error)

GetTLSConfig converts this Config into tls.Config.

func GetUClient added in v1.1.2

func GetUClient(c *TlsConfig, conn net.Conn, tlsConfig *tls.Config) (net.Conn, error)

func VerifyPeerCert added in v1.1.2

func VerifyPeerCert(c *TlsConfig) func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error

Types

type Certificate

type Certificate = tlspb.Certificate

func ParseCertificate

func ParseCertificate(c *cert.Certificate) *Certificate

ParseCertificate converts a cert.Certificate to Certificate.

type Conn

type Conn struct {
	*tls.Conn
}

a wrapper of tls.Conn

func (*Conn) GetConnectionApplicationProtocol

func (c *Conn) GetConnectionApplicationProtocol() (string, error)

func (*Conn) HandshakeAddress

func (c *Conn) HandshakeAddress() net.Address

type Engine

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

func NewEngine

func NewEngine(config EngineConfig) (*Engine, error)

TODO: prebuild tls.Config

func (*Engine) ApplyECH

func (e *Engine) ApplyECH(config *tls.Config)

func (*Engine) GetClientConn

func (c *Engine) GetClientConn(conn net.Conn, opts ...security.Option) (net.Conn, error)

func (*Engine) GetTLSConfig

func (c *Engine) GetTLSConfig(opts ...security.Option) *tls.Config

type EngineConfig

type EngineConfig struct {
	Config    *TlsConfig
	DnsServer i.ECHResolver
}

type Option

type Option func(*tls.Config)

func WithDestination

func WithDestination(dest net.Destination) Option

if c.ServerName has been specified, dont apply dest as ServerName

func WithNextProtocol

func WithNextProtocol(protos []string) Option

type TlsConfig

type TlsConfig = tlspb.TlsConfig

type UConn

type UConn struct {
	*utls.UConn
}

func (UConn) GetConnectionApplicationProtocol

func (u UConn) GetConnectionApplicationProtocol() (string, error)

Jump to

Keyboard shortcuts

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