New config file

This commit is contained in:
Meo597 2025-06-08 20:51:38 +08:00
parent 002da9a24b
commit 461526a265
6 changed files with 36 additions and 34 deletions

4
go.mod
View file

@ -20,7 +20,7 @@ require (
github.com/stretchr/testify v1.10.0 github.com/stretchr/testify v1.10.0
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e
github.com/vishvananda/netlink v1.3.1 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 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
golang.org/x/crypto v0.39.0 golang.org/x/crypto v0.39.0
golang.org/x/net v0.41.0 golang.org/x/net v0.41.0
@ -35,7 +35,7 @@ require (
) )
// [TODO] Temp: use forked reality until upstream merges #12 // [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 ( require (
github.com/andybalholm/brotli v1.1.0 // indirect github.com/andybalholm/brotli v1.1.0 // indirect

4
go.sum
View file

@ -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/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 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= 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-20250608122607-d4826882fcab h1:aEcdfNMR3/SFUP2PRvqYeIpHLtta+vvJ2BGwEoS2tHk=
github.com/meo597/reality v0.0.0-20250608065753-4b636d90bde2/go.mod h1:yD47RN65bDLZgyHWMfFDiqlzrq4usDMt/Xzsk6tMbhw= 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 h1:FeZXOS3VCVsKnEAd+wBkjMC3D2K+ww66Cq3VnCINuJE=
github.com/miekg/dns v1.1.66/go.mod h1:jGFzBsSNbJw6z1HYut1RKBKHA9PBdxeHrZG8J+gC2WE= github.com/miekg/dns v1.1.66/go.mod h1:jGFzBsSNbJw6z1HYut1RKBKHA9PBdxeHrZG8J+gC2WE=
github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA=

View file

