Skip to content

Commit caf5e9a

Browse files
committed
add amnezia for warp
1 parent c0c298d commit caf5e9a

5 files changed

Lines changed: 76 additions & 45 deletions

File tree

ray2sing/awg.go

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -177,26 +177,26 @@ func AWGSingboxTxt(content string) (*T.Endpoint, error) {
177177

178178
PrivateKey: privateKey,
179179
Address: badoption.Listable[netip.Prefix](addresses),
180-
181-
Jc: jc,
182-
Jmin: jmin,
183-
Jmax: jmax,
184-
185-
S1: s1,
186-
S2: s2,
187-
S3: s3,
188-
S4: s4,
189-
H1: h1,
190-
H2: h2,
191-
H3: h3,
192-
H4: h4,
193-
194-
I1: i1,
195-
I2: i2,
196-
I3: i3,
197-
I4: i4,
198-
I5: i5,
199-
180+
Awg: T.AwgOptions{
181+
Jc: jc,
182+
Jmin: jmin,
183+
Jmax: jmax,
184+
185+
S1: s1,
186+
S2: s2,
187+
S3: s3,
188+
S4: s4,
189+
H1: h1,
190+
H2: h2,
191+
H3: h3,
192+
H4: h4,
193+
194+
I1: i1,
195+
I2: i2,
196+
I3: i3,
197+
I4: i4,
198+
I5: i5,
199+
},
200200
Peers: []T.AwgPeerOptions{peer},
201201
},
202202
}
@@ -291,25 +291,26 @@ func AWGSingbox(raw string) (*T.Endpoint, error) {
291291
PrivateKey: pk,
292292
Address: addresses,
293293

294-
Jc: getInt("jc"),
295-
Jmin: getInt("jmin"),
296-
Jmax: getInt("jmax"),
297-
298-
S1: getInt("s1"),
299-
S2: getInt("s2"),
300-
S3: getInt("s3"),
301-
S4: getInt("s4"),
302-
H1: getOneOfN(u.Params, "", "h1"),
303-
H2: getOneOfN(u.Params, "", "h2"),
304-
H3: getOneOfN(u.Params, "", "h3"),
305-
H4: getOneOfN(u.Params, "", "h4"),
306-
307-
I1: getOneOfN(u.Params, "", "i1"),
308-
I2: getOneOfN(u.Params, "", "i2"),
309-
I3: getOneOfN(u.Params, "", "i3"),
310-
I4: getOneOfN(u.Params, "", "i4"),
311-
I5: getOneOfN(u.Params, "", "i5"),
312-
294+
Awg: T.AwgOptions{
295+
Jc: getInt("jc"),
296+
Jmin: getInt("jmin"),
297+
Jmax: getInt("jmax"),
298+
299+
S1: getInt("s1"),
300+
S2: getInt("s2"),
301+
S3: getInt("s3"),
302+
S4: getInt("s4"),
303+
H1: getOneOfN(u.Params, "", "h1"),
304+
H2: getOneOfN(u.Params, "", "h2"),
305+
H3: getOneOfN(u.Params, "", "h3"),
306+
H4: getOneOfN(u.Params, "", "h4"),
307+
308+
I1: getOneOfN(u.Params, "", "i1"),
309+
I2: getOneOfN(u.Params, "", "i2"),
310+
I3: getOneOfN(u.Params, "", "i3"),
311+
I4: getOneOfN(u.Params, "", "i4"),
312+
I5: getOneOfN(u.Params, "", "i5"),
313+
},
313314
Peers: []T.AwgPeerOptions{peer},
314315
}
315316
if mtuStr, ok := u.Params["mtu"]; ok {
@@ -318,7 +319,7 @@ func AWGSingbox(raw string) (*T.Endpoint, error) {
318319
}
319320
}
320321
var out *T.Endpoint
321-
isAwg := opts.Jc+opts.Jmin+opts.Jmax+opts.S1+opts.S2+opts.S3+opts.S4 == 0 && opts.H1+opts.H2+opts.H3+opts.H4+opts.I1+opts.I2+opts.I3+opts.I4 == ""
322+
isAwg := opts.Awg.IsAvailble()
322323

323324
if true || isAwg {
324325
wgopts := T.WireGuardEndpointOptions{

ray2sing/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,10 @@ func getALPNversion(s []string) int {
425425
// }
426426
// }
427427
func getDialerOptions(decoded map[string]string) option.DialerOptions {
428-
fragment := getFragmentOptions(decoded)
428+
// fragment := getFragmentOptions(decoded)
429429
return T.DialerOptions{
430430
// TCPFastOpen: !fragment.Enabled,
431-
TLSFragment: fragment,
431+
// TLSFragment: fragment,
432432
}
433433
}
434434

ray2sing/warp.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package ray2sing
22

33
import (
4+
"strconv"
5+
46
C "github.com/sagernet/sing-box/constant"
57
T "github.com/sagernet/sing-box/option"
68
)
@@ -10,18 +12,46 @@ func WarpSingbox(url string) (*T.Endpoint, error) {
1012
if err != nil {
1113
return nil, err
1214
}
15+
getInt := func(key string) int {
16+
if v, ok := u.Params[key]; ok {
17+
i, _ := strconv.Atoi(v)
18+
return i
19+
}
20+
return 0
21+
}
1322
// fmt.Println(u.Username, "-", u.Password, "-", u.Params)
1423
out := T.Endpoint{
1524
Type: C.TypeWARP,
1625
Tag: u.Name,
17-
Options: &T.WireGuardWARPEndpointOptions{
26+
Options: &T.WARPEndpointOptions{
1827
ServerOptions: T.ServerOptions{
1928
Server: u.Hostname,
2029
ServerPort: u.Port,
2130
},
2231
UniqueIdentifier: u.Username,
2332
Noise: getWireGuardNoise(u.Params, false),
2433
MTU: uint32(toInt(getOneOfN(u.Params, "1280", "mtu"))),
34+
35+
AWG: &T.AwgOptions{
36+
Jc: getInt("jc"),
37+
Jmin: getInt("jmin"),
38+
Jmax: getInt("jmax"),
39+
40+
S1: getInt("s1"),
41+
S2: getInt("s2"),
42+
S3: getInt("s3"),
43+
S4: getInt("s4"),
44+
H1: getOneOfN(u.Params, "", "h1"),
45+
H2: getOneOfN(u.Params, "", "h2"),
46+
H3: getOneOfN(u.Params, "", "h3"),
47+
H4: getOneOfN(u.Params, "", "h4"),
48+
49+
I1: getOneOfN(u.Params, "", "i1"),
50+
I2: getOneOfN(u.Params, "", "i2"),
51+
I3: getOneOfN(u.Params, "", "i3"),
52+
I4: getOneOfN(u.Params, "", "i4"),
53+
I5: getOneOfN(u.Params, "", "i5"),
54+
},
2555
},
2656
}
2757

ray2sing/wireguard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func defaultWireguardNoiseOptions() hiddify.NoiseOptions {
129129
// return &T.Endpoint{
130130
// Type: C.TypeWARP,
131131
// Tag: u.Name,
132-
// Options: &T.WireGuardWARPEndpointOptions{
132+
// Options: &T.WARPEndpointOptions{
133133
// ServerOptions: T.ServerOptions{
134134
// Server: u.Hostname,
135135
// ServerPort: u.Port,

run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
go run -tags with_utls,with_wiregaurd,with_awg $*
1+
go run -tags with_utls,with_wiregaurd,with_awg main.go $*

0 commit comments

Comments
 (0)