Fix linting

This commit is contained in:
9seconds
2018-07-12 22:20:17 +03:00
parent e8a3d570d1
commit 253c705ed6
2 changed files with 12 additions and 4 deletions
+6 -3
View File
@@ -67,12 +67,15 @@ func (c *Config) UseMiddleProxy() bool {
return len(c.AdTag) > 0 return len(c.AdTag) > 0
} }
func (c *Config) SecretString() string { // BotSecretString returns secret string which should work with MTProxybot.
func (c *Config) BotSecretString() string {
return hex.EncodeToString(c.Secret) return hex.EncodeToString(c.Secret)
} }
func (c *Config) BotSecretString() string { // SecretString returns a secret in a form entered on the start of the
secret := c.SecretString() // application.
func (c *Config) SecretString() string {
secret := c.BotSecretString()
if c.SecureMode { if c.SecureMode {
return "dd" + secret return "dd" + secret
} }
+6 -1
View File
@@ -8,6 +8,9 @@ import (
"github.com/9seconds/mtg/mtproto" "github.com/9seconds/mtg/mtproto"
) )
// MTProtoIntermediateSecure is an extension of MTProtoIntermediate
// mode which supports random paddings (socalled 'secure mode' or
// 'dd-secrets').
type MTProtoIntermediateSecure struct { type MTProtoIntermediateSecure struct {
MTProtoIntermediate MTProtoIntermediate
} }
@@ -41,7 +44,7 @@ func (m *MTProtoIntermediateSecure) Write(p []byte) (int, error) {
paddingLength := rand.Intn(4) paddingLength := rand.Intn(4)
buf.Grow(4 + len(p) + paddingLength) buf.Grow(4 + len(p) + paddingLength)
binary.Write(buf, binary.LittleEndian, uint32(len(p)+paddingLength)) binary.Write(buf, binary.LittleEndian, uint32(len(p)+paddingLength)) // nolint: errcheck
buf.Write(p) buf.Write(p)
buf.Write(make([]byte, paddingLength)) buf.Write(make([]byte, paddingLength))
@@ -58,6 +61,8 @@ func (m *MTProtoIntermediateSecure) Write(p []byte) (int, error) {
return len(p), err return len(p), err
} }
// NewMTProtoIntermediateSecure create new instance of
// MTProtoIntermediateSecure instance.
func NewMTProtoIntermediateSecure(conn StreamReadWriteCloser, opts *mtproto.ConnectionOpts) PacketReadWriteCloser { func NewMTProtoIntermediateSecure(conn StreamReadWriteCloser, opts *mtproto.ConnectionOpts) PacketReadWriteCloser {
return &MTProtoIntermediateSecure{ return &MTProtoIntermediateSecure{
MTProtoIntermediate: MTProtoIntermediate{ MTProtoIntermediate: MTProtoIntermediate{