tls_client_cffi_src

package
v0.0.0-...-c37103c Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: BSD-4-Clause Imports: 16 Imported by: 0

Documentation

Overview

tls_client_cffi_src provides and manages a CFFI (C Foreign Function Interface) which allows code in other languages to interact with the module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildResponse

func BuildResponse(sessionId string, withSession bool, resp *http.Response, cookies []*http.Cookie, input RequestInput) (Response, *TLSClientError)

BuildResponse constructs a client response from a given HTTP response. The client response can then be sent to the interface consumer.

func ClearSessionCache

func ClearSessionCache()

ClearSessionCache empties the client session storage.

func GetClient

func GetClient(sessionId string) (tls_client.HttpClient, error)

GetClient returns the client with the given sessionId from the client session storage. If there is no client with the given sessionId, it returns an error.

func RemoveSession

func RemoveSession(sessionId string)

RemoveSession deletes the client with the given sessionId from the client session storage.

Types

type AddCookiesToSessionInput

type AddCookiesToSessionInput struct {
	SessionId string   `json:"sessionId"`
	Url       string   `json:"url"`
	Cookies   []Cookie `json:"cookies"`
}

type CandidateCipherSuite

type CandidateCipherSuite struct {
	KdfId  string `json:"kdfId"`
	AeadId string `json:"aeadId"`
}

type CandidateCipherSuites

type CandidateCipherSuites []CandidateCipherSuite

func (CandidateCipherSuites) Translate

type Cookie struct {
	Expires  Timestamp `json:"expires"`
	Domain   string    `json:"domain"`
	Name     string    `json:"name"`
	Path     string    `json:"path"`
	Value    string    `json:"value"`
	MaxAge   int       `json:"maxAge"`
	Secure   bool      `json:"secure"`
	HttpOnly bool      `json:"httpOnly"`
}

type CookiesFromSessionOutput

type CookiesFromSessionOutput struct {
	Id      string   `json:"id"`
	Cookies []Cookie `json:"cookies"`
}

type CustomTlsClient

type CustomTlsClient struct {
	H2Settings                              map[string]uint32     `json:"h2Settings"`
	HeaderPriority                          *PriorityParam        `json:"headerPriority"`
	CertCompressionAlgo                     string                `json:"certCompressionAlgo"`
	Ja3String                               string                `json:"ja3String"`
	H2SettingsOrder                         []string              `json:"h2SettingsOrder"`
	KeyShareCurves                          []string              `json:"keyShareCurves"`
	ALPNProtocols                           []string              `json:"alpnProtocols"`
	ALPSProtocols                           []string              `json:"alpsProtocols"`
	ECHCandidatePayloads                    []uint16              `json:"ECHCandidatePayloads"`
	ECHCandidateCipherSuites                CandidateCipherSuites `json:"ECHCandidateCipherSuites"`
	PriorityFrames                          []PriorityFrames      `json:"priorityFrames"`
	PseudoHeaderOrder                       []string              `json:"pseudoHeaderOrder"`
	SupportedDelegatedCredentialsAlgorithms []string              `json:"supportedDelegatedCredentialsAlgorithms"`
	SupportedSignatureAlgorithms            []string              `json:"supportedSignatureAlgorithms"`
	SupportedVersions                       []string              `json:"supportedVersions"`
	ConnectionFlow                          uint32                `json:"connectionFlow"`
}

CustomTlsClient contains custom TLS specifications to construct a client from.

type DestroyOutput

type DestroyOutput struct {
	Id      string `json:"id"`
	Success bool   `json:"success"`
}

type DestroySessionInput

type DestroySessionInput struct {
	SessionId string `json:"sessionId"`
}

type GetCookiesFromSessionInput

type GetCookiesFromSessionInput struct {
	SessionId string `json:"sessionId"`
	Url       string `json:"url"`
}

type PriorityFrames

type PriorityFrames struct {
	PriorityParam PriorityParam `json:"priorityParam"`
	StreamID      uint32        `json:"streamID"`
}

type PriorityParam

type PriorityParam struct {
	StreamDep uint32 `json:"streamDep"`
	Exclusive bool   `json:"exclusive"`
	Weight    uint8  `json:"weight"`
}

type RequestInput

