Skip to content

Commit

Permalink
use custom fragment core
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Jul 27, 2024
1 parent 2c4d7d6 commit b0ffc46
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
10 changes: 4 additions & 6 deletions option/xray.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package option

import "github.com/xtls/xray-core/proxy/freedom"

type XrayOutboundOptions struct {
DialerOptions
Network NetworkList `json:"network,omitempty"`
UDPOverTCP *UDPOverTCPOptions `json:"udp_over_tcp,omitempty"`
XrayOutboundJson map[string]any `json:"xray_outbound_raw"`
Fragment *struct {
Packets string `json:"packets"`
Length string `json:"length"`
Interval string `json:"interval"`
} `json:"fragment"`
XrayOutboundJson *map[string]any `json:"xray_outbound_raw"`
Fragment *freedom.Fragment `json:"fragment"`
}
28 changes: 16 additions & 12 deletions outbound/xray.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,28 @@ func NewXray(ctx context.Context, router adapter.Router, logger log.ContextLogge
}
userpass := newuuid.String()
port := getRandomFreePort()
outbounds := []map[string]any{options.XrayOutboundJson}
outbounds[0]["sockopt"] = map[string]any{}
if options.Fragment != nil {
outbounds[0]["sockopt"] = map[string]any{
"dialerProxy": "fragment",
"tcpKeepAliveIdle": 100,
"tcpNoDelay": true,
outbounds := []map[string]any{}
if options.XrayOutboundJson != nil {
xrayconf := *options.XrayOutboundJson
if options.Fragment == nil {
xrayconf["sockopt"] = map[string]any{}
} else {
xrayconf["sockopt"] = map[string]any{
"dialerProxy": "fragment",
"tcpKeepAliveIdle": 100,
"tcpNoDelay": true,
}
}
outbounds = append(outbounds, xrayconf)
}

if options.Fragment != nil {
outbounds = append(outbounds, map[string]any{
"tag": "fragment",
"protocol": "freedom",
"settings": map[string]any{
"domainStrategy": "AsIs",
"fragment": map[string]any{
"packets": options.Fragment.Packets,
"length": options.Fragment.Length,
"interval": options.Fragment.Interval,
},
"fragment": options.Fragment,
},
"streamSettings": map[string]any{
"sockopt": map[string]any{
Expand Down

0 comments on commit b0ffc46

Please sign in to comment.