config

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: GPL-3.0 Imports: 17 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotSSLink error = errors.New("not a shadowsocksR link")
)
View Source
var (
	NotSSRLink error = errors.New("not a shadowsocksR link")
)
View Source
var RegShadowrocketVmess = regexp.MustCompile(`(?i)vmess://(\S+?)@(\S+?):([0-9]{2,5})/?([?#][^\s]+)`)

Functions

func HttpLinkToHttpOption added in v0.12.0

func HttpLinkToHttpOption(link string) (*outbound.HttpOption, error)

func Link2Dialer

func Link2Dialer(link string) (outbound.Dialer, error)

func ParseProxy

func ParseProxy(mapping map[string]interface{}, namePrefix string) (string, error)

func RawConfigToVmessOption

func RawConfigToVmessOption(config *RawConfig) (*outbound.VmessOption, error)

func SSLinkToSSOption

func SSLinkToSSOption(link1 string) (*outbound.ShadowSocksOption, error)

func SSRLinkToSSROption

func SSRLinkToSSROption(link string) (*outbound.ShadowSocksROption, error)
func ShadowrocketLinkToVmessLink(link string) (string, error)

func ShadowrocketVmessLinkToVmessOptionIP added in v0.9.0

func ShadowrocketVmessLinkToVmessOptionIP(link string, resolveip bool) (*outbound.VmessOption, error)

parse shadowrocket link

func ToVmessOption

func ToVmessOption(path string) (*outbound.VmessOption, error)

func TrojanLinkToTrojanOption

func TrojanLinkToTrojanOption(link string) (*outbound.TrojanOption, error)

TODO: SkipCertVerify

func VmessConfigToVmessOption

func VmessConfigToVmessOption(config *VmessConfig) (*outbound.VmessOption, error)

func VmessLinkToVmessOption

func VmessLinkToVmessOption(link string) (*outbound.VmessOption, error)

func VmessLinkToVmessOptionIP

func VmessLinkToVmessOptionIP(link string, resolveip bool) (*outbound.VmessOption, error)

TODO: safe base64

Types

type BaseProxy added in v0.8.0

type BaseProxy struct {
	Name   string      `yaml:"name"`
	Server string      `yaml:"server"`
	Port   interface{} `yaml:"port"` // int, string
	Type   string      `yaml:"type"`
}

func ParseBaseProxy added in v0.8.0

func ParseBaseProxy(profile string) (*BaseProxy, error)

type ClashConfig

type ClashConfig struct {
	General      *General
	Experimental *Experimental
	Profile      *Profile
	Proxies      []string
}

Config is clash config manager

func ParseClash

func ParseClash(buf []byte) (*ClashConfig, error)

Parse config

func ParseRawConfig

func ParseRawConfig(rawCfg *ClashRawConfig) (*ClashConfig, error)

type ClashRawConfig

type ClashRawConfig struct {
	Port               int      `yaml:"port"`
	SocksPort          int      `yaml:"socks-port"`
	RedirPort          int      `yaml:"redir-port"`
	TProxyPort         int      `yaml:"tproxy-port"`
	MixedPort          int      `yaml:"mixed-port"`
	Authentication     []string `yaml:"authentication"`
	AllowLan           bool     `yaml:"allow-lan"`
	BindAddress        string   `yaml:"bind-address"`
	Mode               string   `yaml:"mode"`
	LogLevel           string   `yaml:"log-level"`
	NamePrefix         string   `yaml:"name-prefix"`
	IPv6               bool     `yaml:"ipv6"`
	ExternalController string   `yaml:"external-controller"`
	ExternalUI         string   `yaml:"external-ui"`
	Secret             string   `yaml:"secret"`
	Interface          string   `yaml:"interface-name"`

	ProxyProvider map[string]map[string]interface{} `yaml:"proxy-providers"`
	Hosts         map[string]string                 `yaml:"hosts"`
	Experimental  Experimental                      `yaml:"experimental"`
	Profile       Profile                           `yaml:"profile"`
	Proxy         []map[string]interface{}          `yaml:"proxies"`
}

func UnmarshalRawConfig

func UnmarshalRawConfig(buf []byte) (*ClashRawConfig, error)

type Config

type Config struct {
	Protocol string
	Remarks  string
	Server   string
	Net      string // vmess net type
	Port     int
	Password string
	SNI      string
}

func Link2Config

func Link2Config(link string) (*Config, error)

type Controller

type Controller struct {
	ExternalController string `json:"-"`
	ExternalUI         string `json:"-"`
	Secret             string `json:"-"`
}

Controller

type Experimental

type Experimental struct{}

Experimental config

type FallbackFilter

