Remove length limit on short_id for reality TLS config

This commit is contained in:
世界
2023-03-13 13:34:11 +08:00
parent b004b9ec81
commit 70cf681ff2
4 changed files with 14 additions and 13 deletions

View File

@@ -89,16 +89,16 @@ func NewRealityServer(ctx context.Context, router adapter.Router, logger log.Log
tlsConfig.MaxTimeDiff = time.Duration(options.Reality.MaxTimeDifference)
tlsConfig.ShortIds = make(map[[8]byte]bool)
for i, shortID := range options.Reality.ShortID {
var shortIDBytesArray [8]byte
decodedLen, err := hex.Decode(shortIDBytesArray[:], []byte(shortID))
for i, shortIDString := range options.Reality.ShortID {
var shortID [8]byte
decodedLen, err := hex.Decode(shortID[:], []byte(shortIDString))
if err != nil {
return nil, E.Cause(err, "decode short_id[", i, "]: ", shortID)
return nil, E.Cause(err, "decode short_id[", i, "]: ", shortIDString)
}
if decodedLen != 8 {
return nil, E.New("invalid short_id[", i, "]: ", shortID)
if decodedLen > 8 {
return nil, E.New("invalid short_id[", i, "]: ", shortIDString)
}
tlsConfig.ShortIds[shortIDBytesArray] = true
tlsConfig.ShortIds[shortID] = true
}
handshakeDialer := dialer.New(router, options.Reality.Handshake.DialerOptions)