internal

package
v0.0.0-...-fcff509 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxSchemeLength defines the maximum allowed length for proxy scheme.
	// Legitimate proxy protocols (http, https, socks4, socks5, vmess, trojan, vless, ss, ssr, hy, hy2)
	// are all 6 characters or less. 15 provides safe headroom for future protocols.
	MaxSchemeLength = 15
)

Variables

View Source
var (
	Parsers = map[string]Parser{}

	ErrInvalidProxy = errors.New("gfp: invalid proxy")
)
View Source
var (
	Transformers = map[string]Transformer{}
)

Functions

func Fetch

func Fetch(proto, src string, transformer Transformer, parser Parser) int

func FromBase64

func FromBase64(buf []byte) []byte

func FromClash

func FromClash(buf []byte) []byte

FromClash parses a Clash YAML config and extracts proxy URLs.

func FromRaw

func FromRaw(buf []byte) []byte

func IsLocal

func IsLocal(ip string) bool

func Load

func Load(proto string, content []byte) error

func RegisterParser

func RegisterParser(name string, parser Parser)

func RegisterTransformer

func RegisterTransformer(name string, t Transformer)

func Save

func Save(it *Proxy)

func WriteTo

func WriteTo(dir string)

func WriteTotalAndUpdateReadme

func WriteTotalAndUpdateReadme(dir string, counters map[string]int)

Types

type ClashConfig

type ClashConfig struct {
	Proxies []ClashProxy `yaml:"proxies"`
}

ClashConfig represents a Clash YAML configuration.

type ClashGRPCOpts

type ClashGRPCOpts struct {
	ServiceName string `yaml:"grpc-service-name,omitempty"`
}

ClashGRPCOpts represents gRPC transport options.

type ClashH2Opts

type ClashH2Opts struct {
	Path string   `yaml:"path,omitempty"`
	Host []string `yaml:"host,omitempty"`
}

ClashH2Opts represents HTTP/2 transport options.

type ClashProxy

type ClashProxy struct {
	Name              string            `yaml:"name,omitempty"`
	Type              string            `yaml:"type"`
	Server            string            `yaml:"server"`
	Port              FlexPort          `yaml:"port"`
	Cipher            string            `yaml:"cipher,omitempty"`
	Password          string            `yaml:"password,omitempty"`
	Username          string            `yaml:"username,omitempty"`
	UUID              string            `yaml:"uuid,omitempty"`
	AlterID           int               `yaml:"alterId,omitempty"`
	Network           string            `yaml:"network,omitempty"`
	TLS               bool              `yaml:"tls,omitempty"`
	ServerName        string            `yaml:"servername,omitempty"`
	SNI               string            `yaml:"sni,omitempty"`
	Flow              string            `yaml:"flow,omitempty"`
	ClientFingerprint string            `yaml:"client-fingerprint,omitempty"`
	WSOpts            *ClashWSOpts      `yaml:"ws-opts,omitempty"`
	GRPCOpts          *ClashGRPCOpts    `yaml:"grpc-opts,omitempty"`
	H2Opts            *ClashH2Opts      `yaml:"h2-opts,omitempty"`
	RealityOpts       *ClashRealityOpts `yaml:"reality-opts,omitempty"`
}

ClashProxy represents a single proxy entry in a Clash config.

type ClashRealityOpts

type ClashRealityOpts struct {
	PublicKey string `yaml:"public-key,omitempty"`
	ShortID   string `yaml:"short-id,omitempty"`
}

ClashRealityOpts represents Reality TLS options.

type ClashWSHeaders

type ClashWSHeaders struct {
	Host string `yaml:"Host,omitempty"`
}

ClashWSHeaders represents WebSocket headers in Clash config.

type ClashWSOpts

type ClashWSOpts struct {
	Path    string         `yaml:"path,omitempty"`
	Headers ClashWSHeaders `yaml:"headers,omitempty"`
}

ClashWSOpts represents WebSocket transport options.

type FlexPort

type FlexPort int

FlexPort handles YAML port values that may be int, float, or string.

func (*FlexPort) UnmarshalYAML

func (p *FlexPort) UnmarshalYAML(value *yaml.Node) error

type Parser

type Parser func(string, string) (*Proxy, error)

func GetParser

func GetParser(name string) Parser

type Proxy

type Proxy struct {
	IP       string `json:"ip"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Passwd   string `json:"passwd"`
	Opaque   string `json:"opaque"`
	Protocol string `json:"protocol"`
}

func ParseColonURL

func ParseColonURL(proto, proxyURL string) (*Proxy, error)

func ParseProxyURL

func ParseProxyURL(proto, proxyURL string) (*Proxy, error)

func ParseSpaceURL

func ParseSpaceURL(proto, proxyURL string) (*Proxy, error)

func (*Proxy) String

func (p *Proxy) String() string

type Transformer

type Transformer func([]byte) []byte

func GetTransformer

func GetTransformer(name string) Transformer

Jump to

Keyboard shortcuts

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