utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Socks4CmdConnect = 0x01
	Socks4CmdBind    = 0x02
)

SOCKS4 command codes

View Source
const (
	Socks4StatusGranted          = 0x5A
	Socks4StatusRejected         = 0x5B
	Socks4StatusNoIdentd         = 0x5C
	Socks4StatusIdentdAuthFailed = 0x5D
)

SOCKS4 response codes

Variables

This section is empty.

Functions

func GetJSONKeyOrder

func GetJSONKeyOrder(jsonStr string) ([]string, error)

GetJSONKeyOrder extracts the order of keys from a JSON string

func GetJSONKeyOrderSimple

func GetJSONKeyOrderSimple(jsonStr string) ([]string, error)

Alternative simpler approach using a different method

func ValidateHTTP1HeaderOrder

func ValidateHTTP1HeaderOrder(expectedOrder []string, actualHeaders []string) error

ValidateHTTP1HeaderOrder validates header order for HTTP/1.1 responses expectedOrder contains the expected order of headers (case-insensitive) actualHeaders contains the actual headers from the response

func ValidateHTTP2HeaderOrder

func ValidateHTTP2HeaderOrder(expectedOrder []string, peetResponse *PeetResponse) error

ValidateHTTP2HeaderOrder validates header order for HTTP/2 responses expectedOrder contains the expected order of headers (case-insensitive) peetResponse contains the parsed response from tls.peet.ws

func ValidateHTTP3HeaderOrder

func ValidateHTTP3HeaderOrder(expectedOrder []string, impersonateResponse *ImpersonateResponse) error

ValidateHTTP3HeaderOrder validates header order for HTTP/3 responses expectedOrder contains the expected order of headers (case-insensitive) impersonateResponse contains the parsed response from fp.impersonate.pro

Types

type ImpersonateResponse

type ImpersonateResponse struct {
	Http3 struct {
		PerkText string `json:"perk_text"`
		PerkHash string `json:"perk_hash"`
		Settings []struct {
			Id    int    `json:"id"`
			Name  string `json:"name"`
			Value int    `json:"value"`
		} `json:"settings"`
		Headers *OrderedMap `json:"headers"`
	} `json:"http3"`
	Tls struct {
		CipherSuites []struct {
			Name  string `json:"name"`
			Value int    `json:"value"`
		} `json:"cipher_suites"`
		Extensions []struct {
			Id   int         `json:"id"`
			Name string      `json:"name"`
			Data interface{} `json:"data,omitempty"`
		} `json:"extensions"`
	} `json:"tls"`
}

type OrderedMap

type OrderedMap struct {
	Keys   []string
	Values map[string]interface{}
}

OrderedMap preserves the order of JSON keys during unmarshaling

func (*OrderedMap) UnmarshalJSON

func (om *OrderedMap) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling to preserve key order

type PeetResponse

type PeetResponse struct {
	Donate      string `json:"donate"`
	Ip          string `json:"ip"`
	HttpVersion string `json:"http_version"`
	Method      string `json:"method"`
	UserAgent   string `json:"user_agent,omitempty"`
	Tls         struct {
		Ciphers              []string `json:"ciphers"`
		Extensions           []any    `json:"extensions"`
		TlsVersionRecord     string   `json:"tls_version_record"`
		TlsVersionNegotiated string   `json:"tls_version_negotiated"`
		Ja3                  string   `json:"ja3"`
		Ja3Hash              string   `json:"ja3_hash"`
		Ja4                  string   `json:"ja4"`
		Ja4R                 string   `json:"ja4_r"`
		Peetprint            string   `json:"peetprint"`
		PeetprintHash        string   `json:"peetprint_hash"`
		ClientRandom         string   `json:"client_random"`
		SessionId            string   `json:"session_id"`
	} `json:"tls"`
	Http2 struct {
		AkamaiFingerprint     string `json:"akamai_fingerprint"`
		AkamaiFingerprintHash string `json:"akamai_fingerprint_hash"`
		SentFrames            []struct {
			FrameType string   `json:"frame_type"`
			Length    int      `json:"length"`
			Settings  []string `json:"settings,omitempty"`
			Increment int      `json:"increment,omitempty"`
			StreamId  int      `json:"stream_id,omitempty"`
			Headers   []string `json:"headers,omitempty"`
			Flags     []string `json:"flags,omitempty"`
			Priority  struct {
				Weight    int `json:"weight"`
				DependsOn int `json:"depends_on"`
				Exclusive int `json:"exclusive"`
			} `json:"priority,omitempty"`
		} `json:"sent_frames"`
	} `json:"http2,omitempty"`
	Tcpip struct {
		Ip struct {
		} `json:"ip"`
		Tcp struct {
		} `json:"tcp"`
	} `json:"tcpip"`
	Http1 struct {
		Headers []string `json:"headers"`
	} `json:"http1,omitempty"`
}

type Socks4ProxyServer

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

Socks4ProxyServer implements a simple SOCKS4 proxy server for testing

func NewSocks4ProxyServer

func NewSocks4ProxyServer(host string, port int) *Socks4ProxyServer

NewSocks4ProxyServer creates a new SOCKS4 proxy server

func StartSocks4ProxyServer

func StartSocks4ProxyServer(host string, port int) (*Socks4ProxyServer, string, error)

StartSocks4ProxyServer is a convenience function to start a SOCKS4 proxy server Returns the server instance and the actual address it's listening on

func StartSocks4ProxyServerOnRandomPort

func StartSocks4ProxyServerOnRandomPort() (*Socks4ProxyServer, string, error)

StartSocks4ProxyServerOnRandomPort starts a SOCKS4 proxy server on a random available port Returns the server instance and the actual address it's listening on

func (*Socks4ProxyServer) GetAddress

func (s *Socks4ProxyServer) GetAddress() string

GetAddress returns the address the server is listening on

func (*Socks4ProxyServer) GetPort

func (s *Socks4ProxyServer) GetPort() int

GetPort returns the port number the server is listening on

func (*Socks4ProxyServer) Start

func (s *Socks4ProxyServer) Start() error

Start starts the SOCKS4 proxy server

func (*Socks4ProxyServer) Stop

func (s *Socks4ProxyServer) Stop() error

Stop stops the SOCKS4 proxy server

type Socks4Request

type Socks4Request struct {
	Version byte
	Command byte
	DstPort uint16
	DstIP   net.IP
	UserID  string
}

Socks4Request represents a SOCKS4 request

type Socks4Response

type Socks4Response struct {
	Version byte
	Status  byte
	DstPort uint16
	DstIP   net.IP
}

Socks4Response represents a SOCKS4 response

Jump to

Keyboard shortcuts

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