mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 22:14:02 +03:00
Merge remote-tracking branch 'origin/master' into stable
This commit is contained in:
@@ -6,10 +6,7 @@ CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{38
|
||||
|
||||
GOLANGCI_LINT_VERSION := v1.21.0
|
||||
|
||||
VERSION_GO := $(shell go version)
|
||||
VERSION_DATE := $(shell date -Ru)
|
||||
VERSION_TAG := $(shell git describe --tags --always)
|
||||
COMMON_BUILD_FLAGS := -ldflags="-s -w -X 'main.version=$(VERSION_TAG) ($(VERSION_GO)) [$(VERSION_DATE)]'"
|
||||
COMMON_BUILD_FLAGS := -ldflags="-s -w"
|
||||
|
||||
MOD_ON := env GO111MODULE=on
|
||||
MOD_OFF := env GO111MODULE=auto
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/VictoriaMetrics/fastcache"
|
||||
|
||||
"mtg/config"
|
||||
"github.com/9seconds/mtg/config"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
|
||||
"mtg/config"
|
||||
"github.com/9seconds/mtg/config"
|
||||
)
|
||||
|
||||
func Generate(secretType, hostname string) {
|
||||
|
||||
+10
-10
@@ -8,16 +8,16 @@ import (
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"mtg/antireplay"
|
||||
"mtg/config"
|
||||
"mtg/faketls"
|
||||
"mtg/hub"
|
||||
"mtg/ntp"
|
||||
"mtg/obfuscated2"
|
||||
"mtg/proxy"
|
||||
"mtg/stats"
|
||||
"mtg/telegram"
|
||||
"mtg/utils"
|
||||
"github.com/9seconds/mtg/antireplay"
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/faketls"
|
||||
"github.com/9seconds/mtg/hub"
|
||||
"github.com/9seconds/mtg/ntp"
|
||||
"github.com/9seconds/mtg/obfuscated2"
|
||||
"github.com/9seconds/mtg/proxy"
|
||||
"github.com/9seconds/mtg/stats"
|
||||
"github.com/9seconds/mtg/telegram"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
)
|
||||
|
||||
func Proxy() error { // nolint: funlen
|
||||
|
||||
@@ -11,14 +11,14 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"mtg/antireplay"
|
||||
"mtg/config"
|
||||
"mtg/conntypes"
|
||||
"mtg/obfuscated2"
|
||||
"mtg/protocol"
|
||||
"mtg/stats"
|
||||
"mtg/tlstypes"
|
||||
"mtg/wrappers/stream"
|
||||
"github.com/9seconds/mtg/antireplay"
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/obfuscated2"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
"github.com/9seconds/mtg/stats"
|
||||
"github.com/9seconds/mtg/tlstypes"
|
||||
"github.com/9seconds/mtg/wrappers/stream"
|
||||
)
|
||||
|
||||
type ClientProtocol struct {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module mtg
|
||||
module github.com/9seconds/mtg
|
||||
|
||||
go 1.13
|
||||
|
||||
@@ -13,8 +13,8 @@ require (
|
||||
go.uber.org/multierr v1.4.0 // indirect
|
||||
go.uber.org/zap v1.13.0
|
||||
golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f
|
||||
golang.org/x/net v0.0.0-20191116160921-f9c825593386 // indirect
|
||||
golang.org/x/sys v0.0.0-20191118013547-6254a7c3cac6
|
||||
golang.org/x/tools v0.0.0-20191118051429-5a76f03bc7c3 // indirect
|
||||
golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 // indirect
|
||||
golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2
|
||||
golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98 // indirect
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6
|
||||
)
|
||||
|
||||
@@ -139,8 +139,8 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191116160921-f9c825593386 h1:ktbWvQrW08Txdxno1PiDpSxPXG6ndGsfnJjRRtkM0LQ=
|
||||
golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4=
|
||||
golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -153,16 +153,16 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191118013547-6254a7c3cac6 h1:8mlr2HX+lfl0eaQcjiHfVeM2FHxWkuYQ5a2Wcy8mE1s=
|
||||
golang.org/x/sys v0.0.0-20191118013547-6254a7c3cac6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2 h1:wAW1U21MfVN0sUipAD8952TBjGXMRHFKQugDlQ9RwwE=
|
||||
golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191118051429-5a76f03bc7c3 h1:3gzOmNy3PLCZ+3Ru/n5Gh7pPjsieiytYSDxFj6QY/oI=
|
||||
golang.org/x/tools v0.0.0-20191118051429-5a76f03bc7c3/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98 h1:tZwpOHmF1OEL9wJGSgBALnhFg/8VKjQTtctCX51GLNI=
|
||||
golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
|
||||
+4
-4
@@ -7,10 +7,10 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/mtproto"
|
||||
"mtg/mtproto/rpc"
|
||||
"mtg/protocol"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/mtproto"
|
||||
"github.com/9seconds/mtg/mtproto/rpc"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
)
|
||||
|
||||
type connection struct {
|
||||
|
||||
@@ -4,18 +4,14 @@ import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"mtg/config"
|
||||
"github.com/9seconds/mtg/config"
|
||||
)
|
||||
|
||||
type connectionList struct {
|
||||
connections []*connection
|
||||
}
|
||||
|
||||
func (c *connectionList) Get(conn *ProxyConn) (*connection, error) {
|
||||
if len(c.connections) > 0 {
|
||||
c.gc()
|
||||
}
|
||||
|
||||
func (c *connectionList) get(conn *ProxyConn) (*connection, error) {
|
||||
if len(c.connections) > 0 && c.connections[0].Len() < config.C.MultiplexPerConnection {
|
||||
if err := c.connections[0].Attach(conn); err == nil {
|
||||
return c.connections[0], nil
|
||||
@@ -41,6 +37,9 @@ func (c *connectionList) Get(conn *ProxyConn) (*connection, error) {
|
||||
|
||||
func (c *connectionList) gc() {
|
||||
prevLen := len(c.connections)
|
||||
if prevLen == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for i := len(c.connections) - 1; i >= 0; i-- {
|
||||
lastIndex := len(c.connections) - 1
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"mtg/protocol"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
)
|
||||
|
||||
type hub struct {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package hub
|
||||
|
||||
import "mtg/protocol"
|
||||
import "github.com/9seconds/mtg/protocol"
|
||||
|
||||
type Interface interface {
|
||||
Register(*protocol.TelegramRequest) (*ProxyConn, error)
|
||||
|
||||
+12
-3
@@ -2,11 +2,14 @@ package hub
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/protocol"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
)
|
||||
|
||||
const muxGCEvery = time.Minute
|
||||
|
||||
type muxNewRequest struct {
|
||||
req *protocol.TelegramRequest
|
||||
resp chan<- muxNewResponse
|
||||
@@ -26,6 +29,9 @@ type mux struct {
|
||||
}
|
||||
|
||||
func (m *mux) run() {
|
||||
gcTicker := time.NewTicker(muxGCEvery)
|
||||
defer gcTicker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-m.ctx.Done():
|
||||
@@ -34,9 +40,12 @@ func (m *mux) run() {
|
||||
}
|
||||
|
||||
return
|
||||
case <-gcTicker.C:
|
||||
m.connections.gc()
|
||||
case req := <-m.channelNew:
|
||||
m.connections.gc()
|
||||
proxyConn := newProxyConn(req.req, m.channelClosed)
|
||||
conn, err := m.connections.Get(proxyConn)
|
||||
conn, err := m.connections.get(proxyConn)
|
||||
|
||||
if err == nil {
|
||||
m.clients[string(req.req.ConnID[:])] = conn
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/mtproto/rpc"
|
||||
"mtg/protocol"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/mtproto/rpc"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -3,17 +3,17 @@ package main
|
||||
import (
|
||||
"math/rand"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
|
||||
"mtg/cli"
|
||||
"mtg/config"
|
||||
"mtg/utils"
|
||||
"github.com/9seconds/mtg/cli"
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
)
|
||||
|
||||
var version = "dev" // this has to be set by build ld flags
|
||||
|
||||
var (
|
||||
app = kingpin.New("mtg", "Simple MTPROTO proxy.")
|
||||
|
||||
@@ -114,7 +114,7 @@ var (
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
app.Version(version)
|
||||
app.Version(getVersion())
|
||||
app.HelpFlag.Short('h')
|
||||
|
||||
if err := utils.SetLimits(); err != nil {
|
||||
@@ -153,3 +153,26 @@ func main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getVersion() string {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
builder := strings.Builder{}
|
||||
version := info.Main.Version
|
||||
|
||||
if version == "(devel)" {
|
||||
version = "dev"
|
||||
}
|
||||
|
||||
builder.WriteString(version)
|
||||
|
||||
if info.Main.Sum != "" {
|
||||
builder.WriteString(" (checksum: ")
|
||||
builder.WriteString(info.Main.Sum)
|
||||
builder.WriteRune(')')
|
||||
}
|
||||
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
return "dev"
|
||||
}
|
||||
|
||||
+6
-6
@@ -3,12 +3,12 @@ package mtproto
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/mtproto/rpc"
|
||||
"mtg/protocol"
|
||||
"mtg/telegram"
|
||||
"mtg/wrappers/packet"
|
||||
"mtg/wrappers/stream"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/mtproto/rpc"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
"github.com/9seconds/mtg/telegram"
|
||||
"github.com/9seconds/mtg/wrappers/packet"
|
||||
"github.com/9seconds/mtg/wrappers/stream"
|
||||
)
|
||||
|
||||
func TelegramProtocol(req *protocol.TelegramRequest) (conntypes.PacketReadWriteCloser, error) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
type ProxyResponseType uint8
|
||||
|
||||
@@ -9,13 +9,13 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"mtg/antireplay"
|
||||
"mtg/config"
|
||||
"mtg/conntypes"
|
||||
"mtg/protocol"
|
||||
"mtg/stats"
|
||||
"mtg/utils"
|
||||
"mtg/wrappers/stream"
|
||||
"github.com/9seconds/mtg/antireplay"
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
"github.com/9seconds/mtg/stats"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
"github.com/9seconds/mtg/wrappers/stream"
|
||||
)
|
||||
|
||||
const clientProtocolHandshakeTimeout = 10 * time.Second
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/protocol"
|
||||
"mtg/telegram"
|
||||
"mtg/utils"
|
||||
"mtg/wrappers/stream"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
"github.com/9seconds/mtg/telegram"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
"github.com/9seconds/mtg/wrappers/stream"
|
||||
)
|
||||
|
||||
func TelegramProtocol(req *protocol.TelegramRequest) (conntypes.StreamReadWriteCloser, error) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package protocol
|
||||
|
||||
import "mtg/conntypes"
|
||||
import "github.com/9seconds/mtg/conntypes"
|
||||
|
||||
type ClientProtocol interface {
|
||||
Handshake(conntypes.StreamReadWriteCloser) (conntypes.StreamReadWriteCloser, error)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
type TelegramRequest struct {
|
||||
|
||||
+3
-3
@@ -6,9 +6,9 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/obfuscated2"
|
||||
"mtg/protocol"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/obfuscated2"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
)
|
||||
|
||||
const directPipeBufferSize = 1024 * 1024
|
||||
|
||||
+3
-3
@@ -5,9 +5,9 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/protocol"
|
||||
"mtg/wrappers/packetack"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
"github.com/9seconds/mtg/wrappers/packetack"
|
||||
)
|
||||
|
||||
func middleConnection(request *protocol.TelegramRequest) {
|
||||
|
||||
+6
-6
@@ -6,12 +6,12 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/config"
|
||||
"mtg/conntypes"
|
||||
"mtg/protocol"
|
||||
"mtg/stats"
|
||||
"mtg/utils"
|
||||
"mtg/wrappers/stream"
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
"github.com/9seconds/mtg/stats"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
"github.com/9seconds/mtg/wrappers/stream"
|
||||
)
|
||||
|
||||
type Proxy struct {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package stats
|
||||
import (
|
||||
"net"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
type IngressTrafficInterface interface {
|
||||
|
||||
@@ -3,7 +3,7 @@ package stats
|
||||
import (
|
||||
"net"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
type multiStats []Interface
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"mtg/config"
|
||||
"github.com/9seconds/mtg/config"
|
||||
)
|
||||
|
||||
var Stats Interface
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
"mtg/config"
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
type statsPrometheus struct {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
statsd "github.com/smira/go-statsd"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/config"
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
apiUserAgent = "mtg"
|
||||
apiUserAgent = "github.com/9seconds/mtg"
|
||||
apiHTTPTimeout = 30 * time.Second
|
||||
)
|
||||
|
||||
|
||||
+3
-3
@@ -5,9 +5,9 @@ import (
|
||||
"math/rand"
|
||||
"net"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/utils"
|
||||
"mtg/wrappers/stream"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
"github.com/9seconds/mtg/wrappers/stream"
|
||||
)
|
||||
|
||||
type baseTelegram struct {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package telegram
|
||||
|
||||
import "mtg/conntypes"
|
||||
import "github.com/9seconds/mtg/conntypes"
|
||||
|
||||
const (
|
||||
directV4DefaultIdx conntypes.DC = 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package telegram
|
||||
|
||||
import "mtg/conntypes"
|
||||
import "github.com/9seconds/mtg/conntypes"
|
||||
|
||||
type Telegram interface {
|
||||
Dial(conntypes.DC, conntypes.ConnectionProtocol) (conntypes.StreamReadWriteCloser, error)
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/telegram/api"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/telegram/api"
|
||||
)
|
||||
|
||||
const middleTelegramBackgroundUpdateEvery = time.Hour
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
|
||||
"mtg/config"
|
||||
"mtg/utils"
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
)
|
||||
|
||||
type ClientHello struct {
|
||||
|
||||
@@ -3,7 +3,7 @@ package tlstypes
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"mtg/utils"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
)
|
||||
|
||||
type Handshake struct {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"golang.org/x/crypto/curve25519"
|
||||
|
||||
"mtg/config"
|
||||
"github.com/9seconds/mtg/config"
|
||||
)
|
||||
|
||||
type ServerHello struct {
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"mtg/config"
|
||||
"github.com/9seconds/mtg/config"
|
||||
)
|
||||
|
||||
func InitTCP(conn net.Conn) error {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/utils"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
const clientIntermediateQuickAckLength = 0x80000000
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
type wrapperClientIntermediateSecure struct {
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"mtg/config"
|
||||
"mtg/conntypes"
|
||||
"mtg/hub"
|
||||
"mtg/mtproto/rpc"
|
||||
"mtg/protocol"
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/hub"
|
||||
"github.com/9seconds/mtg/mtproto/rpc"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
)
|
||||
|
||||
type wrapperProxy struct {
|
||||
|
||||
@@ -3,7 +3,7 @@ package stream
|
||||
import (
|
||||
"net"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
func NewClientConn(parent net.Conn, connID conntypes.ConnID) conntypes.StreamReadWriteCloser {
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/utils"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
)
|
||||
|
||||
type wrapperBlockCipher struct {
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/config"
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
type connPurpose uint8
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
type wrapperCtx struct {
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/tlstypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/tlstypes"
|
||||
)
|
||||
|
||||
type wrapperFakeTLS struct {
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"encoding/binary"
|
||||
"net"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/mtproto/rpc"
|
||||
"mtg/utils"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/mtproto/rpc"
|
||||
"github.com/9seconds/mtg/utils"
|
||||
)
|
||||
|
||||
type mtprotoCipherPurpose uint8
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
type wrapperObfuscated2 struct {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
type ReadWriteCloseRewinder interface {
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/stats"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/stats"
|
||||
)
|
||||
|
||||
type wrapperTelegramStats struct {
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"mtg/stats"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/stats"
|
||||
)
|
||||
|
||||
type wrapperTrafficStats struct {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"mtg/conntypes"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user