From b16d2e946311963e8b20be130e9c7dd66da9d544 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 4 Jul 2018 22:26:15 +0200 Subject: [PATCH] make sure dc id is valid. --- proxy/mtproto/auth.go | 2 +- proxy/mtproto/server.go | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/proxy/mtproto/auth.go b/proxy/mtproto/auth.go index aee01064d..962bc1c39 100644 --- a/proxy/mtproto/auth.go +++ b/proxy/mtproto/auth.go @@ -22,7 +22,7 @@ type Authentication struct { } func (a *Authentication) DataCenterID() uint16 { - return (uint16(a.Header[61]) << 8) | uint16(a.Header[60]) + return ((uint16(a.Header[61]) << 8) | uint16(a.Header[60])) % uint16(len(dcList)) } func (a *Authentication) ApplySecret(b []byte) { diff --git a/proxy/mtproto/server.go b/proxy/mtproto/server.go index eba1c684f..a645d470f 100644 --- a/proxy/mtproto/server.go +++ b/proxy/mtproto/server.go @@ -90,9 +90,6 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn internet } dcID := auth.DataCenterID() - if dcID >= uint16(len(dcList)) { - return newError("invalid data center id: ", dcID) - } dest := net.Destination{ Network: net.Network_TCP,