mirror of
https://github.com/bestnite/sub2sing-box.git
synced 2025-06-16 10:03:18 +08:00
⚡️ Improve
This commit is contained in:
@ -9,11 +9,9 @@ type ParseError struct {
|
||||
type ParseErrorType string
|
||||
|
||||
const (
|
||||
ErrInvalidPrefix ParseErrorType = "invalid url prefix"
|
||||
ErrInvalidStruct ParseErrorType = "invalid struct"
|
||||
ErrInvalidPort ParseErrorType = "invalid port number"
|
||||
ErrCannotParseParams ParseErrorType = "cannot parse query parameters"
|
||||
ErrInvalidBase64 ParseErrorType = "invalid base64"
|
||||
ErrInvalidPrefix ParseErrorType = "invalid url prefix"
|
||||
ErrInvalidStruct ParseErrorType = "invalid struct"
|
||||
ErrInvalidPort ParseErrorType = "invalid port number"
|
||||
)
|
||||
|
||||
func (e *ParseError) Error() string {
|
||||
|
@ -72,6 +72,8 @@ func ParseShadowsocks(proxy string) (model.Outbound, error) {
|
||||
Raw: proxy,
|
||||
}
|
||||
}
|
||||
method := methodAndPass[0]
|
||||
password := methodAndPass[1]
|
||||
|
||||
query := link.Query()
|
||||
pluginStr := query.Get("plugin")
|
||||
@ -99,8 +101,8 @@ func ParseShadowsocks(proxy string) (model.Outbound, error) {
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
Method: methodAndPass[0],
|
||||
Password: methodAndPass[1],
|
||||
Method: method,
|
||||
Password: password,
|
||||
Plugin: plugin,
|
||||
PluginOptions: options,
|
||||
},
|
||||
|
@ -78,10 +78,6 @@ func ParseVless(proxy string) (model.Outbound, error) {
|
||||
ALPN: alpn,
|
||||
ServerName: sni,
|
||||
Insecure: insecureBool,
|
||||
UTLS: &model.OutboundUTLSOptions{
|
||||
Enabled: enableUTLS,
|
||||
Fingerprint: fp,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -93,10 +89,6 @@ func ParseVless(proxy string) (model.Outbound, error) {
|
||||
ALPN: alpn,
|
||||
ServerName: sni,
|
||||
Insecure: insecureBool,
|
||||
UTLS: &model.OutboundUTLSOptions{
|
||||
Enabled: enableUTLS,
|
||||
Fingerprint: fp,
|
||||
},
|
||||
Reality: &model.OutboundRealityOptions{
|
||||
Enabled: true,
|
||||
PublicKey: pbk,
|
||||
@ -141,7 +133,7 @@ func ParseVless(proxy string) (model.Outbound, error) {
|
||||
hosts, err := url.QueryUnescape(host)
|
||||
if err != nil {
|
||||
return model.Outbound{}, &ParseError{
|
||||
Type: ErrCannotParseParams,
|
||||
Type: ErrInvalidStruct,
|
||||
Raw: proxy,
|
||||
Message: err.Error(),
|
||||
}
|
||||
@ -153,5 +145,13 @@ func ParseVless(proxy string) (model.Outbound, error) {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if enableUTLS {
|
||||
result.VLESSOptions.OutboundTLSOptionsContainer.TLS.UTLS = &model.OutboundUTLSOptions{
|
||||
Enabled: enableUTLS,
|
||||
Fingerprint: fp,
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ func ParseVmess(proxy string) (model.Outbound, error) {
|
||||
proxy = strings.TrimPrefix(proxy, constant.VMessPrefix)
|
||||
base64, err := util.DecodeBase64(proxy)
|
||||
if err != nil {
|
||||
return model.Outbound{}, &ParseError{Type: ErrInvalidBase64, Raw: proxy, Message: err.Error()}
|
||||
return model.Outbound{}, &ParseError{Type: ErrInvalidStruct, Raw: proxy, Message: err.Error()}
|
||||
}
|
||||
|
||||
var vmess model.VmessJson
|
||||
|
Reference in New Issue
Block a user