Skip to content

Commit 8fa4e81

Browse files
committed
chore: remove internal crypto/tls fork in reality server
1 parent 7551c8a commit 8fa4e81

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ require (
2424
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759
2525
github.com/metacubex/quic-go v0.49.1-0.20250212162123-c135a4412996
2626
github.com/metacubex/randv2 v0.2.0
27-
github.com/metacubex/reality v0.0.0-20250219003814-74e8d7850629
2827
github.com/metacubex/sing-quic v0.0.0-20250404030904-b2cc8aab562c
2928
github.com/metacubex/sing-shadowsocks v0.2.8
3029
github.com/metacubex/sing-shadowsocks2 v0.2.2
@@ -33,7 +32,7 @@ require (
3332
github.com/metacubex/sing-vmess v0.1.14-0.20250228002636-abc39e113b82
3433
github.com/metacubex/sing-wireguard v0.0.0-20241126021510-0827d417b589
3534
github.com/metacubex/tfo-go v0.0.0-20241231083714-66613d49c422
36-
github.com/metacubex/utls v1.6.8-alpha.5
35+
github.com/metacubex/utls v1.6.8-alpha.6
3736
github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181
3837
github.com/miekg/dns v1.1.63
3938
github.com/mroth/weightedrand/v2 v2.1.0

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ github.com/metacubex/quic-go v0.49.1-0.20250212162123-c135a4412996 h1:B+AP/Pj2/j
111111
github.com/metacubex/quic-go v0.49.1-0.20250212162123-c135a4412996/go.mod h1:ExVjGyEwTUjCFqx+5uxgV7MOoA3fZI+th4D40H35xmY=
112112
github.com/metacubex/randv2 v0.2.0 h1:uP38uBvV2SxYfLj53kuvAjbND4RUDfFJjwr4UigMiLs=
113113
github.com/metacubex/randv2 v0.2.0/go.mod h1:kFi2SzrQ5WuneuoLLCMkABtiBu6VRrMrWFqSPyj2cxY=
114-
github.com/metacubex/reality v0.0.0-20250219003814-74e8d7850629 h1:aHsYiTvubfgMa3JMTDY//hDXVvFWrHg6ARckR52ttZs=
115-
github.com/metacubex/reality v0.0.0-20250219003814-74e8d7850629/go.mod h1:TTeIOZLdGmzc07Oedn++vWUUfkZoXLF4sEMxWuhBFr8=
116114
github.com/metacubex/sing v0.0.0-20250228041610-d94509dc612a h1:xjPXdDTlIKq4U/KnKpoCtkxD03T8GimtQrvHy/3dN00=
117115
github.com/metacubex/sing v0.0.0-20250228041610-d94509dc612a/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
118116
github.com/metacubex/sing-quic v0.0.0-20250404030904-b2cc8aab562c h1:OB3WmMA8YPJjE36RjD9X8xlrWGJ4orxbf2R/KAE28b0=
@@ -131,8 +129,8 @@ github.com/metacubex/sing-wireguard v0.0.0-20241126021510-0827d417b589 h1:Z6bNy0
131129
github.com/metacubex/sing-wireguard v0.0.0-20241126021510-0827d417b589/go.mod h1:4NclTLIZuk+QkHVCGrP87rHi/y8YjgPytxTgApJNMhc=
132130
github.com/metacubex/tfo-go v0.0.0-20241231083714-66613d49c422 h1:zGeQt3UyNydIVrMRB97AA5WsYEau/TyCnRtTf1yUmJY=
133131
github.com/metacubex/tfo-go v0.0.0-20241231083714-66613d49c422/go.mod h1:l9oLnLoEXyGZ5RVLsh7QCC5XsouTUyKk4F2nLm2DHLw=
134-
github.com/metacubex/utls v1.6.8-alpha.5 h1:A9kLiUMM0GuSBqkww3eFYSKpupVrgxwKXrjBu1E7a9o=
135-
github.com/metacubex/utls v1.6.8-alpha.5/go.mod h1:MEZ5WO/VLKYs/s/dOzEK/mlXOQxc04ESeLzRgjmLYtk=
132+
github.com/metacubex/utls v1.6.8-alpha.6 h1:5ZdZNiZFkKKgEcuPOOROIc8bA4dX2VJHoY3gajSnSaU=
133+
github.com/metacubex/utls v1.6.8-alpha.6/go.mod h1:MEZ5WO/VLKYs/s/dOzEK/mlXOQxc04ESeLzRgjmLYtk=
136134
github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181 h1:hJLQviGySBuaynlCwf/oYgIxbVbGRUIKZCxdya9YrbQ=
137135
github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181/go.mod h1:phewKljNYiTVT31Gcif8RiCKnTUOgVWFJjccqYM8s+Y=
138136
github.com/miekg/dns v1.1.63 h1:8M5aAw6OMZfFXTT7K5V0Eu5YiiL8l7nUAkyN6C9YwaY=

listener/reality/reality.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import (
1010
"time"
1111

1212
"github.com/metacubex/mihomo/listener/inner"
13+
"github.com/metacubex/mihomo/log"
1314
"github.com/metacubex/mihomo/ntp"
1415

15-
"github.com/metacubex/reality"
16+
utls "github.com/metacubex/utls"
1617
)
1718

18-
type Conn = reality.Conn
19+
type Conn = utls.Conn
1920

2021
type Config struct {
2122
Dest string
@@ -27,12 +28,13 @@ type Config struct {
2728
}
2829

2930
func (c Config) Build() (*Builder, error) {
30-
realityConfig := &reality.Config{}
31+
realityConfig := &utls.RealityConfig{}
3132
realityConfig.SessionTicketsDisabled = true
3233
realityConfig.Type = "tcp"
3334
realityConfig.Dest = c.Dest
3435
realityConfig.Time = ntp.Now
3536
realityConfig.ServerNames = make(map[string]bool)
37+
realityConfig.Log = log.Debugln
3638
for _, it := range c.ServerNames {
3739
realityConfig.ServerNames[it] = true
3840
}
@@ -72,19 +74,19 @@ func (c Config) Build() (*Builder, error) {
7274
}
7375

7476
type Builder struct {
75-
realityConfig *reality.Config
77+
realityConfig *utls.RealityConfig
7678
}
7779

7880
func (b Builder) NewListener(l net.Listener) net.Listener {
79-
l = reality.NewListener(l, b.realityConfig)
81+
l = utls.NewRealityListener(l, b.realityConfig)
8082
// Due to low implementation quality, the reality server intercepted half close and caused memory leaks.
8183
// We fixed it by calling Close() directly.
8284
l = realityListenerWrapper{l}
8385
return l
8486
}
8587

8688
type realityConnWrapper struct {
87-
*reality.Conn
89+
*utls.Conn
8890
}
8991

9092
func (c realityConnWrapper) Upstream() any {
@@ -104,5 +106,5 @@ func (l realityListenerWrapper) Accept() (net.Conn, error) {
104106
if err != nil {
105107
return nil, err
106108
}
107-
return realityConnWrapper{c.(*reality.Conn)}, nil
109+
return realityConnWrapper{c.(*utls.Conn)}, nil
108110
}

0 commit comments

Comments
 (0)