mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 16:01:55 +03:00
Switch to golangci-lint
This commit is contained in:
+21
-18
@@ -13,18 +13,18 @@ import (
|
||||
|
||||
var (
|
||||
directV4Addresses = map[int16][]string{
|
||||
0: []string{"149.154.175.50:443"},
|
||||
1: []string{"149.154.167.51:443"},
|
||||
2: []string{"149.154.175.100:443"},
|
||||
3: []string{"149.154.167.91:443"},
|
||||
4: []string{"149.154.171.5:443"},
|
||||
0: {"149.154.175.50:443"},
|
||||
1: {"149.154.167.51:443"},
|
||||
2: {"149.154.175.100:443"},
|
||||
3: {"149.154.167.91:443"},
|
||||
4: {"149.154.171.5:443"},
|
||||
}
|
||||
directV6Addresses = map[int16][]string{
|
||||
0: []string{"[2001:b28:f23d:f001::a]:443"},
|
||||
1: []string{"[2001:67c:04e8:f002::a]:443"},
|
||||
2: []string{"[2001:b28:f23d:f003::a]:443"},
|
||||
3: []string{"[2001:67c:04e8:f004::a]:443"},
|
||||
4: []string{"[2001:b28:f23f:f005::a]:443"},
|
||||
0: {"[2001:b28:f23d:f001::a]:443"},
|
||||
1: {"[2001:67c:04e8:f002::a]:443"},
|
||||
2: {"[2001:b28:f23d:f003::a]:443"},
|
||||
3: {"[2001:67c:04e8:f004::a]:443"},
|
||||
4: {"[2001:b28:f23f:f005::a]:443"},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -43,7 +43,8 @@ func (t *directTelegram) Dial(connID string, connOpts *mtproto.ConnectionOpts) (
|
||||
return t.baseTelegram.dial(dc-1, connID, connOpts.ConnectionProto)
|
||||
}
|
||||
|
||||
func (t *directTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.StreamReadWriteCloser) (wrappers.Wrap, error) {
|
||||
func (t *directTelegram) Init(connOpts *mtproto.ConnectionOpts,
|
||||
conn wrappers.StreamReadWriteCloser) (wrappers.Wrap, error) {
|
||||
obfs2, frame := obfuscated2.MakeTelegramObfuscated2Frame(connOpts)
|
||||
|
||||
if _, err := conn.Write(frame); err != nil {
|
||||
@@ -56,12 +57,14 @@ func (t *directTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.St
|
||||
// NewDirectTelegram returns Telegram instance which connects directly
|
||||
// to Telegram bypassing middleproxies.
|
||||
func NewDirectTelegram(conf *config.Config) Telegram {
|
||||
return &directTelegram{baseTelegram{
|
||||
dialer: tgDialer{
|
||||
Dialer: net.Dialer{Timeout: telegramDialTimeout},
|
||||
conf: conf,
|
||||
return &directTelegram{
|
||||
baseTelegram: baseTelegram{
|
||||
dialer: tgDialer{
|
||||
Dialer: net.Dialer{Timeout: telegramDialTimeout},
|
||||
conf: conf,
|
||||
},
|
||||
v4Addresses: directV4Addresses,
|
||||
v6Addresses: directV6Addresses,
|
||||
},
|
||||
v4Addresses: directV4Addresses,
|
||||
v6Addresses: directV6Addresses,
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -20,7 +20,8 @@ type middleTelegram struct {
|
||||
conf *config.Config
|
||||
}
|
||||
|
||||
func (t *middleTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.StreamReadWriteCloser) (wrappers.Wrap, error) {
|
||||
func (t *middleTelegram) Init(connOpts *mtproto.ConnectionOpts,
|
||||
conn wrappers.StreamReadWriteCloser) (wrappers.Wrap, error) {
|
||||
rpcNonceConn := wrappers.NewMTProtoFrame(conn, rpc.SeqNoNonce)
|
||||
|
||||
rpcNonceReq, err := t.sendRPCNonceRequest(rpcNonceConn)
|
||||
@@ -65,7 +66,8 @@ func (t *middleTelegram) sendRPCNonceRequest(conn io.Writer) (*rpc.NonceRequest,
|
||||
return rpcNonceReq, nil
|
||||
}
|
||||
|
||||
func (t *middleTelegram) receiveRPCNonceResponse(conn wrappers.PacketReader, req *rpc.NonceRequest) (*rpc.NonceResponse, error) {
|
||||
func (t *middleTelegram) receiveRPCNonceResponse(conn wrappers.PacketReader,
|
||||
req *rpc.NonceRequest) (*rpc.NonceResponse, error) {
|
||||
packet, err := conn.Read()
|
||||
if err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot read RPC nonce response")
|
||||
@@ -91,7 +93,8 @@ func (t *middleTelegram) sendRPCHandshakeRequest(conn io.Writer) (*rpc.Handshake
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (t *middleTelegram) receiveRPCHandshakeResponse(conn wrappers.PacketReader, req *rpc.HandshakeRequest) (*rpc.HandshakeResponse, error) {
|
||||
func (t *middleTelegram) receiveRPCHandshakeResponse(conn wrappers.PacketReader,
|
||||
req *rpc.HandshakeRequest) (*rpc.HandshakeResponse, error) {
|
||||
packet, err := conn.Read()
|
||||
if err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot read RPC handshake response")
|
||||
|
||||
@@ -38,7 +38,8 @@ type middleTelegramCaller struct {
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
func (t *middleTelegramCaller) Dial(connID string, connOpts *mtproto.ConnectionOpts) (wrappers.StreamReadWriteCloser, error) {
|
||||
func (t *middleTelegramCaller) Dial(connID string,
|
||||
connOpts *mtproto.ConnectionOpts) (wrappers.StreamReadWriteCloser, error) {
|
||||
dc := connOpts.DC
|
||||
if dc == 0 {
|
||||
dc = 1
|
||||
|
||||
@@ -22,7 +22,8 @@ type baseTelegram struct {
|
||||
v6Addresses map[int16][]string
|
||||
}
|
||||
|
||||
func (b *baseTelegram) dial(dcIdx int16, connID string, proto mtproto.ConnectionProtocol) (wrappers.StreamReadWriteCloser, error) {
|
||||
func (b *baseTelegram) dial(dcIdx int16, connID string,
|
||||
proto mtproto.ConnectionProtocol) (wrappers.StreamReadWriteCloser, error) {
|
||||
addrs := make([]string, 2)
|
||||
|
||||
if proto&mtproto.ConnectionProtocolIPv6 != 0 {
|
||||
|
||||
Reference in New Issue
Block a user