Skip to content

Commit

Permalink
make parameters case and _ insensitve. add ifps ifpd
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Feb 13, 2024
1 parent d15e72d commit ba1d827
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 33 deletions.
20 changes: 11 additions & 9 deletions ray2sing/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,22 @@ func getFragmentOptions(decoded map[string]string) *option.TLSFragmentOptions {
}
func getMuxOptions(decoded map[string]string) *option.OutboundMultiplexOptions {
mux := option.OutboundMultiplexOptions{}
mux.Protocol = decoded["mux"]
mux.Protocol = decoded["muxtype"]
if mux.Protocol == "" {
return nil
}
mux.Enabled = true
mux.MaxConnections = toInt(decoded["mux_max"])
mux.MinStreams = toInt(decoded["mux_min"])
mux.Padding = decoded["mux_pad"] == "true"
mux.MaxConnections = toInt(decoded["muxmaxc"])
// mux.MinStreams = toInt(decoded["muxsmin"])
mux.MaxStreams = toInt(decoded["muxsmax"])
mux.MinStreams = toInt(decoded["mux"])
mux.Padding = decoded["muxpad"] == "true"

if decoded["mux_up"] != "" && decoded["mux_down"] != "" {
if decoded["muxup"] != "" && decoded["muxdown"] != "" {
mux.Brutal = &option.BrutalOptions{
Enabled: true,
UpMbps: toInt(decoded["mux_up"]),
DownMbps: toInt(decoded["mux_down"]),
UpMbps: toInt(decoded["muxup"]),
DownMbps: toInt(decoded["muxdown"]),
}
}
return &mux
Expand All @@ -122,10 +124,10 @@ func getTransportOptions(decoded map[string]string) (*option.V2RayTransportOptio
net = decoded["type"]
}
if path == "" {
path = decoded["serviceName"]
path = decoded["servicename"]
}
// fmoption.Printf("\n\nheaderType:%s, net:%s, type:%s\n\n", decoded["headerType"], net, decoded["type"])
if (decoded["type"] == "http" || decoded["headerType"] == "http") && net == "tcp" {
if (decoded["type"] == "http" || decoded["headertype"] == "http") && net == "tcp" {
net = "http"
}

Expand Down
2 changes: 1 addition & 1 deletion ray2sing/shadowsocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func ShadowsocksSingbox(shadowsocksUrl string) (*T.Outbound, error) {
Method: defaultMethod,
Password: u.Password,
Plugin: decoded["plugin"],
PluginOptions: decoded["plugin_opts"],
PluginOptions: decoded["pluginopts"],
},
}

Expand Down
6 changes: 3 additions & 3 deletions ray2sing/tuic.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ func TuicSingbox(tuicUrl string) (*T.Outbound, error) {
ServerOptions: u.GetServerOption(),
UUID: u.Username,
Password: u.Password,
CongestionControl: decoded["congestion_control"],
UDPRelayMode: decoded["udp_relay_mode"],
CongestionControl: decoded["congestioncontrol"],
UDPRelayMode: decoded["udprelaymode"],
ZeroRTTHandshake: false,
Heartbeat: T.Duration(10 * time.Second),
OutboundTLSOptionsContainer: T.OutboundTLSOptionsContainer{
TLS: &T.OutboundTLSOptions{
Enabled: true,
DisableSNI: decoded["sni"] == "",
ServerName: decoded["sni"],
Insecure: decoded["allow_insecure"] == "1",
Insecure: decoded["allowinsecure"] == "1" || decoded["insecure"] == "1",
ALPN: []string{"h3", "spdy/3.1"},
ECH: ECHOpts,
},
Expand Down
2 changes: 1 addition & 1 deletion ray2sing/url_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func ParseUrl(inputURL string, defaultPort uint16) (*UrlSchema, error) {
}

for key, values := range parsedURL.Query() {
data.Params[key] = strings.Join(values, ",")
data.Params[strings.ReplaceAll(strings.ToLower(key), "_", "")] = strings.Join(values, ",")
}

return data, nil
Expand Down
2 changes: 1 addition & 1 deletion ray2sing/vless.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func VlessSingbox(vlessURL string) (*T.Outbound, error) {
}
}

packetEncoding := decoded["packetEncoding"]
packetEncoding := decoded["packetencoding"]
// if packetEncoding==""{
// packetEncoding="xudp"
// }
Expand Down
10 changes: 6 additions & 4 deletions ray2sing/warp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ func WarpSingbox(url string) (*T.Outbound, error) {
Tag: u.Name,
CustomOptions: map[string]interface{}{
"warp": map[string]interface{}{
"key": u.Username,
"host": u.Hostname,
"port": u.Port,
"fake_packets": u.Params["ifp"],
"key": u.Username,
"host": u.Hostname,
"port": u.Port,
"fake_packets": u.Params["ifp"],
"fake_packets_size": u.Params["ifps"],
"fake_packets_delay": u.Params["ifpd"],
},
},
}
Expand Down
19 changes: 5 additions & 14 deletions ray2sing/wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,18 @@ func WiregaurdSingbox(url string) (*T.Outbound, error) {
ServerOptions: u.GetServerOption(),

PrivateKey: u.Params["pk"],
PeerPublicKey: u.Params["peer_pub"],
PeerPublicKey: u.Params["peerpub"],
PreSharedKey: u.Params["psk"],
FakePackets: u.Params["ifp"],
},
}
if pk, ok := u.Params["private_key"]; ok {
if pk, ok := u.Params["privatekey"]; ok {
out.WireGuardOptions.PrivateKey = pk
}
if pk, ok := u.Params["privateKey"]; ok {
out.WireGuardOptions.PrivateKey = pk
}
if pub, ok := u.Params["peer_public_key"]; ok {
out.WireGuardOptions.PeerPublicKey = pub
}
if pub, ok := u.Params["peerPublicKey"]; ok {
if pub, ok := u.Params["peerpublickey"]; ok {
out.WireGuardOptions.PeerPublicKey = pub
}
if psk, ok := u.Params["pre_shared_key"]; ok {
out.WireGuardOptions.PreSharedKey = psk
}
if psk, ok := u.Params["presharedKey"]; ok {
if psk, ok := u.Params["presharedkey"]; ok {
out.WireGuardOptions.PreSharedKey = psk
}

Expand All @@ -67,7 +58,7 @@ func WiregaurdSingbox(url string) (*T.Outbound, error) {
out.WireGuardOptions.Reserved = append(out.WireGuardOptions.Reserved, uint8(num))
}
}
if localAddressStr, ok := u.Params["local_address"]; ok {
if localAddressStr, ok := u.Params["localaddress"]; ok {
localAddressParts := strings.Split(localAddressStr, ",")
for _, part := range localAddressParts {
prefix, err := netip.ParsePrefix(part)
Expand Down

0 comments on commit ba1d827

Please sign in to comment.