mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 17:04:02 +03:00
Remove wrap prefix
This commit is contained in:
+2
-4
@@ -30,14 +30,12 @@ func (t *tgDialer) dial(addr string) (net.Conn, error) {
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func (t *tgDialer) dialRWC(addr, connID string) (wrappers.WrapStreamReadWriteCloser, error) {
|
||||
func (t *tgDialer) dialRWC(addr, connID string) (wrappers.StreamReadWriteCloser, error) {
|
||||
conn, err := t.dial(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tgConn := wrappers.NewConn(conn, connID, wrappers.ConnPurposeTelegram,
|
||||
t.conf.PublicIPv4, t.conf.PublicIPv6)
|
||||
tgConn := wrappers.NewConn(conn, connID, wrappers.ConnPurposeTelegram, t.conf.PublicIPv4, t.conf.PublicIPv6)
|
||||
|
||||
return tgConn, nil
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ type DirectTelegram struct {
|
||||
baseTelegram
|
||||
}
|
||||
|
||||
func (t *DirectTelegram) Dial(connID string, connOpts *mtproto.ConnectionOpts) (wrappers.WrapStreamReadWriteCloser, error) {
|
||||
func (t *DirectTelegram) Dial(connID string, connOpts *mtproto.ConnectionOpts) (wrappers.StreamReadWriteCloser, error) {
|
||||
dc := connOpts.DC
|
||||
if dc < 0 {
|
||||
dc = -dc
|
||||
@@ -43,7 +43,7 @@ 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.WrapStreamReadWriteCloser) (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 {
|
||||
|
||||
+5
-5
@@ -19,7 +19,7 @@ type MiddleTelegram struct {
|
||||
conf *config.Config
|
||||
}
|
||||
|
||||
func (t *MiddleTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.WrapStreamReadWriteCloser) (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)
|
||||
@@ -46,7 +46,7 @@ func (t *MiddleTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.Wr
|
||||
return wrappers.NewMTProtoProxy(frameConn, connOpts, t.conf.AdTag)
|
||||
}
|
||||
|
||||
func (t *MiddleTelegram) sendRPCNonceRequest(conn wrappers.WrapPacketWriter) (*rpc.NonceRequest, error) {
|
||||
func (t *MiddleTelegram) sendRPCNonceRequest(conn wrappers.PacketWriter) (*rpc.NonceRequest, error) {
|
||||
rpcNonceReq, err := rpc.NewNonceRequest(t.proxySecret)
|
||||
if err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot create RPC nonce request")
|
||||
@@ -58,7 +58,7 @@ func (t *MiddleTelegram) sendRPCNonceRequest(conn wrappers.WrapPacketWriter) (*r
|
||||
return rpcNonceReq, nil
|
||||
}
|
||||
|
||||
func (t *MiddleTelegram) receiveRPCNonceResponse(conn wrappers.WrapPacketReader, 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")
|
||||
@@ -75,7 +75,7 @@ func (t *MiddleTelegram) receiveRPCNonceResponse(conn wrappers.WrapPacketReader,
|
||||
return rpcNonceResp, nil
|
||||
}
|
||||
|
||||
func (t *MiddleTelegram) sendRPCHandshakeRequest(conn wrappers.WrapPacketWriter) (*rpc.HandshakeRequest, error) {
|
||||
func (t *MiddleTelegram) sendRPCHandshakeRequest(conn wrappers.PacketWriter) (*rpc.HandshakeRequest, error) {
|
||||
req := rpc.NewHandshakeRequest()
|
||||
if _, err := conn.Write(req.Bytes()); err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot send RPC handshake request")
|
||||
@@ -84,7 +84,7 @@ func (t *MiddleTelegram) sendRPCHandshakeRequest(conn wrappers.WrapPacketWriter)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (t *MiddleTelegram) receiveRPCHandshakeResponse(conn wrappers.WrapPacketReader, 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")
|
||||
|
||||
@@ -28,7 +28,7 @@ const (
|
||||
tgUserAgent = "mtg"
|
||||
)
|
||||
|
||||
var middleTelegramProxyConfigSplitter *regexp.Regexp
|
||||
var middleTelegramProxyConfigSplitter = regexp.MustCompile(`\s+`)
|
||||
|
||||
type middleTelegramCaller struct {
|
||||
baseTelegram
|
||||
@@ -38,7 +38,7 @@ type middleTelegramCaller struct {
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
func (t *middleTelegramCaller) Dial(connID string, connOpts *mtproto.ConnectionOpts) (wrappers.WrapStreamReadWriteCloser, error) {
|
||||
func (t *middleTelegramCaller) Dial(connID string, connOpts *mtproto.ConnectionOpts) (wrappers.StreamReadWriteCloser, error) {
|
||||
dc := connOpts.DC
|
||||
if dc == 0 {
|
||||
dc = 1
|
||||
@@ -150,7 +150,3 @@ func (t *middleTelegramCaller) call(url string) (*http.Response, error) {
|
||||
|
||||
return t.httpClient.Do(req)
|
||||
}
|
||||
|
||||
func init() {
|
||||
middleTelegramProxyConfigSplitter = regexp.MustCompile(`\s+`)
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
type Telegram interface {
|
||||
Dial(string, *mtproto.ConnectionOpts) (wrappers.WrapStreamReadWriteCloser, error)
|
||||
Init(*mtproto.ConnectionOpts, wrappers.WrapStreamReadWriteCloser) (wrappers.Wrap, error)
|
||||
Dial(string, *mtproto.ConnectionOpts) (wrappers.StreamReadWriteCloser, error)
|
||||
Init(*mtproto.ConnectionOpts, wrappers.StreamReadWriteCloser) (wrappers.Wrap, error)
|
||||
}
|
||||
|
||||
type baseTelegram struct {
|
||||
@@ -21,7 +21,7 @@ type baseTelegram struct {
|
||||
v6Addresses map[int16][]string
|
||||
}
|
||||
|
||||
func (b *baseTelegram) dial(dcIdx int16, connID string, proto mtproto.ConnectionProtocol) (wrappers.WrapStreamReadWriteCloser, 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