type RequestInput struct {
	CertificatePinningHosts     map[string][]string `json:"certificatePinningHosts"`
	CustomTlsClient             *CustomTlsClient    `json:"customTlsClient"`
	TransportOptions            *TransportOptions   `json:"transportOptions"`
	Headers                     map[string]string   `json:"headers"`
	DefaultHeaders              map[string][]string `json:"defaultHeaders"`
	ConnectHeaders              map[string][]string `json:"connectHeaders"`
	LocalAddress                *string             `json:"localAddress"`
	ServerNameOverwrite         *string             `json:"serverNameOverwrite"`
	ProxyUrl                    *string             `json:"proxyUrl"`
	RequestBody                 *string             `json:"requestBody"`
	RequestHostOverride         *string             `json:"requestHostOverride"`
	SessionId                   *string             `json:"sessionId"`
	StreamOutputBlockSize       *int                `json:"streamOutputBlockSize"`
	StreamOutputEOFSymbol       *string             `json:"streamOutputEOFSymbol"`
	StreamOutputPath            *string             `json:"streamOutputPath"`
	RequestMethod               string              `json:"requestMethod"`
	RequestUrl                  string              `json:"requestUrl"`
	TLSClientIdentifier         string              `json:"tlsClientIdentifier"`
	HeaderOrder                 []string            `json:"headerOrder"`
	RequestCookies              []Cookie            `json:"requestCookies"`
	TimeoutMilliseconds         int                 `json:"timeoutMilliseconds"`
	TimeoutSeconds              int                 `json:"timeoutSeconds"`
	CatchPanics                 bool                `json:"catchPanics"`
	FollowRedirects             bool                `json:"followRedirects"`
	ForceHttp1                  bool                `json:"forceHttp1"`
	InsecureSkipVerify          bool                `json:"insecureSkipVerify"`
	IsByteRequest               bool                `json:"isByteRequest"`
	IsByteResponse              bool                `json:"isByteResponse"`
	IsRotatingProxy             bool                `json:"isRotatingProxy"`
	DisableIPV6                 bool                `json:"disableIPV6"`
	DisableIPV4                 bool                `json:"disableIPV4"`
	WithDebug                   bool                `json:"withDebug"`
	WithDefaultCookieJar        bool                `json:"withDefaultCookieJar"`
	WithoutCookieJar            bool                `json:"withoutCookieJar"`
	WithRandomTLSExtensionOrder bool                `json:"withRandomTLSExtensionOrder"`
}

RequestInput is the data a Python client can construct a client and request from.

type Response

type Response struct {
	Cookies      map[string]string   `json:"cookies"`
	Headers      map[string][]string `json:"headers"`
	Id           string              `json:"id"`
	Body         string              `json:"body"`
	SessionId    string              `json:"sessionId,omitempty"`
	Target       string              `json:"target"`
	UsedProtocol string              `json:"usedProtocol"`
	Status       int                 `json:"status"`
}

Response is the response that is sent back to the Python client.

type TLSClientError

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

func BuildRequest

func BuildRequest(input RequestInput) (*http.Request, *TLSClientError)

BuildRequest constructs a HTTP request from a given RequestInput.

func CreateClient

func CreateClient(requestInput RequestInput) (client tls_client.HttpClient, sessionID string, withSession bool, clientErr *TLSClientError)

CreateClient creates a new client from a given RequestInput.

The RequestInput should only contain a TLSClientIdentifier or a CustomTlsClient. If both are provided, an error will be returned.

func NewTLSClientError

func NewTLSClientError(err error) *TLSClientError

func (*TLSClientError) Error

func (e *TLSClientError) Error() string

type Timestamp

type Timestamp struct {
	time.Time
}

func (*Timestamp) MarshalJSON

func (p *Timestamp) MarshalJSON() ([]byte, error)

func (*Timestamp) UnmarshalJSON

func (p *Timestamp) UnmarshalJSON(bytes []byte) error

type TransportOptions

type TransportOptions struct {
	// IdleConnTimeout is the maximum amount of time an idle (keep-alive)
	// connection will remain idle before closing itself. Zero means no limit.
	IdleConnTimeout        *time.Duration `json:"idleConnTimeout"`
	MaxIdleConns           int            `json:"maxIdleConns"`
	MaxIdleConnsPerHost    int            `json:"maxIdleConnsPerHost"`
	MaxConnsPerHost        int            `json:"maxConnsPerHost"`
	MaxResponseHeaderBytes int64          `json:"maxResponseHeaderBytes"` // Zero means to use a default limit.
	WriteBufferSize        int            `json:"writeBufferSize"`        // If zero, a default (currently 4KB) is used.
	ReadBufferSize         int            `json:"readBufferSize"`         // If zero, a default (currently 4KB) is used.
	DisableKeepAlives      bool           `json:"disableKeepAlives"`
	DisableCompression     bool           `json:"disableCompression"`
}

TransportOptions contains settings for the underlying http transport of the tls client

Jump to

Keyboard shortcuts

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