diff --git a/go.mod b/go.mod index b8c6d235..6f2cddaf 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.1 - github.com/xtls/reality v0.0.0-20250608065753-4b636d90bde2 + github.com/xtls/reality v0.0.0-20250608122607-d4826882fcab go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.39.0 golang.org/x/net v0.41.0 @@ -35,7 +35,7 @@ require ( ) // [TODO] Temp: use forked reality until upstream merges #12 -replace github.com/xtls/reality => github.com/meo597/reality v0.0.0-20250608065753-4b636d90bde2 +replace github.com/xtls/reality => github.com/meo597/reality v0.0.0-20250608122607-d4826882fcab require ( github.com/andybalholm/brotli v1.1.0 // indirect diff --git a/go.sum b/go.sum index 0eb7e296..afc8d6ce 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0N github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/meo597/reality v0.0.0-20250608065753-4b636d90bde2 h1:51SdYH7bCdJ/Nln6UG6aaYEvFw6mr9uCbqhR6Oo/MvQ= -github.com/meo597/reality v0.0.0-20250608065753-4b636d90bde2/go.mod h1:yD47RN65bDLZgyHWMfFDiqlzrq4usDMt/Xzsk6tMbhw= +github.com/meo597/reality v0.0.0-20250608122607-d4826882fcab h1:aEcdfNMR3/SFUP2PRvqYeIpHLtta+vvJ2BGwEoS2tHk= +github.com/meo597/reality v0.0.0-20250608122607-d4826882fcab/go.mod h1:yD47RN65bDLZgyHWMfFDiqlzrq4usDMt/Xzsk6tMbhw= github.com/miekg/dns v1.1.66 h1:FeZXOS3VCVsKnEAd+wBkjMC3D2K+ww66Cq3VnCINuJE= github.com/miekg/dns v1.1.66/go.mod h1:jGFzBsSNbJw6z1HYut1RKBKHA9PBdxeHrZG8J+gC2WE= github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 16fc499c..d2a41048 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -486,6 +486,12 @@ func (c *TLSConfig) Build() (proto.Message, error) { return config, nil } +type LimitFallback struct { + AfterBytes uint64 + BytesPerSec uint64 + BurstBytesPerSec uint64 +} + type REALITYConfig struct { MasterKeyLog string `json:"masterKeyLog"` Show bool `json:"show"` @@ -500,12 +506,8 @@ type REALITYConfig struct { MaxTimeDiff uint64 `json:"maxTimeDiff"` ShortIds []string `json:"shortIds"` - LimitFbUploadRate float64 `json:"limitFbUploadRate"` - LimitFbUploadBurst int64 `json:"limitFbUploadBurst"` - LimitFbUploadAfter int64 `json:"limitFbUploadAfter"` - LimitFbDownloadRate float64 `json:"limitFbDownloadRate"` - LimitFbDownloadBurst int64 `json:"limitFbDownloadBurst"` - LimitFbDownloadAfter int64 `json:"limitFbDownloadAfter"` + LimitFallbackUpload LimitFallback `json:"LimitFallbackUpload"` + LimitFallbackDownload LimitFallback `json:"LimitFallbackDownload"` Fingerprint string `json:"fingerprint"` ServerName string `json:"serverName"` @@ -609,13 +611,13 @@ func (c *REALITYConfig) Build() (proto.Message, error) { config.MaxTimeDiff = c.MaxTimeDiff config.LimitFallbackUpload = new(reality.LimitFallback) - config.LimitFallbackUpload.BytesPerSec = c.LimitFbUploadRate - config.LimitFallbackUpload.BurstBytesPerSec = c.LimitFbUploadBurst - config.LimitFallbackUpload.AfterBytes = c.LimitFbUploadAfter + config.LimitFallbackUpload.BytesPerSec = c.LimitFallbackUpload.BytesPerSec + config.LimitFallbackUpload.BurstBytesPerSec = c.LimitFallbackUpload.BurstBytesPerSec + config.LimitFallbackUpload.AfterBytes = c.LimitFallbackUpload.AfterBytes config.LimitFallbackDownload = new(reality.LimitFallback) - config.LimitFallbackDownload.BytesPerSec = c.LimitFbDownloadRate - config.LimitFallbackDownload.BurstBytesPerSec = c.LimitFbDownloadBurst - config.LimitFallbackDownload.AfterBytes = c.LimitFbDownloadAfter + config.LimitFallbackDownload.BytesPerSec = c.LimitFallbackDownload.BytesPerSec + config.LimitFallbackDownload.BurstBytesPerSec = c.LimitFallbackDownload.BurstBytesPerSec + config.LimitFallbackDownload.AfterBytes = c.LimitFallbackDownload.AfterBytes } else { config.Fingerprint = strings.ToLower(c.Fingerprint) if config.Fingerprint == "unsafe" || config.Fingerprint == "hellogolang" { diff --git a/transport/internet/reality/config.go b/transport/internet/reality/config.go index a776f351..572b9814 100644 --- a/transport/internet/reality/config.go +++ b/transport/internet/reality/config.go @@ -33,14 +33,14 @@ func (c *Config) GetREALITYConfig() *reality.Config { KeyLogWriter: KeyLogWriterFromConfig(c), } if c.LimitFallbackUpload != nil { - config.LimitFbUploadRate = c.LimitFallbackUpload.BytesPerSec - config.LimitFbUploadBurst = c.LimitFallbackUpload.BurstBytesPerSec - config.LimitFbUploadAfter = c.LimitFallbackUpload.AfterBytes + config.LimitFallbackUpload.BytesPerSec = c.LimitFallbackUpload.BytesPerSec + config.LimitFallbackUpload.BurstBytesPerSec = c.LimitFallbackUpload.BurstBytesPerSec + config.LimitFallbackUpload.AfterBytes = c.LimitFallbackUpload.AfterBytes } if c.LimitFallbackDownload != nil { - config.LimitFbDownloadRate = c.LimitFallbackDownload.BytesPerSec - config.LimitFbDownloadBurst = c.LimitFallbackDownload.BurstBytesPerSec - config.LimitFbDownloadAfter = c.LimitFallbackDownload.AfterBytes + config.LimitFallbackDownload.BytesPerSec = c.LimitFallbackDownload.BytesPerSec + config.LimitFallbackDownload.BurstBytesPerSec = c.LimitFallbackDownload.BurstBytesPerSec + config.LimitFallbackDownload.AfterBytes = c.LimitFallbackDownload.AfterBytes } config.ServerNames = make(map[string]bool) for _, serverName := range c.ServerNames { diff --git a/transport/internet/reality/config.pb.go b/transport/internet/reality/config.pb.go index e756948f..0f0e234d 100644 --- a/transport/internet/reality/config.pb.go +++ b/transport/internet/reality/config.pb.go @@ -214,9 +214,9 @@ type LimitFallback struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - BytesPerSec float64 `protobuf:"fixed64,1,opt,name=bytes_per_sec,json=bytesPerSec,proto3" json:"bytes_per_sec,omitempty"` - BurstBytesPerSec int64 `protobuf:"zigzag64,2,opt,name=burst_bytes_per_sec,json=burstBytesPerSec,proto3" json:"burst_bytes_per_sec,omitempty"` - AfterBytes int64 `protobuf:"zigzag64,3,opt,name=after_bytes,json=afterBytes,proto3" json:"after_bytes,omitempty"` + BytesPerSec uint64 `protobuf:"varint,1,opt,name=bytes_per_sec,json=bytesPerSec,proto3" json:"bytes_per_sec,omitempty"` + BurstBytesPerSec uint64 `protobuf:"varint,2,opt,name=burst_bytes_per_sec,json=burstBytesPerSec,proto3" json:"burst_bytes_per_sec,omitempty"` + AfterBytes uint64 `protobuf:"varint,3,opt,name=after_bytes,json=afterBytes,proto3" json:"after_bytes,omitempty"` } func (x *LimitFallback) Reset() { @@ -249,21 +249,21 @@ func (*LimitFallback) Descriptor() ([]byte, []int) { return file_transport_internet_reality_config_proto_rawDescGZIP(), []int{1} } -func (x *LimitFallback) GetBytesPerSec() float64 { +func (x *LimitFallback) GetBytesPerSec() uint64 { if x != nil { return x.BytesPerSec } return 0 } -func (x *LimitFallback) GetBurstBytesPerSec() int64 { +func (x *LimitFallback) GetBurstBytesPerSec() uint64 { if x != nil { return x.BurstBytesPerSec } return 0 } -func (x *LimitFallback) GetAfterBytes() int64 { +func (x *LimitFallback) GetAfterBytes() uint64 { if x != nil { return x.AfterBytes } @@ -325,12 +325,12 @@ var file_transport_internet_reality_config_proto_rawDesc = []byte{ 0x61, 0x63, 0x6b, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x83, 0x01, 0x0a, 0x0d, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x22, 0x0a, 0x0d, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x63, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x63, 0x12, 0x2d, 0x0a, 0x13, 0x62, 0x75, 0x72, 0x73, 0x74, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, - 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x12, 0x52, 0x10, + 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x62, 0x75, 0x72, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x63, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x66, 0x74, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x12, 0x52, 0x0a, 0x61, 0x66, 0x74, 0x65, 0x72, 0x42, 0x79, 0x74, 0x65, + 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x61, 0x66, 0x74, 0x65, 0x72, 0x42, 0x79, 0x74, 0x65, 0x73, 0x42, 0x7f, 0x0a, 0x23, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, diff --git a/transport/internet/reality/config.proto b/transport/internet/reality/config.proto index 9f97f00f..283839d9 100644 --- a/transport/internet/reality/config.proto +++ b/transport/internet/reality/config.proto @@ -31,7 +31,7 @@ message Config { } message LimitFallback { - double bytes_per_sec = 1; - sint64 burst_bytes_per_sec = 2; - sint64 after_bytes = 3; + uint64 bytes_per_sec = 1; + uint64 burst_bytes_per_sec = 2; + uint64 after_bytes = 3; }