Merge pull request #17 from iamxvbaba/dev
fix: sync lenient DC-ID validation for key exchange
This commit is contained in:
commit
5dcdb57e4c
5 changed files with 82 additions and 6 deletions
|
|
@ -303,6 +303,21 @@ type Options struct {
|
|||
|
||||
// DC 是本 server 的 DC ID。默认 2。
|
||||
DC int
|
||||
// StrictDC turns on exact DC-ID validation for the permanent-key exchange
|
||||
// (default off = lenient). telesrv is always a single physical backend —
|
||||
// there is no real multi-DC federation behind it — but self-hosted client
|
||||
// forks commonly run in "single-server backend" mode, where dc_id 1..5 all
|
||||
// alias to this one server so that any old data referencing a specific
|
||||
// dc_id still resolves correctly. When a client adds a new local account it
|
||||
// picks its own starting dc_id (its usual multi-DC load-spreading
|
||||
// behavior, unrelated to which physical server it's actually talking to)
|
||||
// — that choice is not guaranteed to equal our configured DC. Strict
|
||||
// validation would reject those accounts with "-444 wrong dc_id" even
|
||||
// though they are connecting to the right (and only) server; dc_id is a
|
||||
// client-side routing label here, not part of key derivation, so
|
||||
// accepting the mismatch does not weaken the exchange. The switch exists
|
||||
// for a hypothetical future real multi-DC deployment.
|
||||
StrictDC bool
|
||||
// RSAKey 是 server RSA 私钥,用于密钥交换。nil 时无法完成握手。
|
||||
RSAKey *rsa.PrivateKey
|
||||
// AuthKeys 持久化 auth key。默认内存实现。
|
||||
|
|
@ -482,6 +497,7 @@ type Server struct {
|
|||
outboundScratchPool *outboundScratchPool
|
||||
|
||||
dc int
|
||||
strictDC bool
|
||||
key exchange.PrivateKey
|
||||
authKeys store.AuthKeyStore
|
||||
conns *SessionManager
|
||||
|
|
@ -533,6 +549,7 @@ func New(opts Options) *Server {
|
|||
outboundControlBudget: newOutboundTrackedBudget(defaultOutboundControlMaxBytes),
|
||||
outboundScratchPool: newOutboundScratchPool(opts.OutboundWriteGlobalMaxBytes),
|
||||
dc: opts.DC,
|
||||
strictDC: opts.StrictDC,
|
||||
key: exchange.PrivateKey{RSA: opts.RSAKey},
|
||||
authKeys: opts.AuthKeys,
|
||||
conns: conns,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue