Просмотр исходного кода

Merge remote-tracking branch 'origin/master' into stable

tags/v1.0.1
9seconds 6 лет назад
Родитель
Сommit
bb21bf814f
54 измененных файлов: 168 добавлений и 140 удалений
  1. 1
    4
      Makefile
  2. 1
    1
      antireplay/init.go
  3. 1
    1
      cli/generate.go
  4. 10
    10
      cli/proxy.go
  5. 8
    8
      faketls/client_protocol.go
  6. 4
    4
      go.mod
  7. 6
    6
      go.sum
  8. 4
    4
      hub/connection.go
  9. 5
    6
      hub/connection_list.go
  10. 1
    1
      hub/hub.go
  11. 1
    1
      hub/interface.go
  12. 12
    3
      hub/mux.go
  13. 3
    3
      hub/proxy_conn.go
  14. 29
    6
      main.go
  15. 6
    6
      mtproto/protocol.go
  16. 1
    1
      mtproto/rpc/proxy_response.go
  17. 7
    7
      obfuscated2/client_protocol.go
  18. 5
    5
      obfuscated2/telegram_protocol.go
  19. 1
    1
      protocol/interfaces.go
  20. 1
    1
      protocol/request.go
  21. 3
    3
      proxy/direct.go
  22. 3
    3
      proxy/middle.go
  23. 6
    6
      proxy/proxy.go
  24. 1
    1
      stats/interfaces.go
  25. 1
    1
      stats/multi_stats.go
  26. 1
    1
      stats/stats.go
  27. 2
    2
      stats/stats_prometheus.go
  28. 2
    2
      stats/stats_statsd.go
  29. 1
    1
      telegram/api/addresses.go
  30. 1
    1
      telegram/api/api.go
  31. 3
    3
      telegram/base.go
  32. 1
    1
      telegram/direct.go
  33. 1
    1
      telegram/interfaces.go
  34. 2
    2
      telegram/middle.go
  35. 2
    2
      tlstypes/client_hello.go
  36. 1
    1
      tlstypes/handshake.go
  37. 1
    1
      tlstypes/server_hello.go
  38. 1
    1
      utils/init_tcp.go
  39. 1
    1
      wrappers/packet/mtproto_frame.go
  40. 2
    2
      wrappers/packetack/client_abridged.go
  41. 1
    1
      wrappers/packetack/client_intermediate.go
  42. 1
    1
      wrappers/packetack/client_intermediate_secure.go
  43. 5
    5
      wrappers/packetack/proxy.go
  44. 1
    1
      wrappers/stream/base.go
  45. 2
    2
      wrappers/stream/blockcipher.go
  46. 2
    2
      wrappers/stream/conn.go
  47. 1
    1
      wrappers/stream/ctx.go
  48. 2
    2
      wrappers/stream/faketls.go
  49. 3
    3
      wrappers/stream/mtproto_cipher.go
  50. 1
    1
      wrappers/stream/obfuscated2.go
  51. 1
    1
      wrappers/stream/rewind.go
  52. 2
    2
      wrappers/stream/stats_telegram.go
  53. 2
    2
      wrappers/stream/stats_traffic.go
  54. 1
    1
      wrappers/stream/timeout.go

+ 1
- 4
Makefile Просмотреть файл

6
 
6
 
7
 GOLANGCI_LINT_VERSION := v1.21.0
7
 GOLANGCI_LINT_VERSION := v1.21.0
8
 
8
 
9
-VERSION_GO         := $(shell go version)
10
-VERSION_DATE       := $(shell date -Ru)
11
-VERSION_TAG        := $(shell git describe --tags --always)
12
-COMMON_BUILD_FLAGS := -ldflags="-s -w -X 'main.version=$(VERSION_TAG) ($(VERSION_GO)) [$(VERSION_DATE)]'"
9
+COMMON_BUILD_FLAGS := -ldflags="-s -w"
13
 
10
 
14
 MOD_ON  := env GO111MODULE=on
11
 MOD_ON  := env GO111MODULE=on
15
 MOD_OFF := env GO111MODULE=auto
12
 MOD_OFF := env GO111MODULE=auto

+ 1
- 1
antireplay/init.go Просмотреть файл

5
 
5
 
6
 	"github.com/VictoriaMetrics/fastcache"
6
 	"github.com/VictoriaMetrics/fastcache"
7
 
7
 
8
-	"mtg/config"
8
+	"github.com/9seconds/mtg/config"
9
 )
9
 )
10
 
10
 
11
 var (
11
 var (

+ 1
- 1
cli/generate.go Просмотреть файл

4
 	"crypto/rand"
4
 	"crypto/rand"
5
 	"encoding/hex"
5
 	"encoding/hex"
6
 
6
 
7
-	"mtg/config"
7
+	"github.com/9seconds/mtg/config"
8
 )
8
 )
9
 
9
 
