mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 20:34:02 +03:00
Rework for simplier proxy
This commit is contained in:
+26
-26
@@ -19,32 +19,7 @@ type MiddleTelegram struct {
|
||||
conf *config.Config
|
||||
}
|
||||
|
||||
func NewMiddleTelegram(conf *config.Config) *MiddleTelegram {
|
||||
tg := &MiddleTelegram{
|
||||
middleTelegramCaller: middleTelegramCaller{
|
||||
baseTelegram: baseTelegram{
|
||||
dialer: tgDialer{
|
||||
Dialer: net.Dialer{Timeout: telegramDialTimeout},
|
||||
conf: conf,
|
||||
},
|
||||
},
|
||||
httpClient: &http.Client{
|
||||
Timeout: middleTelegramHTTPClientTimeout,
|
||||
},
|
||||
dialerMutex: &sync.RWMutex{},
|
||||
},
|
||||
conf: conf,
|
||||
}
|
||||
|
||||
if err := tg.update(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go tg.autoUpdate()
|
||||
|
||||
return tg
|
||||
}
|
||||
|
||||
func (t *MiddleTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.WrapStreamReadWriteCloser) (wrappers.WrapPacketReadWriteCloser, error) {
|
||||
func (t *MiddleTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.WrapStreamReadWriteCloser) (wrappers.Wrap, error) {
|
||||
rpcNonceConn := wrappers.NewMTProtoFrame(conn, rpc.SeqNoNonce)
|
||||
|
||||
rpcNonceReq, err := t.sendRPCNonceRequest(rpcNonceConn)
|
||||
@@ -125,3 +100,28 @@ func (t *MiddleTelegram) receiveRPCHandshakeResponse(conn wrappers.WrapPacketRea
|
||||
|
||||
return rpcHandshakeResp, nil
|
||||
}
|
||||
|
||||
func NewMiddleTelegram(conf *config.Config) Telegram {
|
||||
tg := &MiddleTelegram{
|
||||
middleTelegramCaller: middleTelegramCaller{
|
||||
baseTelegram: baseTelegram{
|
||||
dialer: tgDialer{
|
||||
Dialer: net.Dialer{Timeout: telegramDialTimeout},
|
||||
conf: conf,
|
||||
},
|
||||
},
|
||||
httpClient: &http.Client{
|
||||
Timeout: middleTelegramHTTPClientTimeout,
|
||||
},
|
||||
dialerMutex: &sync.RWMutex{},
|
||||
},
|
||||
conf: conf,
|
||||
}
|
||||
|
||||
if err := tg.update(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go tg.autoUpdate()
|
||||
|
||||
return tg
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user