network

package
v0.0.0-...-a618c29 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SOCKS4 = iota
	SOCKS4A
)

Variables

This section is empty.

Functions

func DeleteFile

func DeleteFile(filePath string) error

func Dialer

func Dialer(protocol int, proxyAddr, userID string, timeout time.Duration) func(string, string) (net.Conn, error)

func FasthttpDialer

func FasthttpDialer(protocol int, proxyAddr, userID string, timeout time.Duration) func(string) (net.Conn, error)

func GetCookies

func GetCookies(u string) ([]*http.Cookie, error)

func Init

func Init()

func PrepareProxy

func PrepareProxy(option *RequestOptions, targetURL string) (*fasthttp.Client, error)

func Proxy

func Proxy(ctx *fasthttp.RequestCtx)

func ReadAll

func ReadAll(res *fasthttp.Response) ([]byte, error)

ReadAll reads the entire response body and returns it as a byte slice.

func SaveFile

func SaveFile(filePath string, data *[]byte) error

func SetCookiesString

func SetCookiesString(u string, cookies []string) error

func TouchFile

func TouchFile(filePath string) (*os.File, error)

Types

type RequestOptions

type RequestOptions struct {
	Headers        map[string]string `json:"headers"`
	Method         string            `json:"method"`
	ProxyHost      string            `json:"proxy_host"`
	ProxyScheme    string            `json:"proxy_scheme"`
	ProxyUserName  string            `json:"proxy_username"`
	ProxyPassword  string            `json:"proxy_password"`
	RequestBody    string            `json:"request_body"`
	RequestBodyRaw []byte            `json:"request_body_raw"`
	Timeout        int               `json:"timeout"`
	TlsSpoofConfig cycletls.Options  `json:"tls_spoof_config"`
}

type Response

type Response[T StringOrBytes] struct {
	Res  *fasthttp.Response
	Body T
}

func Request

func Request[T StringOrBytes](url string, option *RequestOptions, readPreference func(*fasthttp.Response) ([]byte, error)) (Response[T], error)

Request makes an HTTP request and returns the response as type T.

Parameters:

url:           The URL to send the request to.
option:        Pointer to RequestOptions struct containing headers, method, proxy, etc.
readPreference: Function to read and process the response body (e.g., io.ReadAll,io.Read,).

Returns:

The response body as type T (string or []byte), and an error if any occurred.

type StringOrBytes

type StringOrBytes interface {
	~string | ~[]byte
}

Jump to

Keyboard shortcuts

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