Skip to content

Commit 446315c

Browse files
authored
REALITY protocol: Add optional Post-Quantum ML-DSA-65 verification for cert's ExtraExtensions (#4915)
XTLS/REALITY@00881f6
1 parent eed0554 commit 446315c

File tree

10 files changed

+239
-119
lines changed

10 files changed

+239
-119
lines changed

go.mod

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ require (
1313
github.com/pelletier/go-toml v1.9.5
1414
github.com/pires/go-proxyproto v0.8.1
1515
github.com/quic-go/quic-go v0.54.0
16-
github.com/refraction-networking/utls v1.7.3
16+
github.com/refraction-networking/utls v1.8.0
1717
github.com/sagernet/sing v0.5.1
1818
github.com/sagernet/sing-shadowsocks v0.2.7
1919
github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771
2020
github.com/stretchr/testify v1.10.0
2121
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e
2222
github.com/vishvananda/netlink v1.3.1
23-
github.com/xtls/reality v0.0.0-20250715055725-05a351a64521
23+
github.com/xtls/reality v0.0.0-20250722045654-4eaf7927f393
2424
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
2525
golang.org/x/crypto v0.40.0
2626
golang.org/x/net v0.42.0
@@ -35,13 +35,14 @@ require (
3535
)
3636

3737
require (
38-
github.com/andybalholm/brotli v1.1.0 // indirect
38+
github.com/andybalholm/brotli v1.0.6 // indirect
3939
github.com/davecgh/go-spew v1.1.1 // indirect
40-
github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect
40+
github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165 // indirect
4141
github.com/google/btree v1.1.2 // indirect
4242
github.com/juju/ratelimit v1.0.2 // indirect
43-
github.com/klauspost/compress v1.17.8 // indirect
44-
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
43+
github.com/klauspost/compress v1.17.4 // indirect
44+
github.com/klauspost/cpuid/v2 v2.0.12 // indirect
45+
github.com/kr/pretty v0.3.1 // indirect
4546
github.com/pmezard/go-difflib v1.0.0 // indirect
4647
github.com/quic-go/qpack v0.5.1 // indirect
4748
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect

go.sum

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 h1:Wo41lDOevRJSGpevP+8Pk5bANX7fJacO2w04aqLiC5I=
22
github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0/go.mod h1:FVGavL/QEBQDcBpr3fAojoK17xX5k9bicBphrOpP7uM=
3-
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
4-
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
3+
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
4+
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
55
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
66
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
7+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
78
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
89
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
910
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11+
github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165 h1:BS21ZUJ/B5X2UVUbczfmdWH7GapPWAhxcMsDnjJTU1E=
1012
github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw=
11-
github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 h1:y7y0Oa6UawqTFPCDw9JG6pdKt4F9pAhHv0B7FMGaGD0=
12-
github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw=
1313
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3A65HN+7CMjSDP/gofXL4CZt1V4=
1414
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I=
1515
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
@@ -32,10 +32,14 @@ github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364 h1:5XxdakFhqd9dnXoA
3232
github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364/go.mod h1:eDJQioIyy4Yn3MVivT7rv/39gAJTrA7lgmYr8EW950c=
3333
github.com/juju/ratelimit v1.0.2 h1:sRxmtRiajbvrcLQT7S+JbqU0ntsb9W2yhSdNN8tWfaI=
3434
github.com/juju/ratelimit v1.0.2/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk=
35-
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
36-
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
37-
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
38-
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
35+
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
36+
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
37+
github.com/klauspost/cpuid/v2 v2.0.12 h1:p9dKCg8i4gmOxtv35DvrYoWqYzQrvEVdjQ762Y0OqZE=
38+
github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
39+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
40+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
41+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
42+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
3943
github.com/miekg/dns v1.1.67 h1:kg0EHj0G4bfT5/oOys6HhZw4vmMlnoZ+gDu8tJ/AlI0=
4044
github.com/miekg/dns v1.1.67/go.mod h1:fujopn7TB3Pu3JM69XaawiU0wqjpL9/8xGop5UrTPps=
4145
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
@@ -44,16 +48,19 @@ github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoU
4448
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
4549
github.com/pires/go-proxyproto v0.8.1 h1:9KEixbdJfhrbtjpz/ZwCdWDD2Xem0NZ38qMYaASJgp0=
4650
github.com/pires/go-proxyproto v0.8.1/go.mod h1:ZKAAyp3cgy5Y5Mo4n9AlScrkCZwUy0g3Jf+slqQVcuU=
51+
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
4752
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4853
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4954
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
5055
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
5156
github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQBg=
5257
github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY=
53-
github.com/refraction-networking/utls v1.7.3 h1:L0WRhHY7Oq1T0zkdzVZMR6zWZv+sXbHB9zcuvsAEqCo=
54-
github.com/refraction-networking/utls v1.7.3/go.mod h1:TUhh27RHMGtQvjQq+RyO11P6ZNQNBb3N0v7wsEjKAIQ=
58+
github.com/refraction-networking/utls v1.8.0 h1:L38krhiTAyj9EeiQQa2sg+hYb4qwLCqdMcpZrRfbONE=
59+
github.com/refraction-networking/utls v1.8.0/go.mod h1:jkSOEkLqn+S/jtpEHPOsVv/4V4EVnelwbMQl4vCWXAM=
5560
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg=
5661
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s=
62+
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
63+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
5764
github.com/sagernet/sing v0.5.1 h1:mhL/MZVq0TjuvHcpYcFtmSD1BFOxZ/+8ofbNZcg1k1Y=
5865
github.com/sagernet/sing v0.5.1/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
5966
github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8=
@@ -70,8 +77,8 @@ github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW
7077
github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4=
7178
github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY=
7279
github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
73-
github.com/xtls/reality v0.0.0-20250715055725-05a351a64521 h1:hQQSzX6Y40nY1XT1TKAEpKwUHUUy3UvYKQIclLjYx9U=
74-
github.com/xtls/reality v0.0.0-20250715055725-05a351a64521/go.mod h1:yD47RN65bDLZgyHWMfFDiqlzrq4usDMt/Xzsk6tMbhw=
80+
github.com/xtls/reality v0.0.0-20250722045654-4eaf7927f393 h1:WcsH1BAZVgbKpyyiyjOnS8deJcQ7BmYa2iNEPqEy574=
81+
github.com/xtls/reality v0.0.0-20250722045654-4eaf7927f393/go.mod h1:XxvnCCgBee4WWE0bc4E+a7wbk8gkJ/rS0vNVNtC5qp0=
7582
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
7683
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
7784
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
@@ -111,7 +118,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
111118
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
112119
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
113120
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
114-
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
115121
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
116122
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
117123
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
@@ -141,8 +147,9 @@ google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok=
141147
google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc=
142148
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
143149
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
144-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
145150
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
151+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
152+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
146153
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
147154
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
148155
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

infra/conf/transport_internet.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212
"syscall"
1313

14+
"github.com/cloudflare/circl/sign/mldsa/mldsa65"
1415
"github.com/xtls/xray-core/common/errors"
1516
"github.com/xtls/xray-core/common/net"
1617
"github.com/xtls/xray-core/common/platform/filesystem"
@@ -505,16 +506,18 @@ type REALITYConfig struct {
505506
MaxClientVer string `json:"maxClientVer"`
506507
MaxTimeDiff uint64 `json:"maxTimeDiff"`
507508
ShortIds []string `json:"shortIds"`
509+
Mldsa65Seed string `json:"mldsa65Seed"`
508510

509511
LimitFallbackUpload LimitFallback `json:"limitFallbackUpload"`
510512
LimitFallbackDownload LimitFallback `json:"limitFallbackDownload"`
511513

512-
Fingerprint string `json:"fingerprint"`
513-
ServerName string `json:"serverName"`
514-
Password string `json:"password"`
515-
PublicKey string `json:"publicKey"`
516-
ShortId string `json:"shortId"`
517-
SpiderX string `json:"spiderX"`
514+
Fingerprint string `json:"fingerprint"`
515+
ServerName string `json:"serverName"`
516+
Password string `json:"password"`
517+
PublicKey string `json:"publicKey"`
518+
ShortId string `json:"shortId"`
519+
Mldsa65Verify string `json:"mldsa65Verify"`
520+
SpiderX string `json:"spiderX"`
518521
}
519522

520523
func (c *REALITYConfig) Build() (proto.Message, error) {
@@ -610,6 +613,13 @@ func (c *REALITYConfig) Build() (proto.Message, error) {
610613
config.ServerNames = c.ServerNames
611614
config.MaxTimeDiff = c.MaxTimeDiff
612615

616+
if mldsa65Seed, err := base64.RawURLEncoding.DecodeString(c.Mldsa65Seed); err != nil || len(mldsa65Seed) != 32 {
617+
return nil, errors.New(`invalid "mldsa65Seed": `, c.Mldsa65Seed)
618+
} else {
619+
_, key := mldsa65.NewKeyFromSeed((*[32]byte)(mldsa65Seed))
620+
config.Mldsa65Key = key.Bytes()
621+
}
622+
613623
config.LimitFallbackUpload = new(reality.LimitFallback)
614624
config.LimitFallbackUpload.AfterBytes = c.LimitFallbackUpload.AfterBytes
615625
config.LimitFallbackUpload.BytesPerSec = c.LimitFallbackUpload.BytesPerSec
@@ -645,6 +655,9 @@ func (c *REALITYConfig) Build() (proto.Message, error) {
645655
if _, err = hex.Decode(config.ShortId, []byte(c.ShortId)); err != nil {
646656
return nil, errors.New(`invalid "shortId": `, c.ShortId)
647657
}
658+
if config.Mldsa65Verify, err = base64.RawURLEncoding.DecodeString(c.Mldsa65Verify); err != nil || len(config.Mldsa65Verify) != 1952 {
659+
return nil, errors.New(`invalid "mldsa65Verify": `, c.Mldsa65Verify)
660+
}
648661
if c.SpiderX == "" {
649662
c.SpiderX = "/"
650663
}

main/commands/all/commands.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ func init() {
1616
cmdUUID,
1717
cmdX25519,
1818
cmdWG,
19+
cmdMLDSA65,
1920
)
2021
}

main/commands/all/mldsa65.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package all
2+
3+
import (
4+
"crypto/rand"
5+
"encoding/base64"
6+
"fmt"
7+
8+
"github.com/cloudflare/circl/sign/mldsa/mldsa65"
9+
"github.com/xtls/xray-core/main/commands/base"
10+
)
11+
12+
var cmdMLDSA65 = &base.Command{
13+
UsageLine: `{{.Exec}} mldsa65 [-i "seed (base64.RawURLEncoding)"]`,
14+
Short: `Generate key pair for ML-DSA-65 post-quantum signature`,
15+
Long: `
16+
Generate key pair for ML-DSA-65 post-quantum signature.
17+
18+
Random: {{.Exec}} mldsa65
19+
20+
From seed: {{.Exec}} mldsa65 -i "seed (base64.RawURLEncoding)"
21+
`,
22+
}
23+
24+
func init() {
25+
cmdMLDSA65.Run = executeMLDSA65 // break init loop
26+
}
27+
28+
var input_seed = cmdMLDSA65.Flag.String("i", "", "")
29+
30+
func executeMLDSA65(cmd *base.Command, args []string) {
31+
var seed [32]byte
32+
if len(*input_seed) > 0 {
33+
s, _ := base64.RawURLEncoding.DecodeString(*input_seed)
34+
seed = [32]byte(s)
35+
} else {
36+
rand.Read(seed[:])
37+
}
38+
pub, _ := mldsa65.NewKeyFromSeed(&seed)
39+
fmt.Printf("Seed: %v\nVerify: %v",
40+
base64.RawURLEncoding.EncodeToString(seed[:]),
41+
base64.RawURLEncoding.EncodeToString(pub.Bytes()))
42+
}

main/commands/all/tls/ping.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ func executePing(cmd *base.Command, args []string) {
4040
}
4141

4242
domainWithPort := cmdPing.Flag.Arg(0)
43-
fmt.Println("Tls ping: ", domainWithPort)
43+
fmt.Println("TLS ping: ", domainWithPort)
4444
TargetPort := 443
4545
domain, port, err := net.SplitHostPort(domainWithPort)
46-
if err == nil {
46+
if err != nil {
47+
domain = domainWithPort
48+
} else {
4749
TargetPort, _ = strconv.Atoi(port)
4850
}
4951

@@ -61,7 +63,7 @@ func executePing(cmd *base.Command, args []string) {
6163
}
6264
ip = v.IP
6365
}
64-
fmt.Println("Using IP: ", ip.String())
66+
fmt.Println("Using IP: ", ip.String()+":"+strconv.Itoa(TargetPort))
6567

6668
fmt.Println("-------------------")
6769
fmt.Println("Pinging without SNI")
@@ -72,7 +74,7 @@ func executePing(cmd *base.Command, args []string) {
7274
}
7375
tlsConn := gotls.Client(tcpConn, &gotls.Config{
7476
InsecureSkipVerify: true,
75-
NextProtos: []string{"http/1.1"},
77+
NextProtos: []string{"h2", "http/1.1"},
7678
MaxVersion: gotls.VersionTLS13,
7779
MinVersion: gotls.VersionTLS12,
7880
// Do not release tool before v5's refactor
@@ -98,32 +100,35 @@ func executePing(cmd *base.Command, args []string) {
98100
}
99101
tlsConn := gotls.Client(tcpConn, &gotls.Config{
100102
ServerName: domain,
101-
NextProtos: []string{"http/1.1"},
103+
NextProtos: []string{"h2", "http/1.1"},
102104
MaxVersion: gotls.VersionTLS13,
103105
MinVersion: gotls.VersionTLS12,
104106
// Do not release tool before v5's refactor
105107
// VerifyPeerCertificate: showCert(),
106108
})
107109
err = tlsConn.Handshake()
108110
if err != nil {
109-
fmt.Println("handshake failure: ", err)
111+
fmt.Println("Handshake failure: ", err)
110112
} else {
111-
fmt.Println("handshake succeeded")
113+
fmt.Println("Handshake succeeded")
112114
printTLSConnDetail(tlsConn)
113115
printCertificates(tlsConn.ConnectionState().PeerCertificates)
114116
}
115117
tlsConn.Close()
116118
}
117119

118-
fmt.Println("Tls ping finished")
120+
fmt.Println("-------------------")
121+
fmt.Println("TLS ping finished")
119122
}
120123

121124
func printCertificates(certs []*x509.Certificate) {
122125
for _, cert := range certs {
123126
if len(cert.DNSNames) == 0 {
124127
continue
125128
}
126-
fmt.Println("Allowed domains: ", cert.DNSNames)
129+
fmt.Println("Cert's signature algorithm: ", cert.SignatureAlgorithm.String())
130+
fmt.Println("Cert's publicKey algorithm: ", cert.PublicKeyAlgorithm.String())
131+
fmt.Println("Cert's allowed domains: ", cert.DNSNames)
127132
}
128133
}
129134

@@ -134,13 +139,13 @@ func printTLSConnDetail(tlsConn *gotls.Conn) {
134139
} else if tlsConn.ConnectionState().Version == gotls.VersionTLS12 {
135140
tlsVersion = "TLS 1.2"
136141
}
137-
fmt.Println("TLS Version:", tlsVersion)
142+
fmt.Println("TLS Version: ", tlsVersion)
138143
curveID := *(*gotls.CurveID)(unsafe.Pointer(reflect.ValueOf(tlsConn).Elem().FieldByName("curveID").UnsafeAddr()))
139144
if curveID != 0 {
140145
PostQuantum := (curveID == gotls.X25519MLKEM768)
141-
fmt.Println("Post-Quantum key exchange:", PostQuantum, "("+curveID.String()+")")
146+
fmt.Println("TLS Post-Quantum key exchange: ", PostQuantum, "("+curveID.String()+")")
142147
} else {
143-
fmt.Println("Post-Quantum key exchange: false (RSA Exchange)")
148+
fmt.Println("TLS Post-Quantum key exchange: false (RSA Exchange)")
144149
}
145150
}
146151

transport/internet/reality/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ func (c *Config) GetREALITYConfig() *reality.Config {
2727
MaxClientVer: c.MaxClientVer,
2828
MaxTimeDiff: time.Duration(c.MaxTimeDiff) * time.Millisecond,
2929

30+
Mldsa65Key: c.Mldsa65Key,
31+
3032
NextProtos: nil, // should be nil
3133
SessionTicketsDisabled: true,
3234

0 commit comments

Comments
 (0)