diff --git a/config/config.go b/config/config.go index f5fd97f..52cc25c 100644 --- a/config/config.go +++ b/config/config.go @@ -5,6 +5,7 @@ import ( "fmt" "net" "strconv" + "strings" "github.com/juju/errors" ) @@ -90,6 +91,9 @@ func NewConfig(debug, verbose bool, // nolint: gocyclo publicIPv6 net.IP, publicIPv6Port uint16, statsIP net.IP, statsPort uint16, secret, adtag string) (*Config, error) { + if strings.HasPrefix(secret, "dd") { + secret = secret[2:] + } if len(secret) != 32 { return nil, errors.New("Telegram demands secret of length 32") } diff --git a/mtproto/connection_options.go b/mtproto/connection_options.go index 76d2bfe..0230f5f 100644 --- a/mtproto/connection_options.go +++ b/mtproto/connection_options.go @@ -39,6 +39,7 @@ const ( ConnectionTypeUnknown ConnectionType = iota ConnectionTypeAbridged ConnectionTypeIntermediate + ConnectionTypeSecure ) // ConnectionProtocol* define which connection protocols to use. @@ -53,6 +54,7 @@ const ( var ( ConnectionTagAbridged = []byte{0xef, 0xef, 0xef, 0xef} ConnectionTagIntermediate = []byte{0xee, 0xee, 0xee, 0xee} + ConnectionTagSecure = []byte{0xdd, 0xdd, 0xdd, 0xdd} ) // Tag maps connection type to the corresponding handshake tag. @@ -62,6 +64,8 @@ func (t ConnectionType) Tag() ([]byte, error) { return ConnectionTagAbridged, nil case ConnectionTypeIntermediate: return ConnectionTagIntermediate, nil + case ConnectionTypeSecure: + return ConnectionTagSecure, nil default: return nil, errors.Errorf("Unknown connection type %d", t) } @@ -75,6 +79,9 @@ func ConnectionTagFromHandshake(magic []byte) (ConnectionType, error) { if bytes.Equal(magic, ConnectionTagAbridged) { return ConnectionTypeAbridged, nil } + if bytes.Equal(magic, ConnectionTagSecure) { + return ConnectionTypeSecure, nil + } return ConnectionTypeUnknown, errors.New("Unknown handshake protocol") }