proxy

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSRServer = iota
	SSRPort
	SSRProtocol
	SSRCipher
	SSROBFS
	SSRSuffix
)

Variables

View Source
var (
	ErrorNotVmessLink          = errors.New("not a correct vmess link")
	ErrorVmessPayloadParseFail = errors.New("vmess link payload parse failed")
)
View Source
var (
	// ErrorNotSSLink is an error type
	ErrorNotSSLink = errors.New("not a correct ss link")
)
View Source
var (
	ErrorNotSSRLink = errors.New("not a correct ssr link")
)
View Source
var (
	ErrorNotTrojanink = errors.New("not a correct trojan link")
)

Functions

func ParseProxyToClash

func ParseProxyToClash(content string) (string, error)

Types

type Base

type Base struct {
	Name    string      `yaml:"name" json:"name,omitempty"`
	Server  string      `yaml:"server" json:"server,omitempty"`
	Path    string      `yaml:"path" json:"path,omitempty,omitempty"`
	Type    string      `yaml:"type" json:"type,omitempty"`
	Country string      `yaml:"country,omitempty" json:"country,omitempty"`
	Emoji   string      `yaml:"emoji" json:"emoji,omitempty"`
	Port    interface{} `yaml:"port" json:"port,omitempty" `
	UDP     bool        `yaml:"udp,omitempty" json:"udp,omitempty"`
	Useable bool        `yaml:"useable,omitempty" json:"useable,omitempty"`
}

Base implements interface Proxy. It's the basic proxy struct. Vmess etc extends Base

func (*Base) AddToName

func (b *Base) AddToName(name string)

func (*Base) BaseInfo

func (b *Base) BaseInfo() *Base

func (*Base) Clone

func (b *Base) Clone() Base

func (*Base) GetCountry

func (b *Base) GetCountry() string

func (*Base) GetServer

func (b *Base) GetServer() string

func (*Base) GetUrl

func (b *Base) GetUrl() string

func (*Base) SetCountry

func (b *Base) SetCountry(country string)

func (*Base) SetEmoji

func (b *Base) SetEmoji(emoji string)

func (*Base) SetIP

func (b *Base) SetIP(ip string)

func (*Base) SetName

func (b *Base) SetName(name string)

func (*Base) SetUseable

func (b *Base) SetUseable(useable bool)

func (*Base) TypeName

func (b *Base) TypeName() string

type Clash

type Clash struct {
	Port      int `yaml:"port"`
	SocksPort int `yaml:"socks-port"`
	// RedirPort          int                      `yaml:"redir-port"`
	// Authentication     []string                 `yaml:"authentication"`
	AllowLan           bool   `yaml:"allow-lan"`
	Mode               string `yaml:"mode"`
	LogLevel           string `yaml:"log-level"`
	ExternalController string `yaml:"external-controller"`
	// ExternalUI         string                   `yaml:"external-ui"`
	// Secret             string                   `yaml:"secret"`
	// Experimental       map[string]interface{} 	`yaml:"experimental"`
	Proxy             []map[string]interface{} `yaml:"proxies"`
	ProxyGroup        []map[string]interface{} `yaml:"proxy-groups"`
	Rule              []string                 `yaml:"rules"`
	CFWByPass         []string                 `yaml:"cfw-bypass"`
	CFWLatencyTimeout int                      `yaml:"cfw-latency-timeout"`
}

type ClashRSSR

type ClashRSSR struct {
	Base
	Password      string `json:"password"`
	Cipher        string `json:"cipher"`
	Protocol      string `json:"protocol"`
	ProtocolParam string `json:"protocol-param"`
	OBFS          string `json:"obfs"`
	OBFSParam     string `json:"obfs-param"`
}
func ParseSSRLink(link string) (*ClashRSSR, error)

func (ClashRSSR) Clone

func (ssr ClashRSSR) Clone() Proxy

func (ClashRSSR) String

func (ssr ClashRSSR) String() string

func (ClashRSSR) ToClash

func (ssr ClashRSSR) ToClash() string

func (ClashRSSR) ToSurge

func (ssr ClashRSSR) ToSurge() string

type ClashSS

type ClashSS struct {
	Base
	Password   string     `json:"password"`
	Cipher     string     `json:"cipher"`
	Plugin     string     `json:"plugin"`
	PluginOpts PluginOpts `json:"plugin-opts"`
}
func ParseSSLink(link string) (*ClashSS, error)

ParseSSLink ParseSSLink() parses an ss link to ss proxy

func (ClashSS) Clone

func (ss ClashSS) Clone() Proxy
func (ss ClashSS) Link() (link string)

Link https://shadowsocks.org/en/config/quick-guide.html Link converts a ss proxy to string

func (ClashSS) String

func (ss ClashSS) String() string

func (ClashSS) ToClash

func (ss ClashSS) ToClash() string

ToClash converts proxy to clash proxy string

func (ClashSS) ToSurge

func (ss ClashSS) ToSurge() string

ToSurge converts proxy to surge proxy string

type ClashVmess