10
 func Generate(secretType, hostname string) {
10
 func Generate(secretType, hostname string) {

+ 10
- 10
cli/proxy.go Просмотреть файл

8
 	"go.uber.org/zap"
8
 	"go.uber.org/zap"
9
 	"go.uber.org/zap/zapcore"
9
 	"go.uber.org/zap/zapcore"
10
 
10
 
11
-	"mtg/antireplay"
12
-	"mtg/config"
13
-	"mtg/faketls"
14
-	"mtg/hub"
15
-	"mtg/ntp"
16
-	"mtg/obfuscated2"
17
-	"mtg/proxy"
18
-	"mtg/stats"
19
-	"mtg/telegram"
20
-	"mtg/utils"
11
+	"github.com/9seconds/mtg/antireplay"
12
+	"github.com/9seconds/mtg/config"
13
+	"github.com/9seconds/mtg/faketls"
14
+	"github.com/9seconds/mtg/hub"
15
+	"github.com/9seconds/mtg/ntp"
16
+	"github.com/9seconds/mtg/obfuscated2"
17
+	"github.com/9seconds/mtg/proxy"
18
+	"github.com/9seconds/mtg/stats"
19
+	"github.com/9seconds/mtg/telegram"
20
+	"github.com/9seconds/mtg/utils"
21
 )
21
 )
22
 
22
 
23
 func Proxy() error { // nolint: funlen
23
 func Proxy() error { // nolint: funlen

+ 8
- 8
faketls/client_protocol.go Просмотреть файл

11
 	"sync"
11
 	"sync"
12
 	"time"
12
 	"time"
13
 
13
 
14
-	"mtg/antireplay"
15
-	"mtg/config"
16
-	"mtg/conntypes"
17
-	"mtg/obfuscated2"
18
-	"mtg/protocol"
19
-	"mtg/stats"
20
-	"mtg/tlstypes"
21
-	"mtg/wrappers/stream"
14
+	"github.com/9seconds/mtg/antireplay"
15
+	"github.com/9seconds/mtg/config"
16
+	"github.com/9seconds/mtg/conntypes"
17
+	"github.com/9seconds/mtg/obfuscated2"
18
+	"github.com/9seconds/mtg/protocol"
19
+	"github.com/9seconds/mtg/stats"
20
+	"github.com/9seconds/mtg/tlstypes"
21
+	"github.com/9seconds/mtg/wrappers/stream"
22
 )
22
 )
23
 
23
 
24
 type ClientProtocol struct {
24
 type ClientProtocol struct {

+ 4
- 4
go.mod Просмотреть файл

1
-module mtg
1
+module github.com/9seconds/mtg
2
 
2
 
3
 go 1.13
3
 go 1.13
4
 
4
 
13
 	go.uber.org/multierr v1.4.0 // indirect
13
 	go.uber.org/multierr v1.4.0 // indirect
14
 	go.uber.org/zap v1.13.0
14
 	go.uber.org/zap v1.13.0
15
 	golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f
15
 	golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f
16
-	golang.org/x/net v0.0.0-20191116160921-f9c825593386 // indirect
17
-	golang.org/x/sys v0.0.0-20191118013547-6254a7c3cac6
18
-	golang.org/x/tools v0.0.0-20191118051429-5a76f03bc7c3 // indirect
16
+	golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 // indirect
17
+	golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2
18
+	golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98 // indirect
19
 	gopkg.in/alecthomas/kingpin.v2 v2.2.6
19
 	gopkg.in/alecthomas/kingpin.v2 v2.2.6
20
 )
20
 )

+ 6
- 6
go.sum Просмотреть файл

139
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
139
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
140
 golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
140
 golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
141
 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
141
 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
142
-golang.org/x/net v0.0.0-20191116160921-f9c825593386 h1:ktbWvQrW08Txdxno1PiDpSxPXG6ndGsfnJjRRtkM0LQ=
143
-golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
142
+golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4=
143
+golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
144
 golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
144
 golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
145
 golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
145
 golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
146
 golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
146
 golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
153
 golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
153
 golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
154
 golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
154
 golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
155
 golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
155
 golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
156
-golang.org/x/sys v0.0.0-20191118013547-6254a7c3cac6 h1:8mlr2HX+lfl0eaQcjiHfVeM2FHxWkuYQ5a2Wcy8mE1s=
157
-golang.org/x/sys v0.0.0-20191118013547-6254a7c3cac6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
156
+golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2 h1:wAW1U21MfVN0sUipAD8952TBjGXMRHFKQugDlQ9RwwE=
157
+golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
158
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
158
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
159
 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
159
 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
160
 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
160
 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
161
 golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
161
 golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
162
 golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs=
162
 golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs=
163
 golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
163
 golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
164
-golang.org/x/tools v0.0.0-20191118051429-5a76f03bc7c3 h1:3gzOmNy3PLCZ+3Ru/n5Gh7pPjsieiytYSDxFj6QY/oI=
165
-golang.org/x/tools v0.0.0-20191118051429-5a76f03bc7c3/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
164
+golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98 h1:tZwpOHmF1OEL9wJGSgBALnhFg/8VKjQTtctCX51GLNI=
165
+golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
166
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
166
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
167
 gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