type FallbackFilter struct {
	GeoIP  bool         `yaml:"geoip"`
	IPCIDR []*net.IPNet `yaml:"ipcidr"`
	Domain []string     `yaml:"domain"`
}

FallbackFilter config

type General

type General struct {
	Inbound
	Controller
	Mode      string `json:"mode"`
	LogLevel  string `json:"log-level"`
	IPv6      bool   `json:"ipv6"`
	Interface string `json:"-"`
}

General config

type Inbound

type Inbound struct {
	Port           int      `json:"port"`
	SocksPort      int      `json:"socks-port"`
	RedirPort      int      `json:"redir-port"`
	TProxyPort     int      `json:"tproxy-port"`
	MixedPort      int      `json:"mixed-port"`
	Authentication []string `json:"authentication"`
	AllowLan       bool     `json:"allow-lan"`
	BindAddress    string   `json:"bind-address"`
}

Inbound

type Outbound

type Outbound struct {
	Protocol       string          `json:"protocol"`
	Description    string          `json:"description"`
	Settings       Settings        `json:"settings"`
	StreamSettings *StreamSettings `json:"streamSettings,omitempty"`
}

type Profile

type Profile struct {
	StoreSelected bool `yaml:"store-selected"`
}

Profile config

type RawConfig

type RawConfig struct {
	Outbounds []Outbound `json:"outbounds"`
}

type RawFallbackFilter

type RawFallbackFilter struct {
	GeoIP  bool     `yaml:"geoip"`
	IPCIDR []string `yaml:"ipcidr"`
	Domain []string `yaml:"domain"`
}

type Settings

type Settings struct {
	Vnexts []VNext `json:"vnext"`
}

type StreamSettings

type StreamSettings struct {
	Network    string     `json:"network"`
	Security   string     `json:"security"`
	WSSettings WSSettings `json:"wsSettings,omitempty"`
}

type User

type User struct {
	Email    string `json:"Email"`
	ID       string `json:"ID"`
	AlterId  int    `json:"alterId"`
	Security string `json:"security"`
}

type VNext

type VNext struct {
	Address string `json:"address"`
	Port    uint16 `json:"port"`
	Users   []User `json:"users"`
}

type VmessConfig

type VmessConfig struct {
	Add            string          `json:"add"`
	Aid            json.RawMessage `json:"aid"`
	AlterId        json.RawMessage `json:"alterId,omitempty"`
	Host           string          `json:"host"`
	ID             string          `json:"id"`
	Net            string          `json:"net"`
	Path           string          `json:"path"`
	Port           json.RawMessage `json:"port"`
	Ps             string          `json:"ps"`
	TLSRaw         json.RawMessage `json:"tls"`
	Type           string          `json:"type"`
	V              json.RawMessage `json:"v,omitempty"`
	Security       string          `json:"security,omitempty"`
	Scy            string          `json:"scy,omitempty"`
	Encryption     string          `json:"encryption,omitempty"`
	ResolveIP      bool            `json:"resolve_ip,omitempty"`
	SkipCertVerify bool            `json:"skip-cert-verify,omitempty"`
	ServerName     string          `json:"sni,omitempty"`
	PortInt        int             `json:"-"`
	AidInt         int             `json:"-"`
	TLS            string          `json:"-"`
}

func ShadowrocketVmessLinkToVmessConfig added in v0.9.0

func ShadowrocketVmessLinkToVmessConfig(link string, resolveip bool) (*VmessConfig, error)

func VmessLinkToVmessConfig added in v0.9.0

func VmessLinkToVmessConfig(link string, resolveip bool) (*VmessConfig, error)

func VmessLinkToVmessConfigIP

func VmessLinkToVmessConfigIP(link string, resolveip bool) (*VmessConfig, error)

type VmessConfigMarshal added in v0.10.0

type VmessConfigMarshal struct {
	Add            string `json:"add"`
	Aid            int    `json:"aid"`
	Host           string `json:"host"`
	ID             string `json:"id"`
	Net            string `json:"net"`
	Path           string `json:"path"`
	Port           uint16 `json:"port"`
	Ps             string `json:"ps"`
	TLS            string `json:"tls"`
	Type           string `json:"type"`
	V              string `json:"v,omitempty"`
	Security       string `json:"security,omitempty"`
	Scy            string `json:"scy,omitempty"`
	ResolveIP      bool   `json:"resolve_ip,omitempty"`
	SkipCertVerify bool   `json:"skip-cert-verify"`
	ServerName     string `json:"sni"`
}

type WSSettings

type WSSettings struct {
	Path string `json:"path"`
}

Jump to

Keyboard shortcuts

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