type ClashVmess struct {
	Base
	UUID           string            `json:"uuid,omitempty"`
	AlterID        interface{}       `json:"alterId,omitempty"`
	Cipher         string            `json:"cipher,omitempty"`
	TLS            bool              `json:"tls,omitempty"`
	Network        string            `json:"network,omitempty"`
	WSPATH         string            `json:"ws-path,omitempty"`
	WSHeaders      map[string]string `json:"ws-headers,omitempty"`
	SkipCertVerify bool              `json:"skip-cert-verify,omitempty"`
	HTTPOpts       *HTTPOptions      `yaml:"http-opts,omitempty" json:"http-opts,omitempty"`
	HTTP2Opts      *HTTP2Options     `yaml:"h2-opts,omitempty" json:"h2-opts,omitempty"`
	ServerName     string            `yaml:"servername,omitempty" json:"servername,omitempty"`
}
func ParseVmessLink(link string) (*ClashVmess, error)

func (ClashVmess) Clone

func (v ClashVmess) Clone() Proxy
func (v ClashVmess) Link() (link string)

func (ClashVmess) String

func (v ClashVmess) String() string

func (ClashVmess) ToClash

func (v ClashVmess) ToClash() string

func (ClashVmess) ToSurge

func (v ClashVmess) ToSurge() string

type HTTP2Options

type HTTP2Options struct {
	Host []string `yaml:"host,omitempty" json:"host,omitempty"`
	Path string   `yaml:"path,omitempty" json:"path,omitempty"` // 暂只处理一个Path
}

type HTTPOptions

type HTTPOptions struct {
	Method  string              `yaml:"method,omitempty" json:"method,omitempty"`
	Path    []string            `yaml:"path,omitempty" json:"path,omitempty"`
	Headers map[string][]string `yaml:"headers,omitempty" json:"headers,omitempty"`
}

type Http

type Http struct {
	Base
	Username string `json:"username"`
	Password string `json:"password"`
	Tls      bool   `json:"tls"`
}
func ParseHttpLink(link string) (*Http, error)
func ParseSocketLink(link string) (*Http, error)

func (Http) Clone

func (h Http) Clone() Proxy
func (h Http) Link() string

func (Http) String

func (h Http) String() string

func (Http) ToClash

func (h Http) ToClash() string

func (Http) ToSurge

func (h Http) ToSurge() string

type PluginOpts

type PluginOpts struct {
	Mode string `json:"mode"`
	Host string `json:"host"`
	Tls  bool   `json:"Tls"`
}

type Proxy

type Proxy interface {
	String() string
	ToClash() string
	ToSurge() string
	Link() string
	SetName(name string)
	AddToName(name string)
	SetIP(ip string)
	TypeName() string //ss ssr vmess trojan
	BaseInfo() *Base
	Clone() Proxy
	SetUseable(useable bool)
	SetCountry(country string)
	GetCountry() string
	SetEmoji(emoji string)
}

func ParseProxy

func ParseProxy(content string) (p Proxy, err error)

func ParseProxyFromClashProxy

func ParseProxyFromClashProxy(p map[string]interface{}) (proxy Proxy, err error)

type SSD

type SSD struct {
	Airport      string  `json:"airport"`
	Port         int     `json:"port"`
	Encryption   string  `json:"encryption"`
	Password     string  `json:"password"`
	TrafficUsed  float64 `json:"traffic_used"`
	TrafficTotal float64 `json:"traffic_total"`
	Expiry       string  `json:"expiry"`
	URL          string  `json:"url"`
	Servers      []struct {
		ID            int     `json:"id"`
		Server        string  `json:"server"`
		Ratio         float64 `json:"ratio"`
		Remarks       string  `json:"remarks"`
		Port          string  `json:"port"`
		Encryption    string  `json:"encryption"`
		Password      string  `json:"password"`
		Plugin        string  `json:"plugin"`
		PluginOptions string  `json:"plugin_options"`
	} `json:"servers"`
}

type Socket

type Socket struct {
	Base
	Username string `json:"username"`
	Password string `json:"password"`
}

func (Socket) Clone

func (s Socket) Clone() Proxy
func (s Socket) Link() string

func (Socket) String

func (s Socket) String() string

func (Socket) ToClash

func (s Socket) ToClash() string

func (Socket) ToSurge

func (s Socket) ToSurge() string

type Trojan

type Trojan struct {
	Base
	Password       string   `json:"password"`
	Sni            string   `json:"sni,omitempty"`
	ALPN           []string `yaml:"alpn,omitempty" json:"alpn,omitempty"`
	SkipCertVerify bool     `yaml:"skip-cert-verify,omitempty" json:"skip-cert-verify,omitempty"`
}
func ParseTrojanLink(link string) (*Trojan, error)

func (Trojan) Clone

func (t Trojan) Clone() Proxy

func (Trojan) String

func (t Trojan) String() string

func (Trojan) ToClash

func (t Trojan) ToClash() string

func (Trojan) ToSurge

func (t Trojan) ToSurge() string

type Vmess

type Vmess struct {
	Add  string      `json:"add"`
	Aid  interface{} `json:"aid"`
	Host string      `json:"host"`
	ID   string      `json:"id"`
	Net  string      `json:"net"`
	Path string      `json:"path"`
	Port interface{} `json:"port"`
	PS   string      `json:"ps"`
	TLS  string      `json:"tls"`
	Type string      `json:"type"`
	V    interface{} `json:"v"`
}

Jump to

Keyboard shortcuts

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