@ -486,6 +486,12 @@ func (c *TLSConfig) Build() (proto.Message, error) {
return config, nil return config, nil
} }
type LimitFallback struct {
AfterBytes uint64
BytesPerSec uint64
BurstBytesPerSec uint64
}
type REALITYConfig struct { type REALITYConfig struct {
MasterKeyLog string `json:"masterKeyLog"` MasterKeyLog string `json:"masterKeyLog"`
Show bool `json:"show"` Show bool `json:"show"`
@ -500,12 +506,8 @@ type REALITYConfig struct {
MaxTimeDiff uint64 `json:"maxTimeDiff"` MaxTimeDiff uint64 `json:"maxTimeDiff"`
ShortIds []string `json:"shortIds"` ShortIds []string `json:"shortIds"`
LimitFbUploadRate float64 `json:"limitFbUploadRate"` LimitFallbackUpload LimitFallback `json:"LimitFallbackUpload"`
LimitFbUploadBurst int64 `json:"limitFbUploadBurst"` LimitFallbackDownload LimitFallback `json:"LimitFallbackDownload"`
LimitFbUploadAfter int64 `json:"limitFbUploadAfter"`
LimitFbDownloadRate float64 `json:"limitFbDownloadRate"`
LimitFbDownloadBurst int64 `json:"limitFbDownloadBurst"`
LimitFbDownloadAfter int64 `json:"limitFbDownloadAfter"`
Fingerprint string `json:"fingerprint"` Fingerprint string `json:"fingerprint"`
ServerName string `json:"serverName"` ServerName string `json:"serverName"`
@ -609,13 +611,13 @@ func (c *REALITYConfig) Build() (proto.Message, error) {
config.MaxTimeDiff = c.MaxTimeDiff config.MaxTimeDiff = c.MaxTimeDiff
config.LimitFallbackUpload = new(reality.LimitFallback) config.LimitFallbackUpload = new(reality.LimitFallback)
config.LimitFallbackUpload.BytesPerSec = c.LimitFbUploadRate config.LimitFallbackUpload.BytesPerSec = c.LimitFallbackUpload.BytesPerSec
config.LimitFallbackUpload.BurstBytesPerSec = c.LimitFbUploadBurst config.LimitFallbackUpload.BurstBytesPerSec = c.LimitFallbackUpload.BurstBytesPerSec
config.LimitFallbackUpload.AfterBytes = c.LimitFbUploadAfter config.LimitFallbackUpload.AfterBytes = c.LimitFallbackUpload.AfterBytes
config.LimitFallbackDownload = new(reality.LimitFallback) config.LimitFallbackDownload = new(reality.LimitFallback)
config.LimitFallbackDownload.BytesPerSec = c.LimitFbDownloadRate config.LimitFallbackDownload.BytesPerSec = c.LimitFallbackDownload.BytesPerSec
config.LimitFallbackDownload.BurstBytesPerSec = c.LimitFbDownloadBurst config.LimitFallbackDownload.BurstBytesPerSec = c.LimitFallbackDownload.BurstBytesPerSec
config.LimitFallbackDownload.AfterBytes = c.LimitFbDownloadAfter config.LimitFallbackDownload.AfterBytes = c.LimitFallbackDownload.AfterBytes
} else { } else {
config.Fingerprint = strings.ToLower(c.Fingerprint) config.Fingerprint = strings.ToLower(c.Fingerprint)
if config.Fingerprint == "unsafe" || config.Fingerprint == "hellogolang" { if config.Fingerprint == "unsafe" || config.Fingerprint == "hellogolang" {

View file

@ -33,14 +33,14 @@ func (c *Config) GetREALITYConfig() *reality.Config {
KeyLogWriter: KeyLogWriterFromConfig(c), KeyLogWriter: KeyLogWriterFromConfig(c),
} }
if c.LimitFallbackUpload != nil { if c.LimitFallbackUpload != nil {
config.LimitFbUploadRate = c.LimitFallbackUpload.BytesPerSec config.LimitFallbackUpload.BytesPerSec = c.LimitFallbackUpload.BytesPerSec
config.LimitFbUploadBurst = c.LimitFallbackUpload.BurstBytesPerSec config.LimitFallbackUpload.BurstBytesPerSec = c.LimitFallbackUpload.BurstBytesPerSec
config.LimitFbUploadAfter = c.LimitFallbackUpload.AfterBytes config.LimitFallbackUpload.AfterBytes = c.LimitFallbackUpload.AfterBytes
} }
if c.LimitFallbackDownload != nil { if c.LimitFallbackDownload != nil {
config.LimitFbDownloadRate = c.LimitFallbackDownload.BytesPerSec config.LimitFallbackDownload.BytesPerSec = c.LimitFallbackDownload.BytesPerSec
config.LimitFbDownloadBurst = c.LimitFallbackDownload.BurstBytesPerSec config.LimitFallbackDownload.BurstBytesPerSec = c.LimitFallbackDownload.BurstBytesPerSec
config.LimitFbDownloadAfter = c.LimitFallbackDownload.AfterBytes config.LimitFallbackDownload.AfterBytes = c.LimitFallbackDownload.AfterBytes
} }
config.ServerNames = make(map[string]bool) config.ServerNames = make(map[string]bool)
for _, serverName := range c.ServerNames { for _, serverName := range c.ServerNames {

View file

@ -214,9 +214,9 @@ type LimitFallback struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
BytesPerSec float64 `protobuf:"fixed64,1,opt,name=bytes_per_sec,json=bytesPerSec,proto3" json:"bytes_per_sec,omitempty"` BytesPerSec uint64 `protobuf:"varint,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"` BurstBytesPerSec uint64 `protobuf:"varint,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"` AfterBytes uint64 `protobuf:"varint,3,opt,name=after_bytes,json=afterBytes,proto3" json:"after_bytes,omitempty"`
} }
func (x *LimitFallback) Reset() { func (x *LimitFallback) Reset() {
@ -249,21 +249,21 @@ func (*LimitFallback) Descriptor() ([]byte, []int) {
return file_transport_internet_reality_config_proto_rawDescGZIP(), []int{1} return file_transport_internet_reality_config_proto_rawDescGZIP(), []int{1}
} }
func (x *LimitFallback) GetBytesPerSec() float64 { func (x *LimitFallback) GetBytesPerSec() uint64 {
if x != nil { if x != nil {
return x.BytesPerSec return x.BytesPerSec
} }
return 0 return 0
} }
func (x *LimitFallback) GetBurstBytesPerSec() int64 { func (x *LimitFallback) GetBurstBytesPerSec() uint64 {
if x != nil { if x != nil {
return x.BurstBytesPerSec return x.BurstBytesPerSec
} }
return 0 return 0
} }
func (x *LimitFallback) GetAfterBytes() int64 { func (x *LimitFallback) GetAfterBytes() uint64 {
if x != nil { if x != nil {
return x.AfterBytes 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x2e, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68,

View file

@ -31,7 +31,7 @@ message Config {
} }
message LimitFallback { message LimitFallback {
double bytes_per_sec = 1; uint64 bytes_per_sec = 1;
sint64 burst_bytes_per_sec = 2; uint64 burst_bytes_per_sec = 2;
sint64 after_bytes = 3; uint64 after_bytes = 3;
} }