mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-14 00:51:12 +03:00
Add MTProxy, MASQUE, VPN, Link parser. Update AmneziaWG. Remove Tunneling
This commit is contained in:
39
parser/link/shadowsocks.go
Normal file
39
parser/link/shadowsocks.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package link
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"github.com/sagernet/sing-box/common"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
)
|
||||
|
||||
func parseShadowsocksLink(link string) (option.Outbound, error) {
|
||||
linkURL, err := url.Parse(link)
|
||||
if err != nil {
|
||||
return option.Outbound{}, err
|
||||
}
|
||||
if linkURL.User == nil || linkURL.User.Username() == "" {
|
||||
return option.Outbound{}, E.New("missing user info")
|
||||
}
|
||||
var options option.ShadowsocksOutboundOptions
|
||||
options.ServerOptions.Server = linkURL.Hostname()
|
||||
options.ServerOptions.ServerPort = common.StringToType[uint16](linkURL.Port())
|
||||
password, _ := linkURL.User.Password()
|
||||
if password == "" {
|
||||
return option.Outbound{}, E.New("bad user info")
|
||||
}
|
||||
options.Method = linkURL.User.Username()
|
||||
options.Password = password
|
||||
plugin := linkURL.Query().Get("plugin")
|
||||
options.Plugin = shadowsocksPluginName(plugin)
|
||||
options.PluginOptions = shadowsocksPluginOptions(plugin)
|
||||
|
||||
outbound := option.Outbound{
|
||||
Type: C.TypeShadowsocks,
|
||||
Tag: linkURL.Fragment,
|
||||
}
|
||||
outbound.Options = &options
|
||||
return outbound, nil
|
||||
}
|
||||
Reference in New Issue
Block a user