Direct proxy works

This commit is contained in:
9seconds
2019-09-04 10:19:01 +03:00
parent 07985cf418
commit 2492a47d0a
87 changed files with 1883 additions and 1447 deletions
+21
View File
@@ -0,0 +1,21 @@
package protocol
import "github.com/9seconds/mtg/conntypes"
type BaseProtocol struct {
ConnectionType conntypes.ConnectionType
ConnectionProtocol conntypes.ConnectionProtocol
DC conntypes.DC
}
func (b *BaseProtocol) GetConnectionType() conntypes.ConnectionType {
return b.ConnectionType
}
func (b *BaseProtocol) GetConnectionProtocol() conntypes.ConnectionProtocol {
return b.ConnectionProtocol
}
func (b *BaseProtocol) GetDC() conntypes.DC {
return b.DC
}
+22
View File
@@ -0,0 +1,22 @@
package protocol
import (
"github.com/9seconds/mtg/conntypes"
"github.com/9seconds/mtg/telegram"
"github.com/9seconds/mtg/wrappers"
)
type ClientProtocol interface {
Handshake(wrappers.StreamReadWriteCloser) (wrappers.StreamReadWriteCloser, error)
GetConnectionType() conntypes.ConnectionType
GetConnectionProtocol() conntypes.ConnectionProtocol
GetDC() conntypes.DC
}
type ClientProtocolMaker func() ClientProtocol
type TelegramProtocol interface {
Handshake(*TelegramRequest) (wrappers.Wrap, error)
}
type TelegramProtocolMaker func(telegram.Telegram) TelegramProtocol
+18
View File
@@ -0,0 +1,18 @@
package protocol
import (
"context"
"go.uber.org/zap"
"github.com/9seconds/mtg/wrappers"
)
type TelegramRequest struct {
Logger *zap.SugaredLogger
ClientConn wrappers.StreamReadWriteCloser
ConnID wrappers.ConnID
Ctx context.Context
Cancel context.CancelFunc
ClientProtocol ClientProtocol
}