167
 gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
168
 gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
168
 gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=

+ 4
- 4
hub/connection.go Просмотреть файл

7
 
7
 
8
 	"go.uber.org/zap"
8
 	"go.uber.org/zap"
9
 
9
 
10
-	"mtg/conntypes"
11
-	"mtg/mtproto"
12
-	"mtg/mtproto/rpc"
13
-	"mtg/protocol"
10
+	"github.com/9seconds/mtg/conntypes"
11
+	"github.com/9seconds/mtg/mtproto"
12
+	"github.com/9seconds/mtg/mtproto/rpc"
13
+	"github.com/9seconds/mtg/protocol"
14
 )
14
 )
15
 
15
 
16
 type connection struct {
16
 type connection struct {

+ 5
- 6
hub/connection_list.go Просмотреть файл

4
 	"fmt"
4
 	"fmt"
5
 	"sort"
5
 	"sort"
6
 
6
 
7
-	"mtg/config"
7
+	"github.com/9seconds/mtg/config"
8
 )
8
 )
9
 
9
 
10
 type connectionList struct {
10
 type connectionList struct {
11
 	connections []*connection
11
 	connections []*connection
12
 }
12
 }
13
 
13
 
14
-func (c *connectionList) Get(conn *ProxyConn) (*connection, error) {
15
-	if len(c.connections) > 0 {
16
-		c.gc()
17
-	}
18
-
14
+func (c *connectionList) get(conn *ProxyConn) (*connection, error) {
19
 	if len(c.connections) > 0 && c.connections[0].Len() < config.C.MultiplexPerConnection {
15
 	if len(c.connections) > 0 && c.connections[0].Len() < config.C.MultiplexPerConnection {
20
 		if err := c.connections[0].Attach(conn); err == nil {
16
 		if err := c.connections[0].Attach(conn); err == nil {
21
 			return c.connections[0], nil
17
 			return c.connections[0], nil
41
 
37
 
42
 func (c *connectionList) gc() {
38
 func (c *connectionList) gc() {
43
 	prevLen := len(c.connections)
39
 	prevLen := len(c.connections)
40
+	if prevLen == 0 {
41
+		return
42
+	}
44
 
43
 
45
 	for i := len(c.connections) - 1; i >= 0; i-- {
44
 	for i := len(c.connections) - 1; i >= 0; i-- {
46
 		lastIndex := len(c.connections) - 1
45
 		lastIndex := len(c.connections) - 1

+ 1
- 1
hub/hub.go Просмотреть файл

4
 	"context"
4
 	"context"
5
 	"sync"
5
 	"sync"
6
 
6
 
7
-	"mtg/protocol"
7
+	"github.com/9seconds/mtg/protocol"
8
 )
8
 )
9
 
9
 
10
 type hub struct {
10
 type hub struct {

+ 1
- 1
hub/interface.go Просмотреть файл

1
 package hub
1
 package hub
2
 
2
 
3
-import "mtg/protocol"
3
+import "github.com/9seconds/mtg/protocol"
4
 
4
 
5
 type Interface interface {
5
 type Interface interface {
6
 	Register(*protocol.TelegramRequest) (*ProxyConn, error)
6
 	Register(*protocol.TelegramRequest) (*ProxyConn, error)

+ 12
- 3
hub/mux.go Просмотреть файл

2
 
2
 
3
 import (
3
 import (
4
 	"context"
4
 	"context"
5
+	"time"
5
 
6
 
6
-	"mtg/conntypes"
7
-	"mtg/protocol"
7
+	"github.com/9seconds/mtg/conntypes"
8
+	"github.com/9seconds/mtg/protocol"
8
 )
9
 )
9
 
10
 
11
+const muxGCEvery = time.Minute
12
+
10
 type muxNewRequest struct {
13
 type muxNewRequest struct {
11
 	req  *protocol.TelegramRequest
14
 	req  *protocol.TelegramRequest
12
 	resp chan<- muxNewResponse
15
 	resp chan<- muxNewResponse
26
 }
29
 }
27
 
30
 
28
 func (m *mux) run() {
31
 func (m *mux) run() {
32
+	gcTicker := time.NewTicker(muxGCEvery)
33
+	defer gcTicker.Stop()
34
+
29
 	for {
35
 	for {
30
 		select {
36
 		select {
31
 		case <-m.ctx.Done():
37
 		case <-m.ctx.Done():
34
 			}
40
 			}
35
 
41
 
36
 			return
42
 			return
43
+		case <-gcTicker.C:
44
+			m.connections.gc()
37
 		case req := <-m.channelNew:
45
 		case req := <-m.channelNew:
46
+			m.connections.gc()
38
 			proxyConn := newProxyConn(req.req, m.channelClosed)
47
 			proxyConn := newProxyConn(req.req, m.channelClosed)
39
-			conn, err := m.connections.Get(proxyConn)
48
+			conn, err := m.connections.get(proxyConn)
40
 
49
 
41
 			if err == nil {
50
 			if err == nil {
42
 				m.clients[string(req.req.ConnID[:])] = conn
51
 				m.clients[string(req.req.ConnID[:])] = conn

+ 3
- 3
hub/proxy_conn.go Просмотреть файл

4
 	"sync"
4
 	"sync"
5
 	"time"
5
 	"time"
6
 
6
 
7
-	"mtg/conntypes"
8
-	"mtg/mtproto/rpc"
9
-	"mtg/protocol"
7
+	"github.com/9seconds/mtg/conntypes"
8
+	"github.com/9seconds/mtg/mtproto/rpc"
9
+	"github.com/9seconds/mtg/protocol"
10
 )
10
 )
11
 
11
 
12
 const (
12
 const (

+ 29
- 6
main.go Просмотреть файл

3
 import (
3
 import (
4
 	"math/rand"
4
 	"math/rand"
5
 	"os"
5
 	"os"
6
+	"runtime/debug"
7
+	"strings"
6
 	"time"
8
 	"time"
7
 
9
 
8
 	kingpin "gopkg.in/alecthomas/kingpin.v2"
10
 	kingpin "gopkg.in/alecthomas/kingpin.v2"
9
 
11
 
10
-	"mtg/cli"
11
-	"mtg/config"
12
-	"mtg/utils"
12
+	"github.com/9seconds/mtg/cli"
13
+	"github.com/9seconds/mtg/config"
14
+	"github.com/9seconds/mtg/utils"
13
 )
15
 )
14
 
16
 
15
-var version = "dev" // this has to be set by build ld flags
16
-
17
 var (
17
 var (
18
 	app = kingpin.New("mtg", "Simple MTPROTO proxy.")
18
 	app = kingpin.New("mtg", "Simple MTPROTO proxy.")
19
 
19
 
114
 
114
 
115
 func main() {
115
 func main() {
116
 	rand.Seed(time.Now().UTC().UnixNano())
116
 	rand.Seed(time.Now().UTC().UnixNano())
117
-	app.Version(version)
117
+	app.Version(getVersion())
118
 	app.HelpFlag.Short('h')
118
 	app.HelpFlag.Short('h')
119
 
119
 
120
 	if err := utils.SetLimits(); err != nil {
120
 	if err := utils.SetLimits(); err != nil {
153
 		}
153
 		}
154
 	}
154
 	}
155
 }
155
 }
156
+
157
+func getVersion() string {
158
+	if info, ok := debug.ReadBuildInfo(); ok {
159
+		builder := strings.Builder{}
160
+		version := info.Main.Version
161
+
162
+		if version == "(devel)" {
163
+			version = "dev"
164
+		}
165
+
166
+		builder.WriteString(version)
167
+
168
+		if info.Main.Sum != "" {
169
+			builder.WriteString(" (checksum: ")
170
+			builder.WriteString(info.Main.Sum)
171
+			builder.WriteRune(')')
172
+		}
173
+
174
+		return builder.String()
175
+	}
176
+
177
+	return "dev"
178
+}

+ 6
- 6
mtproto/protocol.go Просмотреть файл

3
 import (
3
 import (
4
 	"fmt"
4
 	"fmt"
5
 
5
 
6
-	"mtg/conntypes"
7
-	"mtg/mtproto/rpc"
8
-	"mtg/protocol"
9
-	"mtg/telegram"
10
-	"mtg/wrappers/packet"
11
-	"mtg/wrappers/stream"
6
+	"github.com/9seconds/mtg/conntypes"
7
+	"github.com/9seconds/mtg/mtproto/rpc"
8
+	"github.com/9seconds/mtg/protocol"
9
+	"github.com/9seconds/mtg/telegram"
10
+	"github.com/9seconds/mtg/wrappers/packet"
11
+	"github.com/9seconds/mtg/wrappers/stream"
12
 )
12
 )
13
 
13
 
14
 func TelegramProtocol(req *protocol.TelegramRequest) (conntypes.PacketReadWriteCloser, error) {
14
 func TelegramProtocol(req *protocol.TelegramRequest) (conntypes.PacketReadWriteCloser, error) {

+ 1
- 1
mtproto/rpc/proxy_response.go Просмотреть файл

4
 	"bytes"
4
 	"bytes"
5
 	"fmt"
5
 	"fmt"
6
 
6
 
7
-	"mtg/conntypes"
7
+	"github.com/9seconds/mtg/conntypes"
8
 )
8
 )
9
 
9
 
10
 type ProxyResponseType uint8
10
 type ProxyResponseType uint8

+ 7
- 7
obfuscated2/client_protocol.go Просмотреть файл

9
 	"io"
9
 	"io"
10
 	"time"
10
 	"time"
11
 
11
 
12
-	"mtg/antireplay"
13
-	"mtg/config"
14
-	"mtg/conntypes"
15
-	"mtg/protocol"
16
-	"mtg/stats"
17
-	"mtg/utils"
18
-	"mtg/wrappers/stream"
12
+	"github.com/9seconds/mtg/antireplay"
13
+	"github.com/9seconds/mtg/config"
14
+	"github.com/9seconds/mtg/conntypes"
15
+	"github.com/9seconds/mtg/protocol"
16
+	"github.com/9seconds/mtg/stats"
17
+	"github.com/9seconds/mtg/utils"
18
+	"github.com/9seconds/mtg/wrappers/stream"
19
 )
19
 )
20
 
20
 
21
 const clientProtocolHandshakeTimeout = 10 * time.Second
21
 const clientProtocolHandshakeTimeout = 10 * time.Second

+ 5
- 5
obfuscated2/telegram_protocol.go Просмотреть файл

4
 	"crypto/rand"
4
 	"crypto/rand"
5
 	"fmt"
5
 	"fmt"
6
 
6
 
7
-	"mtg/conntypes"
8
-	"mtg/protocol"
9
-	"mtg/telegram"
10
-	"mtg/utils"
11
-	"mtg/wrappers/stream"
7
+	"github.com/9seconds/mtg/conntypes"
8
+	"github.com/9seconds/mtg/protocol"
9
+	"github.com/9seconds/mtg/telegram"
10
+	"github.com/9seconds/mtg/utils"
11
+	"github.com/9seconds/mtg/wrappers/stream"
12
 )
12
 )
13
 
13
 
14
 func TelegramProtocol(req *protocol.TelegramRequest) (conntypes.StreamReadWriteCloser, error) {
14
 func TelegramProtocol(req *protocol.TelegramRequest) (conntypes.StreamReadWriteCloser, error) {

+ 1
- 1
protocol/interfaces.go Просмотреть файл

1
 package protocol
1
 package protocol
2
 
2
 
3
-import "mtg/conntypes"
3
+import "github.com/9seconds/mtg/conntypes"
4
 
4
 
5
 type ClientProtocol interface {
5
 type ClientProtocol interface {
6
 	Handshake(conntypes.StreamReadWriteCloser) (conntypes.StreamReadWriteCloser, error)
6
 	Handshake(conntypes.StreamReadWriteCloser) (conntypes.StreamReadWriteCloser, error)

+ 1
- 1
protocol/request.go Просмотреть файл

5
 
5
 
6
 	"go.uber.org/zap"
6
 	"go.uber.org/zap"
7
 
7
 
8
-	"mtg/conntypes"
8
+	"github.com/9seconds/mtg/conntypes"
9
 )
9
 )
10
 
10
 
11
 type TelegramRequest struct {
11
 type TelegramRequest struct {

+ 3
- 3
proxy/direct.go Просмотреть файл

6
 
6
 
7
 	"go.uber.org/zap"
7
 	"go.uber.org/zap"
8
 
8
 
9
-	"mtg/conntypes"
10
-	"mtg/obfuscated2"
11
-	"mtg/protocol"
9
+	"github.com/9seconds/mtg/conntypes"
10
+	"github.com/9seconds/mtg/obfuscated2"
11
+	"github.com/9seconds/mtg/protocol"
12
 )
12
 )
13
 
13
 
14
 const directPipeBufferSize = 1024 * 1024
14
 const directPipeBufferSize = 1024 * 1024

+ 3
- 3
proxy/middle.go Просмотреть файл

5
 
5
 
6
 	"go.uber.org/zap"
6
 	"go.uber.org/zap"
7
 
7
 
8
-	"mtg/conntypes"
9
-	"mtg/protocol"
10
-	"mtg/wrappers/packetack"
8
+	"github.com/9seconds/mtg/conntypes"
9
+	"github.com/9seconds/mtg/protocol"
10
+	"github.com/9seconds/mtg/wrappers/packetack"
11
 )
11
 )
12
 
12
 
13
 func middleConnection(request *protocol.TelegramRequest) {
13
 func middleConnection(request *protocol.TelegramRequest) {

+ 6
- 6
proxy/proxy.go Просмотреть файл

6
 
6
 
7
 	"go.uber.org/zap"
7
 	"go.uber.org/zap"
8
 
8
 
9
-	"mtg/config"
10
-	"mtg/conntypes"
11
-	"mtg/protocol"
12
-	"mtg/stats"
13
-	"mtg/utils"
14
-	"mtg/wrappers/stream"
9
+	"github.com/9seconds/mtg/config"
10
+	"github.com/9seconds/mtg/conntypes"
11
+	"github.com/9seconds/mtg/protocol"
12
+	"github.com/9seconds/mtg/stats"
13
+	"github.com/9seconds/mtg/utils"
14
+	"github.com/9seconds/mtg/wrappers/stream"
15
 )
15
 )
16
 
16
 
17
 type Proxy struct {
17
 type Proxy struct {

+ 1
- 1
stats/interfaces.go Просмотреть файл

3
 import (
3
 import (
4
 	"net"
4
 	"net"
5
 
5
 
6
-	"mtg/conntypes"
6
+	"github.com/9seconds/mtg/conntypes"
7
 )
7
 )
8
 
8
 
9
 type IngressTrafficInterface interface {
9
 type IngressTrafficInterface interface {

+ 1
- 1
stats/multi_stats.go Просмотреть файл

3
 import (
3
 import (
4
 	"net"
4
 	"net"
5
 
5
 
6
-	"mtg/conntypes"
6
+	"github.com/9seconds/mtg/conntypes"
7
 )
7
 )
8
 
8
 
9
 type multiStats []Interface
9
 type multiStats []Interface

+ 1
- 1
stats/stats.go Просмотреть файл

6
 	"net"
6
 	"net"
7
 	"net/http"
7
 	"net/http"
8
 
8
 
9
-	"mtg/config"
9
+	"github.com/9seconds/mtg/config"
10
 )
10
 )
11
 
11
 
12
 var Stats Interface
12
 var Stats Interface

+ 2
- 2
stats/stats_prometheus.go Просмотреть файл

8
 	"github.com/prometheus/client_golang/prometheus"
8
 	"github.com/prometheus/client_golang/prometheus"
9
 	"github.com/prometheus/client_golang/prometheus/promhttp"
9
 	"github.com/prometheus/client_golang/prometheus/promhttp"
10
 
10
 
11
-	"mtg/config"
12
-	"mtg/conntypes"
11
+	"github.com/9seconds/mtg/config"
12
+	"github.com/9seconds/mtg/conntypes"
13
 )
13
 )
14
 
14
 
15
 type statsPrometheus struct {
15
 type statsPrometheus struct {

+ 2
- 2
stats/stats_statsd.go Просмотреть файл

11
 	statsd "github.com/smira/go-statsd"
11
 	statsd "github.com/smira/go-statsd"
12
 	"go.uber.org/zap"
12
 	"go.uber.org/zap"
13
 
13
 
14
-	"mtg/config"
15
-	"mtg/conntypes"
14
+	"github.com/9seconds/mtg/config"
15
+	"github.com/9seconds/mtg/conntypes"
16
 )
16
 )
17
 
17
 
18
 var (
18
 var (

+ 1
- 1
telegram/api/addresses.go Просмотреть файл

8
 	"strconv"
8
 	"strconv"
9
 	"strings"
9
 	"strings"
10
 
10
 
11
-	"mtg/conntypes"
11
+	"github.com/9seconds/mtg/conntypes"
12
 )
12
 )
13
 
13
 
14
 const (
14
 const (

+ 1
- 1
telegram/api/api.go Просмотреть файл

9
 )
9
 )
10
 
10
 
11
 const (
11
 const (
12
-	apiUserAgent   = "mtg"
12
+	apiUserAgent   = "github.com/9seconds/mtg"
13
 	apiHTTPTimeout = 30 * time.Second
13
 	apiHTTPTimeout = 30 * time.Second
14
 )
14
 )
15
 
15
 

+ 3
- 3
telegram/base.go Просмотреть файл

5
 	"math/rand"
5
 	"math/rand"
6
 	"net"
6
 	"net"
7
 
7
 
8
-	"mtg/conntypes"
9
-	"mtg/utils"
10
-	"mtg/wrappers/stream"
8
+	"github.com/9seconds/mtg/conntypes"
9
+	"github.com/9seconds/mtg/utils"
10
+	"github.com/9seconds/mtg/wrappers/stream"
11
 )
11
 )
12
 
12
 
13
 type baseTelegram struct {
13
 type baseTelegram struct {

+ 1
- 1
telegram/direct.go Просмотреть файл

1
 package telegram
1
 package telegram
2
 
2
 
3
-import "mtg/conntypes"
3
+import "github.com/9seconds/mtg/conntypes"
4
 
4
 
5
 const (
5
 const (
6
 	directV4DefaultIdx conntypes.DC = 1
6
 	directV4DefaultIdx conntypes.DC = 1

+ 1
- 1
telegram/interfaces.go Просмотреть файл

1
 package telegram
1
 package telegram
2
 
2
 
3
-import "mtg/conntypes"
3
+import "github.com/9seconds/mtg/conntypes"
4
 
4
 
5
 type Telegram interface {
5
 type Telegram interface {
6
 	Dial(conntypes.DC, conntypes.ConnectionProtocol) (conntypes.StreamReadWriteCloser, error)
6
 	Dial(conntypes.DC, conntypes.ConnectionProtocol) (conntypes.StreamReadWriteCloser, error)

+ 2
- 2
telegram/middle.go Просмотреть файл

7
 
7
 
8
 	"go.uber.org/zap"
8
 	"go.uber.org/zap"
9
 
9
 
10
-	"mtg/conntypes"
11
-	"mtg/telegram/api"
10
+	"github.com/9seconds/mtg/conntypes"
11
+	"github.com/9seconds/mtg/telegram/api"
12
 )
12
 )
13
 
13
 
14
 const middleTelegramBackgroundUpdateEvery = time.Hour
14
 const middleTelegramBackgroundUpdateEvery = time.Hour

+ 2
- 2
tlstypes/client_hello.go Просмотреть файл

6
 	"crypto/sha256"
6
 	"crypto/sha256"
7
 	"fmt"
7
 	"fmt"
8
 
8
 
9
-	"mtg/config"
10
-	"mtg/utils"
9
+	"github.com/9seconds/mtg/config"
10
+	"github.com/9seconds/mtg/utils"
11
 )
11
 )
12
 
12
 
13
 type ClientHello struct {
13
 type ClientHello struct {

+ 1
- 1
tlstypes/handshake.go Просмотреть файл

3
 import (
3
 import (
4
 	"bytes"
4
 	"bytes"
5
 
5
 
6
-	"mtg/utils"
6
+	"github.com/9seconds/mtg/utils"
7
 )
7
 )
8
 
8
 
9
 type Handshake struct {
9
 type Handshake struct {

+ 1
- 1
tlstypes/server_hello.go Просмотреть файл

10
 
10
 
11
 	"golang.org/x/crypto/curve25519"
11
 	"golang.org/x/crypto/curve25519"
12
 
12
 
13
-	"mtg/config"
13
+	"github.com/9seconds/mtg/config"
14
 )
14
 )
15
 
15
 
16
 type ServerHello struct {
16
 type ServerHello struct {

+ 1
- 1
utils/init_tcp.go Просмотреть файл

4
 	"fmt"
4
 	"fmt"
5
 	"net"
5
 	"net"
6
 
6
 
7
-	"mtg/config"
7
+	"github.com/9seconds/mtg/config"
8
 )
8
 )
9
 
9
 
10
 func InitTCP(conn net.Conn) error {
10
 func InitTCP(conn net.Conn) error {

+ 1
- 1
wrappers/packet/mtproto_frame.go Просмотреть файл

12
 
12
 
13
 	"go.uber.org/zap"
13
 	"go.uber.org/zap"
14
 
14
 
15
-	"mtg/conntypes"
15
+	"github.com/9seconds/mtg/conntypes"
16
 )
16
 )
17
 
17
 
18
 const (
18
 const (

+ 2
- 2
wrappers/packetack/client_abridged.go Просмотреть файл

8
 
8
 
9
 	"go.uber.org/zap"
9
 	"go.uber.org/zap"
10
 
10
 
11
-	"mtg/conntypes"
12
-	"mtg/utils"
11
+	"github.com/9seconds/mtg/conntypes"
12
+	"github.com/9seconds/mtg/utils"
13
 )
13
 )
14
 
14
 
15
 const (
15
 const (

+ 1
- 1
wrappers/packetack/client_intermediate.go Просмотреть файл

9
 
9
 
10
 	"go.uber.org/zap"
10
 	"go.uber.org/zap"
11
 
11
 
12
-	"mtg/conntypes"
12
+	"github.com/9seconds/mtg/conntypes"
13
 )
13
 )
14
 
14
 
15
 const clientIntermediateQuickAckLength = 0x80000000
15
 const clientIntermediateQuickAckLength = 0x80000000

+ 1
- 1
wrappers/packetack/client_intermediate_secure.go Просмотреть файл

8
 
8
 
9
 	"go.uber.org/zap"
9
 	"go.uber.org/zap"
10
 
10
 
11
-	"mtg/conntypes"
11
+	"github.com/9seconds/mtg/conntypes"
12
 )
12
 )
13
 
13
 
14
 type wrapperClientIntermediateSecure struct {
14
 type wrapperClientIntermediateSecure struct {

+ 5
- 5
wrappers/packetack/proxy.go Просмотреть файл

6
 	"fmt"
6
 	"fmt"
7
 	"net"
7
 	"net"
8
 
8
 
9
-	"mtg/config"
10
-	"mtg/conntypes"
11
-	"mtg/hub"
12
-	"mtg/mtproto/rpc"
13
-	"mtg/protocol"
9
+	"github.com/9seconds/mtg/config"
10
+	"github.com/9seconds/mtg/conntypes"
11
+	"github.com/9seconds/mtg/hub"
12
+	"github.com/9seconds/mtg/mtproto/rpc"
13
+	"github.com/9seconds/mtg/protocol"
14
 )
14
 )
15
 
15
 
16
 type wrapperProxy struct {
16
 type wrapperProxy struct {

+ 1
- 1
wrappers/stream/base.go Просмотреть файл

3
 import (
3
 import (
4
 	"net"
4
 	"net"
5
 
5
 
6
-	"mtg/conntypes"
6
+	"github.com/9seconds/mtg/conntypes"
7
 )
7
 )
8
 
8
 
9
 func NewClientConn(parent net.Conn, connID conntypes.ConnID) conntypes.StreamReadWriteCloser {
9
 func NewClientConn(parent net.Conn, connID conntypes.ConnID) conntypes.StreamReadWriteCloser {

+ 2
- 2
wrappers/stream/blockcipher.go Просмотреть файл

9
 
9
 
10
 	"go.uber.org/zap"
10
 	"go.uber.org/zap"
11
 
11
 
12
-	"mtg/conntypes"
13
-	"mtg/utils"
12
+	"github.com/9seconds/mtg/conntypes"
13
+	"github.com/9seconds/mtg/utils"
14
 )
14
 )
15
 
15
 
16
 type wrapperBlockCipher struct {
16
 type wrapperBlockCipher struct {

+ 2
- 2
wrappers/stream/conn.go Просмотреть файл

7
 
7
 
8
 	"go.uber.org/zap"
8
 	"go.uber.org/zap"
9
 
9
 
10
-	"mtg/config"
11
-	"mtg/conntypes"
10
+	"github.com/9seconds/mtg/config"
11
+	"github.com/9seconds/mtg/conntypes"
12
 )
12
 )
13
 
13
 
14
 type connPurpose uint8
14
 type connPurpose uint8

+ 1
- 1
wrappers/stream/ctx.go Просмотреть файл

8
 
8
 
9
 	"go.uber.org/zap"
9
 	"go.uber.org/zap"
10
 
10
 
11
-	"mtg/conntypes"
11
+	"github.com/9seconds/mtg/conntypes"
12
 )
12
 )
13
 
13
 
14
 type wrapperCtx struct {
14
 type wrapperCtx struct {

+ 2
- 2
wrappers/stream/faketls.go Просмотреть файл

8
 
8
 
9
 	"go.uber.org/zap"
9
 	"go.uber.org/zap"
10
 
10
 
11
-	"mtg/conntypes"
12
-	"mtg/tlstypes"
11
+	"github.com/9seconds/mtg/conntypes"
12
+	"github.com/9seconds/mtg/tlstypes"
13
 )
13
 )
14
 
14
 
15
 type wrapperFakeTLS struct {
15
 type wrapperFakeTLS struct {

+ 3
- 3
wrappers/stream/mtproto_cipher.go Просмотреть файл

9
 	"encoding/binary"
9
 	"encoding/binary"
10
 	"net"
10
 	"net"
11
 
11
 
12
-	"mtg/conntypes"
13
-	"mtg/mtproto/rpc"
14
-	"mtg/utils"
12
+	"github.com/9seconds/mtg/conntypes"
13
+	"github.com/9seconds/mtg/mtproto/rpc"
14
+	"github.com/9seconds/mtg/utils"
15
 )
15
 )
16
 
16
 
17
 type mtprotoCipherPurpose uint8
17
 type mtprotoCipherPurpose uint8

+ 1
- 1
wrappers/stream/obfuscated2.go Просмотреть файл

8
 
8
 
9
 	"go.uber.org/zap"
9
 	"go.uber.org/zap"
10
 
10
 
11
-	"mtg/conntypes"
11
+	"github.com/9seconds/mtg/conntypes"
12
 )
12
 )
13
 
13
 
14
 type wrapperObfuscated2 struct {
14
 type wrapperObfuscated2 struct {

+ 1
- 1
wrappers/stream/rewind.go Просмотреть файл

9
 
9
 
10
 	"go.uber.org/zap"
10
 	"go.uber.org/zap"
11
 
11
 
12
-	"mtg/conntypes"
12
+	"github.com/9seconds/mtg/conntypes"
13
 )
13
 )
14
 
14
 
15
 type ReadWriteCloseRewinder interface {
15
 type ReadWriteCloseRewinder interface {

+ 2
- 2
wrappers/stream/stats_telegram.go Просмотреть файл

7
 
7
 
8
 	"go.uber.org/zap"
8
 	"go.uber.org/zap"
9
 
9
 
10
-	"mtg/conntypes"
11
-	"mtg/stats"
10
+	"github.com/9seconds/mtg/conntypes"
11
+	"github.com/9seconds/mtg/stats"
12
 )
12
 )
13
 
13
 
14
 type wrapperTelegramStats struct {
14
 type wrapperTelegramStats struct {

+ 2
- 2
wrappers/stream/stats_traffic.go Просмотреть файл

6
 
6
 
7
 	"go.uber.org/zap"
7
 	"go.uber.org/zap"
8
 
8
 
9
-	"mtg/conntypes"
10
-	"mtg/stats"
9
+	"github.com/9seconds/mtg/conntypes"
10
+	"github.com/9seconds/mtg/stats"
11
 )
11
 )
12
 
12
 
13
 type wrapperTrafficStats struct {
13
 type wrapperTrafficStats struct {

+ 1
- 1
wrappers/stream/timeout.go Просмотреть файл

6
 
6
 
7
 	"go.uber.org/zap"
7
 	"go.uber.org/zap"
8
 
8
 
9
-	"mtg/conntypes"
9
+	"github.com/9seconds/mtg/conntypes"
10
 )
10
 )
11
 
11
 
12
 const (
12
 const (

Загрузка…
Отмена
Сохранить