Documentation
¶
Index ¶
- Variables
- func Base64Decode(data string) (string, error)
- func FmtStringReplace(format string, m map[string]string) string
- func JSONPath(p string) func(result gjson.Result) string
- func JSONPathWithValue(p, value string) func(result gjson.Result) string
- func ReadLines(path string) ([]string, error)
- type Endpoint
- type FieldParser
- type JSONParser
- type Number
- type Proxy
- type ShadowsocksURL
- type VmessURL
Constants ¶
This section is empty.
Variables ¶
View Source
var SSParser = JSONParser{ Filed: map[string]FieldParser{ "protocol": JSONPath("protocol"), "port": JSONPath("port"), "method": JSONPath("settings.method"), "password": JSONPath("settings.password"), }, DefaultField: map[string]string{ "host": "", }, PostHandler: func(m map[string]string, tag string) (Endpoint, error) { su := ShadowsocksURL{ Host: m["host"], Port: m["port"], Method: m["method"], Password: m["password"], Tag: tag, } return &su, nil }, }
SSParser parse shadowsocks node in v2ray config
View Source
var VmessParser = JSONParser{ Filed: map[string]FieldParser{ "protocol": JSONPath("protocol"), "port": JSONPath("port"), "id": JSONPath("settings.clients.0.id"), "alterId": JSONPath("settings.clients.0.alterId"), "network": JSONPathWithValue("streamSettings.network", "tcp"), "security": JSONPath("streamSettings.security"), "http.host": JSONPath("streamSettings.httpSettings.host.0"), "http.path": JSONPath("streamSettings.httpSettings.path"), "ws.host": JSONPath("streamSettings.wsSettings.headers.Host"), "ws.path": JSONPath("streamSettings.wsSettings.path"), "kcp.type": JSONPath("streamSettings.kcpSettings.header.type"), "quic.type": JSONPath("streamSettings.quicSettings.header.type"), "quic.security": JSONPath("streamSettings.quicSettings.security"), "quic.key": JSONPath("streamSettings.quicSettings.key"), "servername": JSONPath("tlsSettings.serverName"), }, DefaultField: map[string]string{ "add": "", }, PostHandler: func(m map[string]string, tag string) (Endpoint, error) { alterID, err := strconv.Atoi(m["alterId"]) if err != nil { return nil, errors.Wrap(err, "VmessParser") } vu := VmessURL{ Ps: tag, Port: m["port"], ID: m["id"], AlterID: Number(alterID), Network: m["network"], Security: m["security"], Add: m["add"], Version: 2, } if m["network"] == "http" { vu.FakeHost = m["http.host"] vu.FakePath = m["http.path"] vu.Network = "h2" } else if m["network"] == "ws" { vu.FakeHost = m["ws.host"] vu.FakePath = m["ws.path"] } else if m["network"] == "kcp" { if m["kcp.type"] == "" { m["kcp.type"] = "none" } vu.FakeType = m["kcp.type"] } else if m["network"] == "quic" { if m["quic.type"] == "" { m["quic.type"] = "none" } vu.FakeType = m["quic.type"] vu.FakeHost = m["quic.security"] vu.FakePath = m["quic.key"] } if vu.Port == "443" { vu.Security = "tls" } return &vu, nil }, }
VmessParser parse vmess node in v2ray config
Functions ¶
func FmtStringReplace ¶
FmtStringReplace replace {key} ,key in map
func JSONPathWithValue ¶
JSONPathWithValue json path with default value
Types ¶
type JSONParser ¶
type JSONParser struct { TagFmt string Filed map[string]FieldParser DefaultField map[string]string PostHandler func(m map[string]string, tag string) (Endpoint, error) }
JSONParser -
type ShadowsocksURL ¶
type ShadowsocksURL struct { Host string `json:"host"` Port string `json:"port"` Method string `json:"method"` Password string `json:"password"` Protocol string `json:"protocol"` Tag string `json:"tag"` }
ShadowsocksURL implement interface Endpoint
func NewShadowsocksURL ¶
func NewShadowsocksURL(u string) (*ShadowsocksURL, error)
NewShadowsocksURL -
type VmessURL ¶
type VmessURL struct { Version Number `json:"v"` AlterID Number `json:"aid"` Ps string `json:"ps"` Port string `json:"port"` ID string `json:"id"` Network string `json:"net"` Security string `json:"tls"` Add string `json:"add"` FakePath string `json:"path"` FakeType string `json:"type"` FakeHost string `json:"host"` }
VmessURL implement interface Endpoint from https://github.com/2dust/v2rayN/wiki/分享链接格式说明(ver-2)
Click to show internal directories.
Click to hide internal directories.