mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-05 02:37:30 +03:00
Add MTProxy, MASQUE, VPN, Link parser. Update AmneziaWG. Remove Tunneling
This commit is contained in:
46
parser/link/utils.go
Normal file
46
parser/link/utils.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package link
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/sagernet/sing-box/common"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
F "github.com/sagernet/sing/common/format"
|
||||
"github.com/sagernet/sing/common/json/badoption"
|
||||
)
|
||||
|
||||
func shadowsocksPluginName(plugin string) string {
|
||||
if index := strings.Index(plugin, ";"); index != -1 {
|
||||
return plugin[:index]
|
||||
}
|
||||
return plugin
|
||||
}
|
||||
|
||||
func shadowsocksPluginOptions(plugin string) string {
|
||||
if index := strings.Index(plugin, ";"); index != -1 {
|
||||
return plugin[index+1:]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func v2rayTransportWsPath(WebsocketOptions *option.V2RayWebsocketOptions, path string) {
|
||||
reg := regexp.MustCompile(`^(.*?)(?:\?ed=(\d*))?$`)
|
||||
result := reg.FindStringSubmatch(path)
|
||||
WebsocketOptions.Path = result[1]
|
||||
if result[2] != "" {
|
||||
WebsocketOptions.EarlyDataHeaderName = "Sec-WebSocket-Protocol"
|
||||
WebsocketOptions.MaxEarlyData = common.StringToType[uint32](result[2])
|
||||
}
|
||||
}
|
||||
|
||||
func v2rayTransportWs(host string, path string) option.V2RayWebsocketOptions {
|
||||
var WebsocketOptions option.V2RayWebsocketOptions
|
||||
if host != "" {
|
||||
WebsocketOptions.Headers = common.StringToType[badoption.HTTPHeader](F.ToString("Host: ", host))
|
||||
}
|
||||
if path != "" {
|
||||
v2rayTransportWsPath(&WebsocketOptions, path)
|
||||
}
|
||||
return WebsocketOptions
|
||||
}
|
||||
Reference in New Issue
Block a user