test(mtproto): cover single-backend DC aliases
Follow up gramsrv PR #17 with boundary coverage and public configuration docs.
Canonical-Telesrv: b4df3e72c24470e4ce09e5fc1d46e0c2944f6d3e
Reviewed-Head: e7eb07b9eb
Co-authored-by: onysd <beatvin128@gmail.com>
This commit is contained in:
parent
5dcdb57e4c
commit
9ef746d45e
8 changed files with 127 additions and 69 deletions
|
|
@ -25,14 +25,12 @@ import (
|
|||
|
||||
// runServerExchange is a gotd server exchange compatibility shim.
|
||||
//
|
||||
// DrKLO Android marks media temporary auth-key exchange with a negative DC in
|
||||
// p_q_inner_data_temp_dc (for example DC 2 -> -2). gotd v0.158.0 validates this
|
||||
// field by exact equality and rejects that legitimate media-temp path. The
|
||||
// temp-key DC check accepts any value whose absolute value matches this
|
||||
// server DC. The permanent-key check is lenient by default too (see
|
||||
// Options.StrictDC doc) — self-hosted single-server deployments commonly
|
||||
// have clients that alias dc_id 1..5 to the one backend, so a client-chosen
|
||||
// dc_id that isn't our configured DC is expected, not an error.
|
||||
// In the default single-backend mode, p_q_inner_data_dc and
|
||||
// p_q_inner_data_temp_dc carry client routing labels only: every int32 value is
|
||||
// admitted and the label is not persisted or used for key/session identity.
|
||||
// This also covers DrKLO Android's negative media-temp labels. StrictDC retains
|
||||
// exact permanent / absolute-value temporary validation as an explicit,
|
||||
// default-off diagnostic for a future real multi-DC deployment.
|
||||
func (s *Server) runServerExchange(ctx context.Context, conn transport.Conn) (exchange.ServerExchangeResult, error) {
|
||||
ex := serverExchangeCompat{
|
||||
conn: conn,
|
||||
|
|
@ -351,14 +349,7 @@ func (s serverExchangeCompat) validatePQInnerDataDC(d mt.PQInnerDataClass) error
|
|||
case *mt.PQInnerDataDC:
|
||||
if innerDataDC.DC != s.dc {
|
||||
if !s.strictDC {
|
||||
// Lenient by default (Options.StrictDC doc has the full
|
||||
// rationale): telesrv is a single physical backend, and
|
||||
// self-hosted client forks commonly alias dc_id 1..5 to this
|
||||
// one server, so a client-chosen dc_id that isn't our
|
||||
// configured DC is expected, not an error. dc_id plays no
|
||||
// role in key derivation, so accepting it doesn't weaken the
|
||||
// exchange.
|
||||
s.log.Debug("Accepted permanent auth key DC mismatch (lenient mode)",
|
||||
s.log.Debug("Accepted permanent auth key DC alias",
|
||||
zap.Int("server_dc", s.dc),
|
||||
zap.Int("client_dc", innerDataDC.DC))
|
||||
return nil
|
||||
|
|
@ -369,8 +360,8 @@ func (s serverExchangeCompat) validatePQInnerDataDC(d mt.PQInnerDataClass) error
|
|||
if !sameDCByAbs(innerDataDC.DC, s.dc) && s.strictDC {
|
||||
return wrongDCError(s.dc, innerDataDC.DC)
|
||||
}
|
||||
if innerDataDC.DC < 0 {
|
||||
s.log.Warn("Accepted Android media temp auth key negative DC",
|
||||
if !sameDCByAbs(innerDataDC.DC, s.dc) {
|
||||
s.log.Debug("Accepted temporary auth key DC alias",
|
||||
zap.Int("server_dc", s.dc),
|
||||
zap.Int("client_dc", innerDataDC.DC),
|
||||
zap.Int("expires_in", innerDataDC.ExpiresIn))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue