9seconds 7 лет назад
Родитель
Сommit
253c705ed6
2 измененных файлов: 12 добавлений и 4 удалений
  1. 6
    3
      config/config.go
  2. 6
    1
      wrappers/mtproto_intermediate_secure.go

+ 6
- 3
config/config.go Просмотреть файл

@@ -67,12 +67,15 @@ func (c *Config) UseMiddleProxy() bool {
67 67
 	return len(c.AdTag) > 0
68 68
 }
69 69
 
70
-func (c *Config) SecretString() string {
70
+// BotSecretString returns secret string which should work with MTProxybot.
71
+func (c *Config) BotSecretString() string {
71 72
 	return hex.EncodeToString(c.Secret)
72 73
 }
73 74
 
74
-func (c *Config) BotSecretString() string {
75
-	secret := c.SecretString()
75
+// SecretString returns a secret in a form entered on the start of the
76
+// application.
77
+func (c *Config) SecretString() string {
78
+	secret := c.BotSecretString()
76 79
 	if c.SecureMode {
77 80
 		return "dd" + secret
78 81
 	}

+ 6
- 1
wrappers/mtproto_intermediate_secure.go Просмотреть файл

@@ -8,6 +8,9 @@ import (
8 8
 	"github.com/9seconds/mtg/mtproto"
9 9
 )
10 10
 
11
+// MTProtoIntermediateSecure is an extension of MTProtoIntermediate
12
+// mode which supports random paddings (socalled 'secure mode' or
13
+// 'dd-secrets').
11 14
 type MTProtoIntermediateSecure struct {
12 15
 	MTProtoIntermediate
13 16
 }
@@ -41,7 +44,7 @@ func (m *MTProtoIntermediateSecure) Write(p []byte) (int, error) {
41 44
 	paddingLength := rand.Intn(4)
42 45
 	buf.Grow(4 + len(p) + paddingLength)
43 46
 
44
-	binary.Write(buf, binary.LittleEndian, uint32(len(p)+paddingLength))
47
+	binary.Write(buf, binary.LittleEndian, uint32(len(p)+paddingLength)) // nolint: errcheck
45 48
 	buf.Write(p)
46 49
 	buf.Write(make([]byte, paddingLength))
47 50
 
@@ -58,6 +61,8 @@ func (m *MTProtoIntermediateSecure) Write(p []byte) (int, error) {
58 61
 	return len(p), err
59 62
 }
60 63
 
64
+// NewMTProtoIntermediateSecure create new instance of
65
+// MTProtoIntermediateSecure instance.
61 66
 func NewMTProtoIntermediateSecure(conn StreamReadWriteCloser, opts *mtproto.ConnectionOpts) PacketReadWriteCloser {
62 67
 	return &MTProtoIntermediateSecure{
63 68
 		MTProtoIntermediate: MTProtoIntermediate{

Загрузка…
Отмена
Сохранить