mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 22:04:02 +03:00
REPOSITORY / ScuroNeko/mtg
Compare commits
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64859069ed | ||
|
|
c1935b4cef | ||
|
|
f48156814b |
@@ -30,7 +30,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go_version:
|
go_version:
|
||||||
- ^1.18
|
- ^1.19
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
@@ -70,7 +70,7 @@ jobs:
|
|||||||
- name: Run linter
|
- name: Run linter
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
with:
|
with:
|
||||||
version: v1.45.0
|
version: v1.48.0
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
name: Docker
|
name: Docker
|
||||||
|
|||||||
+11
-1
@@ -9,4 +9,14 @@ format = "colored-line-number"
|
|||||||
|
|
||||||
[linters]
|
[linters]
|
||||||
enable-all = true
|
enable-all = true
|
||||||
disable = ["thelper", "ireturn", "varnamelen", "gochecknoglobals", "gas", "goerr113", "exhaustivestruct", "containedctx"]
|
disable = [
|
||||||
|
"containedctx",
|
||||||
|
"exhaustivestruct",
|
||||||
|
"exhaustruct",
|
||||||
|
"gas",
|
||||||
|
"gochecknoglobals",
|
||||||
|
"goerr113",
|
||||||
|
"ireturn",
|
||||||
|
"thelper",
|
||||||
|
"varnamelen",
|
||||||
|
]
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# BUILD STAGE
|
# BUILD STAGE
|
||||||
|
|
||||||
FROM golang:1.18-alpine AS build
|
FROM golang:1.19-alpine AS build
|
||||||
|
|
||||||
RUN set -x \
|
RUN set -x \
|
||||||
&& apk --no-cache --update add \
|
&& apk --no-cache --update add \
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|||||||
IMAGE_NAME := mtg
|
IMAGE_NAME := mtg
|
||||||
APP_NAME := $(IMAGE_NAME)
|
APP_NAME := $(IMAGE_NAME)
|
||||||
|
|
||||||
GOLANGCI_LINT_VERSION := v1.45.0
|
GOLANGCI_LINT_VERSION := v1.48.0
|
||||||
|
|
||||||
VERSION_GO := $(shell go version)
|
VERSION_GO := $(shell go version)
|
||||||
VERSION_DATE := $(shell date -Ru)
|
VERSION_DATE := $(shell date -Ru)
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"runtime/debug"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var version = "dev" // has to be set by ldflags
|
||||||
|
|
||||||
|
const (
|
||||||
|
buildInfoModuleStart byte = iota
|
||||||
|
buildInfoModuleFinish
|
||||||
|
buildInfoModuleDelimeter
|
||||||
|
)
|
||||||
|
|
||||||
|
func getVersion() string {
|
||||||
|
buildInfo, ok := debug.ReadBuildInfo()
|
||||||
|
if !ok {
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
|
||||||
|
date := time.Now()
|
||||||
|
commit := ""
|
||||||
|
goVersion := buildInfo.GoVersion
|
||||||
|
dirtySuffix := ""
|
||||||
|
|
||||||
|
for _, setting := range buildInfo.Settings {
|
||||||
|
switch setting.Key {
|
||||||
|
case "vcs.time":
|
||||||
|
date, _ = time.Parse(time.RFC3339, setting.Value)
|
||||||
|
case "vcs.revision":
|
||||||
|
commit = setting.Value
|
||||||
|
case "vcs.modified":
|
||||||
|
if dirty, _ := strconv.ParseBool(setting.Value); dirty {
|
||||||
|
dirtySuffix = " [dirty]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hasher := sha256.New()
|
||||||
|
|
||||||
|
checksumModule := func(mod *debug.Module) {
|
||||||
|
hasher.Write([]byte{buildInfoModuleStart})
|
||||||
|
|
||||||
|
io.WriteString(hasher, mod.Path) //nolint: errcheck
|
||||||
|
hasher.Write([]byte{buildInfoModuleDelimeter})
|
||||||
|
|
||||||
|
io.WriteString(hasher, mod.Version) //nolint: errcheck
|
||||||
|
hasher.Write([]byte{buildInfoModuleDelimeter})
|
||||||
|
|
||||||
|
io.WriteString(hasher, mod.Sum) //nolint: errcheck
|
||||||
|
|
||||||
|
hasher.Write([]byte{buildInfoModuleFinish})
|
||||||
|
}
|
||||||
|
|
||||||
|
io.WriteString(hasher, buildInfo.Path) //nolint: errcheck
|
||||||
|
|
||||||
|
binary.Write(hasher, binary.LittleEndian, uint64(1+len(buildInfo.Deps))) //nolint: errcheck
|
||||||
|
|
||||||
|
sort.Slice(buildInfo.Deps, func(i, j int) bool {
|
||||||
|
return buildInfo.Deps[i].Path > buildInfo.Deps[j].Path
|
||||||
|
})
|
||||||
|
|
||||||
|
checksumModule(&buildInfo.Main)
|
||||||
|
|
||||||
|
for _, module := range buildInfo.Deps {
|
||||||
|
checksumModule(module)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s (%s: %s on %s%s, modules checksum %s)",
|
||||||
|
version,
|
||||||
|
goVersion,
|
||||||
|
date.Format(time.RFC3339),
|
||||||
|
commit,
|
||||||
|
dirtySuffix,
|
||||||
|
base64.StdEncoding.EncodeToString(hasher.Sum(nil)))
|
||||||
|
}
|
||||||
+2
-2
@@ -19,7 +19,7 @@ import (
|
|||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Proxy() error { // nolint: funlen,cyclop
|
func Proxy() error { //nolint: funlen,cyclop
|
||||||
ctx := utils.GetSignalContext()
|
ctx := utils.GetSignalContext()
|
||||||
|
|
||||||
atom := zap.NewAtomicLevel()
|
atom := zap.NewAtomicLevel()
|
||||||
@@ -41,7 +41,7 @@ func Proxy() error { // nolint: funlen,cyclop
|
|||||||
))
|
))
|
||||||
|
|
||||||
zap.ReplaceGlobals(logger)
|
zap.ReplaceGlobals(logger)
|
||||||
defer logger.Sync() // nolint: errcheck
|
defer logger.Sync() //nolint: errcheck
|
||||||
|
|
||||||
if err := config.InitPublicAddress(ctx); err != nil {
|
if err := config.InitPublicAddress(ctx); err != nil {
|
||||||
Fatal(err)
|
Fatal(err)
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
func Fatal(arg interface{}) {
|
func Fatal(arg interface{}) {
|
||||||
if value, ok := arg.(error); ok {
|
if value, ok := arg.(error); ok {
|
||||||
arg = fmt.Errorf("fatal error: %+v", value) // nolint: errorlint
|
arg = fmt.Errorf("fatal error: %+v", value) //nolint: errorlint
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintStderr(arg)
|
PrintStderr(arg)
|
||||||
@@ -21,7 +21,7 @@ func PrintStderr(args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PrintStdout(args ...interface{}) {
|
func PrintStdout(args ...interface{}) {
|
||||||
fmt.Println(args...) // nolint: forbidigo
|
fmt.Println(args...) //nolint: forbidigo
|
||||||
}
|
}
|
||||||
|
|
||||||
func PrintJSONStderr(data interface{}) {
|
func PrintJSONStderr(data interface{}) {
|
||||||
|
|||||||
+37
-37
@@ -79,29 +79,29 @@ const (
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Bind *net.TCPAddr `json:"bind"`
|
Bind *net.TCPAddr `json:"bind"`
|
||||||
PublicIPv4 *net.TCPAddr `json:"public_ipv4"` // nolint: tagliatelle
|
PublicIPv4 *net.TCPAddr `json:"public_ipv4"` //nolint: tagliatelle
|
||||||
PublicIPv6 *net.TCPAddr `json:"public_ipv6"` // nolint: tagliatelle
|
PublicIPv6 *net.TCPAddr `json:"public_ipv6"` //nolint: tagliatelle
|
||||||
StatsBind *net.TCPAddr `json:"stats_bind"` // nolint: tagliatelle
|
StatsBind *net.TCPAddr `json:"stats_bind"` //nolint: tagliatelle
|
||||||
StatsdAddr *net.TCPAddr `json:"stats_addr"` // nolint: tagliatelle
|
StatsdAddr *net.TCPAddr `json:"stats_addr"` //nolint: tagliatelle
|
||||||
StatsdTagsFormat *statsd.TagFormat `json:"statsd_tags_format"` // nolint: tagliatelle
|
StatsdTagsFormat *statsd.TagFormat `json:"statsd_tags_format"` //nolint: tagliatelle
|
||||||
|
|
||||||
StatsNamespace string `json:"stats_namespace"` // nolint: tagliatelle
|
StatsNamespace string `json:"stats_namespace"` //nolint: tagliatelle
|
||||||
CloakHost string `json:"cloak_host"` // nolint: tagliatelle
|
CloakHost string `json:"cloak_host"` //nolint: tagliatelle
|
||||||
StatsdTags map[string]string `json:"statsd_tags"` // nolint: tagliatelle
|
StatsdTags map[string]string `json:"statsd_tags"` //nolint: tagliatelle
|
||||||
|
|
||||||
WriteBuffer int `json:"write_buffer"` // nolint: tagliatelle
|
WriteBuffer int `json:"write_buffer"` //nolint: tagliatelle
|
||||||
ReadBuffer int `json:"read_buffer"` // nolint: tagliatelle
|
ReadBuffer int `json:"read_buffer"` //nolint: tagliatelle
|
||||||
CloakPort int `json:"cloak_port"` // nolint: tagliatelle
|
CloakPort int `json:"cloak_port"` //nolint: tagliatelle
|
||||||
|
|
||||||
AntiReplayMaxSize int `json:"anti_replay_max_size"` // nolint: tagliatelle
|
AntiReplayMaxSize int `json:"anti_replay_max_size"` //nolint: tagliatelle
|
||||||
|
|
||||||
MultiplexPerConnection int `json:"multiplex_per_connection"` // nolint: tagliatelle
|
MultiplexPerConnection int `json:"multiplex_per_connection"` //nolint: tagliatelle
|
||||||
|
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
Verbose bool `json:"verbose"`
|
Verbose bool `json:"verbose"`
|
||||||
SecretMode SecretMode `json:"secret_mode"` // nolint: tagliatelle
|
SecretMode SecretMode `json:"secret_mode"` //nolint: tagliatelle
|
||||||
PreferIP PreferIP `json:"prefer_ip"` // nolint: tagliatelle
|
PreferIP PreferIP `json:"prefer_ip"` //nolint: tagliatelle
|
||||||
NTPServers []string `json:"ntp_servers"` // nolint: tagliatelle
|
NTPServers []string `json:"ntp_servers"` //nolint: tagliatelle
|
||||||
|
|
||||||
Secret []byte `json:"secret"`
|
Secret []byte `json:"secret"`
|
||||||
AdTag []byte `json:"adtag"`
|
AdTag []byte `json:"adtag"`
|
||||||
@@ -146,7 +146,7 @@ func (c *Config) adjustProxyValue(value int) int {
|
|||||||
|
|
||||||
fvalue := float64(value)
|
fvalue := float64(value)
|
||||||
|
|
||||||
newValue := fvalue * 2 * math.Log(float64(c.MultiplexPerConnection)) // nolint: gomnd
|
newValue := fvalue * 2 * math.Log(float64(c.MultiplexPerConnection)) //nolint: gomnd
|
||||||
newValue = math.Ceil(newValue)
|
newValue = math.Ceil(newValue)
|
||||||
newValue = math.Max(fvalue, newValue)
|
newValue = math.Max(fvalue, newValue)
|
||||||
|
|
||||||
@@ -160,15 +160,15 @@ type Opt struct {
|
|||||||
|
|
||||||
var C = Config{}
|
var C = Config{}
|
||||||
|
|
||||||
func Init(options ...Opt) error { // nolint: gocyclo, funlen, cyclop
|
func Init(options ...Opt) error { //nolint: gocyclo, funlen, cyclop
|
||||||
for _, opt := range options {
|
for _, opt := range options {
|
||||||
switch opt.Option {
|
switch opt.Option {
|
||||||
case OptionTypeDebug:
|
case OptionTypeDebug:
|
||||||
C.Debug = opt.Value.(bool) // nolint: forcetypeassert
|
C.Debug = opt.Value.(bool) //nolint: forcetypeassert
|
||||||
case OptionTypeVerbose:
|
case OptionTypeVerbose:
|
||||||
C.Verbose = opt.Value.(bool) // nolint: forcetypeassert
|
C.Verbose = opt.Value.(bool) //nolint: forcetypeassert
|
||||||
case OptionTypePreferIP:
|
case OptionTypePreferIP:
|
||||||
value := opt.Value.(string) // nolint: forcetypeassert
|
value := opt.Value.(string) //nolint: forcetypeassert
|
||||||
switch value {
|
switch value {
|
||||||
case "ipv4":
|
case "ipv4":
|
||||||
C.PreferIP = PreferIPv4
|
C.PreferIP = PreferIPv4
|
||||||
@@ -178,25 +178,25 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen, cyclop
|
|||||||
return fmt.Errorf("incorrect direct IP mode %s", value)
|
return fmt.Errorf("incorrect direct IP mode %s", value)
|
||||||
}
|
}
|
||||||
case OptionTypeBind:
|
case OptionTypeBind:
|
||||||
C.Bind = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
|
C.Bind = opt.Value.(*net.TCPAddr) //nolint: forcetypeassert
|
||||||
case OptionTypePublicIPv4:
|
case OptionTypePublicIPv4:
|
||||||
C.PublicIPv4 = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
|
C.PublicIPv4 = opt.Value.(*net.TCPAddr) //nolint: forcetypeassert
|
||||||
if C.PublicIPv4 == nil {
|
if C.PublicIPv4 == nil {
|
||||||
C.PublicIPv4 = &net.TCPAddr{}
|
C.PublicIPv4 = &net.TCPAddr{}
|
||||||
}
|
}
|
||||||
case OptionTypePublicIPv6:
|
case OptionTypePublicIPv6:
|
||||||
C.PublicIPv6 = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
|
C.PublicIPv6 = opt.Value.(*net.TCPAddr) //nolint: forcetypeassert
|
||||||
if C.PublicIPv6 == nil {
|
if C.PublicIPv6 == nil {
|
||||||
C.PublicIPv6 = &net.TCPAddr{}
|
C.PublicIPv6 = &net.TCPAddr{}
|
||||||
}
|
}
|
||||||
case OptionTypeStatsBind:
|
case OptionTypeStatsBind:
|
||||||
C.StatsBind = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
|
C.StatsBind = opt.Value.(*net.TCPAddr) //nolint: forcetypeassert
|
||||||
case OptionTypeStatsNamespace:
|
case OptionTypeStatsNamespace:
|
||||||
C.StatsNamespace = opt.Value.(string) // nolint: forcetypeassert
|
C.StatsNamespace = opt.Value.(string) //nolint: forcetypeassert
|
||||||
case OptionTypeStatsdAddress:
|
case OptionTypeStatsdAddress:
|
||||||
C.StatsdAddr = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
|
C.StatsdAddr = opt.Value.(*net.TCPAddr) //nolint: forcetypeassert
|
||||||
case OptionTypeStatsdTagsFormat:
|
case OptionTypeStatsdTagsFormat:
|
||||||
value := opt.Value.(string) // nolint: forcetypeassert
|
value := opt.Value.(string) //nolint: forcetypeassert
|
||||||
switch value {
|
switch value {
|
||||||
case "datadog":
|
case "datadog":
|
||||||
C.StatsdTagsFormat = statsd.TagFormatDatadog
|
C.StatsdTagsFormat = statsd.TagFormatDatadog
|
||||||
@@ -206,26 +206,26 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen, cyclop
|
|||||||
return fmt.Errorf("incorrect statsd tag %s", value)
|
return fmt.Errorf("incorrect statsd tag %s", value)
|
||||||
}
|
}
|
||||||
case OptionTypeStatsdTags:
|
case OptionTypeStatsdTags:
|
||||||
C.StatsdTags = opt.Value.(map[string]string) // nolint: forcetypeassert
|
C.StatsdTags = opt.Value.(map[string]string) //nolint: forcetypeassert
|
||||||
case OptionTypeWriteBufferSize:
|
case OptionTypeWriteBufferSize:
|
||||||
C.WriteBuffer = int(opt.Value.(units.Base2Bytes)) // nolint: forcetypeassert
|
C.WriteBuffer = int(opt.Value.(units.Base2Bytes)) //nolint: forcetypeassert
|
||||||
case OptionTypeReadBufferSize:
|
case OptionTypeReadBufferSize:
|
||||||
C.ReadBuffer = int(opt.Value.(units.Base2Bytes)) // nolint: forcetypeassert
|
C.ReadBuffer = int(opt.Value.(units.Base2Bytes)) //nolint: forcetypeassert
|
||||||
case OptionTypeCloakPort:
|
case OptionTypeCloakPort:
|
||||||
C.CloakPort = int(opt.Value.(uint16)) // nolint: forcetypeassert
|
C.CloakPort = int(opt.Value.(uint16)) //nolint: forcetypeassert
|
||||||
case OptionTypeAntiReplayMaxSize:
|
case OptionTypeAntiReplayMaxSize:
|
||||||
C.AntiReplayMaxSize = int(opt.Value.(units.Base2Bytes)) // nolint: forcetypeassert
|
C.AntiReplayMaxSize = int(opt.Value.(units.Base2Bytes)) //nolint: forcetypeassert
|
||||||
case OptionTypeMultiplexPerConnection:
|
case OptionTypeMultiplexPerConnection:
|
||||||
C.MultiplexPerConnection = int(opt.Value.(uint)) // nolint: forcetypeassert
|
C.MultiplexPerConnection = int(opt.Value.(uint)) //nolint: forcetypeassert
|
||||||
case OptionTypeNTPServers:
|
case OptionTypeNTPServers:
|
||||||
C.NTPServers = opt.Value.([]string) // nolint: forcetypeassert
|
C.NTPServers = opt.Value.([]string) //nolint: forcetypeassert
|
||||||
if len(C.NTPServers) == 0 {
|
if len(C.NTPServers) == 0 {
|
||||||
return errors.New("ntp server list is empty")
|
return errors.New("ntp server list is empty")
|
||||||
}
|
}
|
||||||
case OptionTypeSecret:
|
case OptionTypeSecret:
|
||||||
C.Secret = opt.Value.([]byte) // nolint: forcetypeassert
|
C.Secret = opt.Value.([]byte) //nolint: forcetypeassert
|
||||||
case OptionTypeAdtag:
|
case OptionTypeAdtag:
|
||||||
C.AdTag = opt.Value.([]byte) // nolint: forcetypeassert
|
C.AdTag = opt.Value.([]byte) //nolint: forcetypeassert
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unknown tag %v", opt.Option)
|
return fmt.Errorf("unknown tag %v", opt.Option)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -41,12 +40,12 @@ func fetchIP(ctx context.Context, network string) (net.IP, error) {
|
|||||||
Timeout: ifconfigTimeout,
|
Timeout: ifconfigTimeout,
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
DialContext: func(ctx context.Context, _, addr string) (net.Conn, error) {
|
DialContext: func(ctx context.Context, _, addr string) (net.Conn, error) {
|
||||||
return dialer.DialContext(ctx, network, addr) // nolint: wrapcheck
|
return dialer.DialContext(ctx, network, addr) //nolint: wrapcheck
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", ifconfigAddress, nil)
|
req, err := http.NewRequest(http.MethodGet, ifconfigAddress, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot create a request: %w", err)
|
return nil, fmt.Errorf("cannot create a request: %w", err)
|
||||||
}
|
}
|
||||||
@@ -54,7 +53,7 @@ func fetchIP(ctx context.Context, network string) (net.IP, error) {
|
|||||||
resp, err := client.Do(req.WithContext(ctx))
|
resp, err := client.Do(req.WithContext(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
io.Copy(ioutil.Discard, resp.Body) // nolint: errcheck
|
io.Copy(io.Discard, resp.Body) //nolint: errcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("cannot perform a request: %w", err)
|
return nil, fmt.Errorf("cannot perform a request: %w", err)
|
||||||
@@ -62,7 +61,7 @@ func fetchIP(ctx context.Context, network string) (net.IP, error) {
|
|||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
respDataBytes, err := ioutil.ReadAll(resp.Body)
|
respDataBytes, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot read response body: %w", err)
|
return nil, fmt.Errorf("cannot read response body: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-6
@@ -8,20 +8,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type URLs struct {
|
type URLs struct {
|
||||||
TG string `json:"tg_url"` // nolint: tagliatelle
|
TG string `json:"tg_url"` //nolint: tagliatelle
|
||||||
TMe string `json:"tme_url"` // nolint: tagliatelle
|
TMe string `json:"tme_url"` //nolint: tagliatelle
|
||||||
TGQRCode string `json:"tg_qrcode"` // nolint: tagliatelle
|
TGQRCode string `json:"tg_qrcode"` //nolint: tagliatelle
|
||||||
TMeQRCode string `json:"tme_qrcode"` // nolint: tagliatelle
|
TMeQRCode string `json:"tme_qrcode"` //nolint: tagliatelle
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPURLs struct {
|
type IPURLs struct {
|
||||||
IPv4 *URLs `json:"ipv4,omitempty"`
|
IPv4 *URLs `json:"ipv4,omitempty"`
|
||||||
IPv6 *URLs `json:"ipv6,omitempty"`
|
IPv6 *URLs `json:"ipv6,omitempty"`
|
||||||
BotSecret string `json:"secret_for_mtproxybot"` // nolint: tagliatelle
|
BotSecret string `json:"secret_for_mtproxybot"` //nolint: tagliatelle
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetURLs() (urls IPURLs) {
|
func GetURLs() IPURLs {
|
||||||
secret := ""
|
secret := ""
|
||||||
|
urls := IPURLs{}
|
||||||
|
|
||||||
switch C.SecretMode {
|
switch C.SecretMode {
|
||||||
case SecretModeSimple:
|
case SecretModeSimple:
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ func (c *ClientProtocol) Handshake(socket conntypes.StreamReadWriteCloser) (conn
|
|||||||
|
|
||||||
conn, err := c.ClientProtocol.Handshake(conn)
|
conn, err := c.ClientProtocol.Handshake(conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err // nolint: wrapcheck
|
return nil, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
return conn, err // nolint: wrapcheck
|
return conn, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ClientProtocol) tlsHandshake(conn io.ReadWriter) error {
|
func (c *ClientProtocol) tlsHandshake(conn io.ReadWriter) error {
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ func cloak(one, another io.ReadWriteCloser) {
|
|||||||
another = rwc.NewPing(ctx, another, channelPing)
|
another = rwc.NewPing(ctx, another, channelPing)
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
|
|
||||||
wg.Add(2) // nolint: gomnd
|
wg.Add(2) //nolint: gomnd
|
||||||
|
|
||||||
go cloakPipe(one, another, wg)
|
go cloakPipe(one, another, wg)
|
||||||
|
|
||||||
@@ -69,5 +69,5 @@ func cloak(one, another io.ReadWriteCloser) {
|
|||||||
func cloakPipe(one io.Writer, another io.Reader, wg *sync.WaitGroup) {
|
func cloakPipe(one io.Writer, another io.Reader, wg *sync.WaitGroup) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
io.Copy(one, another) // nolint: errcheck
|
io.Copy(one, another) //nolint: errcheck
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,20 @@ module github.com/9seconds/mtg
|
|||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/VictoriaMetrics/fastcache v1.9.0
|
github.com/VictoriaMetrics/fastcache v1.10.0
|
||||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137
|
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137
|
||||||
github.com/beevik/ntp v0.3.0
|
github.com/beevik/ntp v0.3.0
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/prometheus/client_golang v1.12.1
|
github.com/prometheus/client_golang v1.13.0
|
||||||
github.com/prometheus/common v0.32.1 // indirect
|
github.com/prometheus/common v0.37.0 // indirect
|
||||||
github.com/prometheus/procfs v0.7.3 // indirect
|
github.com/prometheus/procfs v0.8.0 // indirect
|
||||||
github.com/smira/go-statsd v1.3.2
|
github.com/smira/go-statsd v1.3.2
|
||||||
go.uber.org/multierr v1.8.0 // indirect
|
go.uber.org/multierr v1.8.0 // indirect
|
||||||
go.uber.org/zap v1.21.0
|
go.uber.org/zap v1.22.0
|
||||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd
|
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
|
||||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
|
golang.org/x/net v0.0.0-20220809012201-f428fae20770 // indirect
|
||||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8
|
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 // indirect
|
||||||
google.golang.org/protobuf v1.27.1 // indirect
|
google.golang.org/protobuf v1.28.1 // indirect
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
|||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/VictoriaMetrics/fastcache v1.9.0 h1:oMwsS6c8abz98B7ytAewQ7M1ZN/Im/iwKoE1euaFvhs=
|
github.com/VictoriaMetrics/fastcache v1.10.0 h1:5hDJnLsKLpnUEToub7ETuRu8RCkb40woBZAUiKonXzY=
|
||||||
github.com/VictoriaMetrics/fastcache v1.9.0/go.mod h1:otoTS3xu+6IzF/qByjqzjp3rTuzM3Qf0ScU1UTj97iU=
|
github.com/VictoriaMetrics/fastcache v1.10.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJaNxq6132xHICNP77w8=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
|
||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
@@ -48,7 +48,6 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
|
|||||||
github.com/beevik/ntp v0.3.0 h1:xzVrPrE4ziasFXgBVBZJDP0Wg/KpMwk2KHJ4Ba8GrDw=
|
github.com/beevik/ntp v0.3.0 h1:xzVrPrE4ziasFXgBVBZJDP0Wg/KpMwk2KHJ4Ba8GrDw=
|
||||||
github.com/beevik/ntp v0.3.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg=
|
github.com/beevik/ntp v0.3.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg=
|
||||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
@@ -75,9 +74,11 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2
|
|||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||||
|
github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||||
|
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
@@ -120,8 +121,8 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||||
@@ -173,8 +174,9 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP
|
|||||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||||
github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk=
|
|
||||||
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
||||||
|
github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU=
|
||||||
|
github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
|
||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
@@ -183,14 +185,16 @@ github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6T
|
|||||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
||||||
github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
|
|
||||||
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
|
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
|
||||||
|
github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE=
|
||||||
|
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
|
||||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||||
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
|
|
||||||
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||||
|
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
|
||||||
|
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
@@ -207,7 +211,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
|
||||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
@@ -217,20 +220,18 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
|||||||
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
|
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
|
||||||
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||||
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
|
||||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
|
||||||
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
|
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
|
||||||
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
||||||
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
|
go.uber.org/zap v1.22.0 h1:Zcye5DUgBloQ9BaT4qc9BnjOFog5TvBSAGkJ3Nf70c0=
|
||||||
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
|
go.uber.org/zap v1.22.0/go.mod h1:H4siCOZOrAolnUPJEkfaSjDqyP+BDS0DdDWzwcgt3+U=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
|
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
|
||||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
@@ -261,7 +262,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
|
|||||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
@@ -290,16 +290,18 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/
|
|||||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
|
||||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
|
golang.org/x/net v0.0.0-20220809012201-f428fae20770 h1:dIi4qVdvjZEjiMDv7vhokAZNGnz3kepwuXqFKYDdDMs=
|
||||||
|
golang.org/x/net v0.0.0-20220809012201-f428fae20770/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@@ -309,7 +311,6 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
|
|||||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
@@ -343,21 +344,23 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
|
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs=
|
||||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
@@ -401,11 +404,9 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY
|
|||||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||||
@@ -482,8 +483,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
|
|||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
|
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=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -494,13 +495,11 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
|||||||
+2
-2
@@ -30,7 +30,7 @@ type connection struct {
|
|||||||
channelConnDetach chan conntypes.ConnID
|
channelConnDetach chan conntypes.ConnID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *connection) run() { // nolint: cyclop
|
func (c *connection) run() { //nolint: cyclop
|
||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
||||||
ttl := time.NewTimer(connectionTTL)
|
ttl := time.NewTimer(connectionTTL)
|
||||||
@@ -148,7 +148,7 @@ func newConnection(req *protocol.TelegramRequest) (*connection, error) {
|
|||||||
return nil, fmt.Errorf("cannot create a new connection: %w", err)
|
return nil, fmt.Errorf("cannot create a new connection: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := rand.Int() // nolint: gosec
|
id := rand.Int() //nolint: gosec
|
||||||
rv := &connection{
|
rv := &connection{
|
||||||
conn: conn,
|
conn: conn,
|
||||||
id: id,
|
id: id,
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ func (h *hub) Register(req *protocol.TelegramRequest) (*ProxyConn, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *hub) getMux(req *protocol.TelegramRequest) *mux {
|
func (h *hub) getMux(req *protocol.TelegramRequest) *mux {
|
||||||
key := 32767 + int32(req.ClientProtocol.DC()) + 100000*int32(req.ClientProtocol.ConnectionProtocol()) // nolint: gomnd
|
key := 32767 + int32(req.ClientProtocol.DC()) + 100000*int32(req.ClientProtocol.ConnectionProtocol()) //nolint: gomnd
|
||||||
|
|
||||||
h.mutex.RLock()
|
h.mutex.RLock()
|
||||||
m, ok := h.muxes[key]
|
m, ok := h.muxes[key]
|
||||||
|
|||||||
@@ -3,18 +3,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"runtime/debug"
|
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/cli"
|
"github.com/9seconds/mtg/cli"
|
||||||
"github.com/9seconds/mtg/config"
|
"github.com/9seconds/mtg/config"
|
||||||
"github.com/9seconds/mtg/utils"
|
|
||||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version = "dev" // has to be set by ldflags
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
app = kingpin.New("mtg", "Simple MTPROTO proxy.")
|
app = kingpin.New("mtg", "Simple MTPROTO proxy.")
|
||||||
|
|
||||||
@@ -128,10 +123,6 @@ func main() {
|
|||||||
app.Version(getVersion())
|
app.Version(getVersion())
|
||||||
app.HelpFlag.Short('h')
|
app.HelpFlag.Short('h')
|
||||||
|
|
||||||
if err := utils.SetLimits(); err != nil {
|
|
||||||
cli.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
|
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
|
||||||
case generateSecretCommand.FullCommand():
|
case generateSecretCommand.FullCommand():
|
||||||
cli.Generate(*generateSecretType, *generateCloakHost)
|
cli.Generate(*generateSecretType, *generateCloakHost)
|
||||||
@@ -166,25 +157,3 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVersion() string {
|
|
||||||
if version != "dev" {
|
|
||||||
return version
|
|
||||||
}
|
|
||||||
|
|
||||||
info, ok := debug.ReadBuildInfo()
|
|
||||||
if !ok {
|
|
||||||
return version
|
|
||||||
}
|
|
||||||
|
|
||||||
builder := strings.Builder{}
|
|
||||||
builder.WriteString(info.Main.Version)
|
|
||||||
|
|
||||||
if info.Main.Sum != "" {
|
|
||||||
builder.WriteString(" (checksum: ")
|
|
||||||
builder.WriteString(info.Main.Sum)
|
|
||||||
builder.WriteRune(')')
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.String()
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ func doRPCNonceRequest(conn conntypes.BasePacketWriter) (*rpc.NonceRequest, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := conn.Write(rpcNonceReq.Bytes()); err != nil {
|
if err := conn.Write(rpcNonceReq.Bytes()); err != nil {
|
||||||
return nil, err // nolint: wrapcheck
|
return nil, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcNonceReq, nil
|
return rpcNonceReq, nil
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func (r *HandshakeResponse) Valid() error {
|
|||||||
// NewHandshakeResponse constructs new handshake response from the given
|
// NewHandshakeResponse constructs new handshake response from the given
|
||||||
// data.
|
// data.
|
||||||
func NewHandshakeResponse(data []byte) (*HandshakeResponse, error) {
|
func NewHandshakeResponse(data []byte) (*HandshakeResponse, error) {
|
||||||
if len(data) != 32 { // nolint: gomnd
|
if len(data) != 32 { //nolint: gomnd
|
||||||
return nil, fmt.Errorf("incorrect handshake response length %d", len(data))
|
return nil, fmt.Errorf("incorrect handshake response length %d", len(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ func (r *NonceRequest) Bytes() []byte {
|
|||||||
|
|
||||||
// NewNonceRequest builds new none request based on proxy secret.
|
// NewNonceRequest builds new none request based on proxy secret.
|
||||||
func NewNonceRequest(proxySecret []byte) (*NonceRequest, error) {
|
func NewNonceRequest(proxySecret []byte) (*NonceRequest, error) {
|
||||||
nonce := make([]byte, 16) // nolint: gomnd
|
nonce := make([]byte, 16) //nolint: gomnd
|
||||||
keySelector := make([]byte, 4) // nolint: gomnd
|
keySelector := make([]byte, 4) //nolint: gomnd
|
||||||
cryptoTS := make([]byte, 4) // nolint: gomnd
|
cryptoTS := make([]byte, 4) //nolint: gomnd
|
||||||
|
|
||||||
if _, err := rand.Read(nonce); err != nil {
|
if _, err := rand.Read(nonce); err != nil {
|
||||||
return nil, fmt.Errorf("cannot generate nonce: %w", err)
|
return nil, fmt.Errorf("cannot generate nonce: %w", err)
|
||||||
@@ -39,7 +39,7 @@ func NewNonceRequest(proxySecret []byte) (*NonceRequest, error) {
|
|||||||
|
|
||||||
copy(keySelector, proxySecret)
|
copy(keySelector, proxySecret)
|
||||||
// 256 ^ 4 - do not know how to name
|
// 256 ^ 4 - do not know how to name
|
||||||
timestamp := time.Now().Truncate(time.Second).Unix() % 4294967296 // nolint: gomnd
|
timestamp := time.Now().Truncate(time.Second).Unix() % 4294967296 //nolint: gomnd
|
||||||
binary.LittleEndian.PutUint32(cryptoTS, uint32(timestamp))
|
binary.LittleEndian.PutUint32(cryptoTS, uint32(timestamp))
|
||||||
|
|
||||||
return &NonceRequest{
|
return &NonceRequest{
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func (r *NonceResponse) Valid(req *NonceRequest) error {
|
|||||||
|
|
||||||
// NewNonceResponse build new nonce response based on the given data.
|
// NewNonceResponse build new nonce response based on the given data.
|
||||||
func NewNonceResponse(data []byte) (*NonceResponse, error) {
|
func NewNonceResponse(data []byte) (*NonceResponse, error) {
|
||||||
if len(data) != 32 { // nolint: gomnd
|
if len(data) != 32 { //nolint: gomnd
|
||||||
return nil, fmt.Errorf("unexpected message length %d", len(data))
|
return nil, fmt.Errorf("unexpected message length %d", len(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ const (
|
|||||||
var ProxyRequestFlagsEncryptedPrefix [8]byte
|
var ProxyRequestFlagsEncryptedPrefix [8]byte
|
||||||
|
|
||||||
func (r ProxyRequestFlags) Bytes() []byte {
|
func (r ProxyRequestFlags) Bytes() []byte {
|
||||||
converted := make([]byte, 4) // nolint: gomnd
|
converted := make([]byte, 4) //nolint: gomnd
|
||||||
binary.LittleEndian.PutUint32(converted, uint32(r))
|
binary.LittleEndian.PutUint32(converted, uint32(r))
|
||||||
|
|
||||||
return converted
|
return converted
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r ProxyRequestFlags) String() string {
|
func (r ProxyRequestFlags) String() string {
|
||||||
flags := make([]string, 0, 7) // nolint: gomnd
|
flags := make([]string, 0, 7) //nolint: gomnd
|
||||||
|
|
||||||
if r&ProxyRequestFlagsHasAdTag != 0 {
|
if r&ProxyRequestFlagsHasAdTag != 0 {
|
||||||
flags = append(flags, "HAS_AD_TAG")
|
flags = append(flags, "HAS_AD_TAG")
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type ProxyResponse struct {
|
|||||||
func ParseProxyResponse(packet conntypes.Packet) (*ProxyResponse, error) {
|
func ParseProxyResponse(packet conntypes.Packet) (*ProxyResponse, error) {
|
||||||
var response ProxyResponse
|
var response ProxyResponse
|
||||||
|
|
||||||
if len(packet) < 4 { // nolint: gomnd
|
if len(packet) < 4 { //nolint: gomnd
|
||||||
return nil, fmt.Errorf("incorrect packet length: %d", len(packet))
|
return nil, fmt.Errorf("incorrect packet length: %d", len(packet))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ const autoUpdatePeriod = time.Minute
|
|||||||
|
|
||||||
// Fetch fetches the data on time drift.
|
// Fetch fetches the data on time drift.
|
||||||
func Fetch() (time.Duration, error) {
|
func Fetch() (time.Duration, error) {
|
||||||
url := config.C.NTPServers[rand.Intn(len(config.C.NTPServers))] // nolint: gosec
|
url := config.C.NTPServers[rand.Intn(len(config.C.NTPServers))] //nolint: gosec
|
||||||
|
|
||||||
resp, err := ntp.Query(url)
|
resp, err := ntp.Query(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -93,12 +93,14 @@ func (c *ClientProtocol) Handshake(socket conntypes.StreamReadWriteCloser) (conn
|
|||||||
return stream.NewObfuscated2(socket, encryptor, decryptor), nil
|
return stream.NewObfuscated2(socket, encryptor, decryptor), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ClientProtocol) ReadFrame(socket conntypes.StreamReader) (fm Frame, err error) {
|
func (c *ClientProtocol) ReadFrame(socket conntypes.StreamReader) (Frame, error) {
|
||||||
if _, err = io.ReadFull(handshakeReader{socket}, fm.Bytes()); err != nil {
|
fm := Frame{}
|
||||||
err = fmt.Errorf("cannot extract obfuscated2 frame: %w", err)
|
|
||||||
|
if _, err := io.ReadFull(handshakeReader{socket}, fm.Bytes()); err != nil {
|
||||||
|
return fm, fmt.Errorf("cannot extract obfuscated2 frame: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return fm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type handshakeReader struct {
|
type handshakeReader struct {
|
||||||
@@ -106,7 +108,7 @@ type handshakeReader struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h handshakeReader) Read(p []byte) (int, error) {
|
func (h handshakeReader) Read(p []byte) (int, error) {
|
||||||
return h.parent.ReadTimeout(p, clientProtocolHandshakeTimeout) // nolint: wrapcheck
|
return h.parent.ReadTimeout(p, clientProtocolHandshakeTimeout) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeClientProtocol() protocol.ClientProtocol {
|
func MakeClientProtocol() protocol.ClientProtocol {
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ func (f *Frame) Unique() []byte {
|
|||||||
return f.data[frameOffsetFirst:frameOffsetDC]
|
return f.data[frameOffsetFirst:frameOffsetDC]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frame) Invert() (nf Frame) {
|
func (f *Frame) Invert() Frame {
|
||||||
nf = *f
|
nf := *f
|
||||||
for i := 0; i < frameLenKey+frameLenIV; i++ {
|
for i := 0; i < frameLenKey+frameLenIV; i++ {
|
||||||
nf.data[frameOffsetFirst+i] = f.data[frameOffsetIV-1-i]
|
nf.data[frameOffsetFirst+i] = f.data[frameOffsetIV-1-i]
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return nf
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ func TelegramProtocol(req *protocol.TelegramRequest) (conntypes.StreamReadWriteC
|
|||||||
return stream.NewObfuscated2(conn, encryptor, decryptor), nil
|
return stream.NewObfuscated2(conn, encryptor, decryptor), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateFrame(cp protocol.ClientProtocol) (fm Frame) {
|
func generateFrame(cp protocol.ClientProtocol) Frame {
|
||||||
|
fm := Frame{}
|
||||||
data := fm.Bytes()
|
data := fm.Bytes()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@@ -47,22 +48,22 @@ func generateFrame(cp protocol.ClientProtocol) (fm Frame) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if data[0] == 0xef { // nolint: gomnd
|
if data[0] == 0xef { //nolint: gomnd
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
val := (uint32(data[3]) << 24) | (uint32(data[2]) << 16) | (uint32(data[1]) << 8) | uint32(data[0]) // nolint: gomnd, lll
|
val := (uint32(data[3]) << 24) | (uint32(data[2]) << 16) | (uint32(data[1]) << 8) | uint32(data[0]) //nolint: gomnd, lll
|
||||||
if val == 0x44414548 || val == 0x54534f50 || val == 0x20544547 || val == 0x4954504f || val == 0xeeeeeeee { // nolint: lll
|
if val == 0x44414548 || val == 0x54534f50 || val == 0x20544547 || val == 0x4954504f || val == 0xeeeeeeee { //nolint: lll
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
val = (uint32(data[7]) << 24) | (uint32(data[6]) << 16) | (uint32(data[5]) << 8) | uint32(data[4]) // nolint: gomnd
|
val = (uint32(data[7]) << 24) | (uint32(data[6]) << 16) | (uint32(data[5]) << 8) | uint32(data[4]) //nolint: gomnd
|
||||||
if val == 0x00000000 { // nolint: gomnd
|
if val == 0x00000000 { //nolint: gomnd
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(fm.Magic(), cp.ConnectionType().Tag())
|
copy(fm.Magic(), cp.ConnectionType().Tag())
|
||||||
|
|
||||||
return
|
return fm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -14,13 +14,13 @@ const directPipeBufferSize = 1024
|
|||||||
func directConnection(request *protocol.TelegramRequest) error {
|
func directConnection(request *protocol.TelegramRequest) error {
|
||||||
telegramConnRaw, err := obfuscated2.TelegramProtocol(request)
|
telegramConnRaw, err := obfuscated2.TelegramProtocol(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err // nolint: wrapcheck
|
return err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
defer telegramConnRaw.Close()
|
defer telegramConnRaw.Close()
|
||||||
|
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
wg.Add(2) // nolint: gomnd
|
wg.Add(2) //nolint: gomnd
|
||||||
|
|
||||||
go directPipe(telegramConnRaw, request.ClientConn, wg, request.Logger)
|
go directPipe(telegramConnRaw, request.ClientConn, wg, request.Logger)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ func middleConnection(request *protocol.TelegramRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
wg.Add(2) // nolint: gomnd
|
wg.Add(2) //nolint: gomnd
|
||||||
|
|
||||||
go middlePipe(telegramConn, clientConn, wg, request.Logger)
|
go middlePipe(telegramConn, clientConn, wg, request.Logger)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -28,11 +28,11 @@ func Init(ctx context.Context) error {
|
|||||||
Handler: mux,
|
Handler: mux,
|
||||||
}
|
}
|
||||||
|
|
||||||
go srv.Serve(listener) // nolint: errcheck
|
go srv.Serve(listener) //nolint: errcheck
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
srv.Shutdown(context.Background()) // nolint: errcheck, contextcheck
|
srv.Shutdown(context.Background()) //nolint: errcheck
|
||||||
}()
|
}()
|
||||||
|
|
||||||
Stats = multiStats(stats)
|
Stats = multiStats(stats)
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func (s *statsStatsd) ClientDisconnected(connectionType conntypes.ConnectionType
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *statsStatsd) changeConnections(connectionType conntypes.ConnectionType, addr *net.TCPAddr, increment int64) {
|
func (s *statsStatsd) changeConnections(connectionType conntypes.ConnectionType, addr *net.TCPAddr, increment int64) {
|
||||||
tags := make([]*statsStatsdTag, 0, 2) // nolint: gomnd
|
tags := make([]*statsStatsdTag, 0, 2) //nolint: gomnd
|
||||||
|
|
||||||
switch connectionType {
|
switch connectionType {
|
||||||
case conntypes.ConnectionTypeAbridged:
|
case conntypes.ConnectionTypeAbridged:
|
||||||
@@ -172,7 +172,7 @@ func (s *statsStatsd) initGauge(metric, key string, tags []statsd.Tag) {
|
|||||||
s.seenMutex.RUnlock()
|
s.seenMutex.RUnlock()
|
||||||
|
|
||||||
return
|
return
|
||||||
} else { // nolint: golint,revive
|
} else { //nolint: golint,revive
|
||||||
s.seenMutex.RUnlock()
|
s.seenMutex.RUnlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,8 +194,8 @@ func newStatsStatsd() Interface {
|
|||||||
return &statsStatsd{
|
return &statsStatsd{
|
||||||
seen: make(map[string]struct{}),
|
seen: make(map[string]struct{}),
|
||||||
client: statsd.NewClient(config.C.StatsdAddr.String(),
|
client: statsd.NewClient(config.C.StatsdAddr.String(),
|
||||||
statsd.SendLoopCount(2), // nolint: gomnd
|
statsd.SendLoopCount(2), //nolint: gomnd
|
||||||
statsd.ReconnectInterval(10*time.Second), // nolint: gomnd
|
statsd.ReconnectInterval(10*time.Second), //nolint: gomnd
|
||||||
statsd.Logger(logger),
|
statsd.Logger(logger),
|
||||||
statsd.MetricPrefix(prefix),
|
statsd.MetricPrefix(prefix),
|
||||||
statsd.TagStyle(config.C.StatsdTagsFormat),
|
statsd.TagStyle(config.C.StatsdTagsFormat),
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
addressesURLV4 = "https://core.telegram.org/getProxyConfig" // nolint: gas
|
addressesURLV4 = "https://core.telegram.org/getProxyConfig" //nolint: gas
|
||||||
addressesURLV6 = "https://core.telegram.org/getProxyConfigV6" // nolint: gas
|
addressesURLV6 = "https://core.telegram.org/getProxyConfigV6" //nolint: gas
|
||||||
)
|
)
|
||||||
|
|
||||||
var addressesProxyForSplitter = regexp.MustCompile(`\s+`)
|
var addressesProxyForSplitter = regexp.MustCompile(`\s+`)
|
||||||
@@ -74,12 +74,12 @@ func getAddresses(url string) (map[conntypes.DC][]string, conntypes.DC, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addressesParseProxyFor(text string) (string, conntypes.DC, error) {
|
func addressesParseProxyFor(text string) (string, conntypes.DC, error) {
|
||||||
chunks := addressesProxyForSplitter.Split(text, 3) // nolint: gomnd
|
chunks := addressesProxyForSplitter.Split(text, 3) //nolint: gomnd
|
||||||
if len(chunks) != 3 || chunks[0] != "proxy_for" {
|
if len(chunks) != 3 || chunks[0] != "proxy_for" {
|
||||||
return "", 0, fmt.Errorf("incorrect config %s", text)
|
return "", 0, fmt.Errorf("incorrect config %s", text)
|
||||||
}
|
}
|
||||||
|
|
||||||
dc, err := strconv.ParseInt(chunks[1], 10, 16) // nolint: gomnd
|
dc, err := strconv.ParseInt(chunks[1], 10, 16) //nolint: gomnd
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", 0, fmt.Errorf("incorrect config '%s': %w", text, err)
|
return "", 0, fmt.Errorf("incorrect config '%s': %w", text, err)
|
||||||
}
|
}
|
||||||
@@ -93,14 +93,14 @@ func addressesParseProxyFor(text string) (string, conntypes.DC, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addressesParseDefault(text string) (conntypes.DC, error) {
|
func addressesParseDefault(text string) (conntypes.DC, error) {
|
||||||
chunks := addressesProxyForSplitter.Split(text, 2) // nolint: gomnd
|
chunks := addressesProxyForSplitter.Split(text, 2) //nolint: gomnd
|
||||||
if len(chunks) != 2 || chunks[0] != "default" {
|
if len(chunks) != 2 || chunks[0] != "default" {
|
||||||
return 0, fmt.Errorf("incorrect config '%s'", text)
|
return 0, fmt.Errorf("incorrect config '%s'", text)
|
||||||
}
|
}
|
||||||
|
|
||||||
dcString := strings.TrimRight(chunks[1], ";")
|
dcString := strings.TrimRight(chunks[1], ";")
|
||||||
|
|
||||||
dc, err := strconv.ParseInt(dcString, 10, 16) // nolint: gomnd
|
dc, err := strconv.ParseInt(dcString, 10, 16) //nolint: gomnd
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("incorrect config '%s': %w", text, err)
|
return 0, fmt.Errorf("incorrect config '%s': %w", text, err)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -22,7 +21,7 @@ func request(url string) (io.ReadCloser, error) {
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), apiHTTPTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), apiHTTPTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -33,12 +32,12 @@ func request(url string) (io.ReadCloser, error) {
|
|||||||
resp, err := httpClient.Do(req)
|
resp, err := httpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
io.Copy(ioutil.Discard, resp.Body) // nolint: errcheck
|
io.Copy(io.Discard, resp.Body) //nolint: errcheck
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("cannot perform a request: %w", err)
|
return nil, fmt.Errorf("cannot perform a request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Body, err // nolint: wrapcheck
|
return resp.Body, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
const secretURL = "https://core.telegram.org/getProxySecret" // nolint: gas
|
const secretURL = "https://core.telegram.org/getProxySecret" //nolint: gas
|
||||||
|
|
||||||
func Secret() ([]byte, error) {
|
func Secret() ([]byte, error) {
|
||||||
resp, err := request(secretURL)
|
resp, err := request(secretURL)
|
||||||
@@ -15,7 +15,7 @@ func Secret() ([]byte, error) {
|
|||||||
|
|
||||||
defer resp.Close()
|
defer resp.Close()
|
||||||
|
|
||||||
secret, err := ioutil.ReadAll(resp)
|
secret, err := io.ReadAll(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot read response: %w", err)
|
return nil, fmt.Errorf("cannot read response: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -51,7 +51,7 @@ func (b *baseTelegram) dial(dc conntypes.DC,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseTelegram) getAddresses(dc conntypes.DC, protocol conntypes.ConnectionProtocol) []string {
|
func (b *baseTelegram) getAddresses(dc conntypes.DC, protocol conntypes.ConnectionProtocol) []string {
|
||||||
addresses := make([]string, 0, 2) // nolint: gomnd
|
addresses := make([]string, 0, 2) //nolint: gomnd
|
||||||
protos := []conntypes.ConnectionProtocol{
|
protos := []conntypes.ConnectionProtocol{
|
||||||
conntypes.ConnectionProtocolIPv6,
|
conntypes.ConnectionProtocolIPv6,
|
||||||
conntypes.ConnectionProtocolIPv4,
|
conntypes.ConnectionProtocolIPv4,
|
||||||
@@ -86,7 +86,7 @@ func (b *baseTelegram) chooseAddress(addresses map[conntypes.DC][]string,
|
|||||||
case len(addrs) == 1:
|
case len(addrs) == 1:
|
||||||
return addrs[0]
|
return addrs[0]
|
||||||
case len(addrs) > 1:
|
case len(addrs) > 1:
|
||||||
return addrs[rand.Intn(len(addrs))] // nolint: gosec
|
return addrs[rand.Intn(len(addrs))] //nolint: gosec
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
+14
-14
@@ -20,22 +20,22 @@ const (
|
|||||||
type CipherSuiteType uint8
|
type CipherSuiteType uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CipherSuiteType_TLS_AES_128_GCM_SHA256 CipherSuiteType = iota // nolint: stylecheck,golint,revive
|
CipherSuiteType_TLS_AES_128_GCM_SHA256 CipherSuiteType = iota //nolint: stylecheck,golint,revive,nosnakecase
|
||||||
CipherSuiteType_TLS_AES_256_GCM_SHA384 // nolint: stylecheck,golint,revive
|
CipherSuiteType_TLS_AES_256_GCM_SHA384 //nolint: stylecheck,golint,revive,nosnakecase
|
||||||
CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256 // nolint: stylecheck,golint,revive
|
CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256 //nolint: stylecheck,golint,revive,nosnakecase
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c CipherSuiteType) Bytes() []byte {
|
func (c CipherSuiteType) Bytes() []byte {
|
||||||
switch c {
|
switch c {
|
||||||
case CipherSuiteType_TLS_AES_128_GCM_SHA256:
|
case CipherSuiteType_TLS_AES_128_GCM_SHA256: //nolint: nosnakecase
|
||||||
return CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes
|
return CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes //nolint: nosnakecase
|
||||||
case CipherSuiteType_TLS_AES_256_GCM_SHA384:
|
case CipherSuiteType_TLS_AES_256_GCM_SHA384: //nolint: nosnakecase
|
||||||
return CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes
|
return CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes //nolint: nosnakecase
|
||||||
case CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256:
|
case CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256: //nolint: nosnakecase
|
||||||
return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes
|
return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes //nolint: nosnakecase
|
||||||
}
|
}
|
||||||
|
|
||||||
return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes
|
return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes //nolint: nosnakecase
|
||||||
}
|
}
|
||||||
|
|
||||||
type Version uint8
|
type Version uint8
|
||||||
@@ -69,9 +69,9 @@ var (
|
|||||||
Version12Bytes = []byte{0x03, 0x03}
|
Version12Bytes = []byte{0x03, 0x03}
|
||||||
Version13Bytes = []byte{0x03, 0x04}
|
Version13Bytes = []byte{0x03, 0x04}
|
||||||
|
|
||||||
CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes = []byte{0x13, 0x01} // nolint: stylecheck,golint,revive
|
CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes = []byte{0x13, 0x01} //nolint: stylecheck,golint,revive,nosnakecase
|
||||||
CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes = []byte{0x13, 0x02} // nolint: stylecheck,golint,revive
|
CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes = []byte{0x13, 0x02} //nolint: stylecheck,golint,revive,nosnakecase
|
||||||
CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes = []byte{0x13, 0x03} // nolint: stylecheck,golint,revive
|
CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes = []byte{0x13, 0x03} //nolint: stylecheck,golint,revive,nosnakecase
|
||||||
)
|
)
|
||||||
|
|
||||||
type Byter interface {
|
type Byter interface {
|
||||||
@@ -82,7 +82,7 @@ type Byter interface {
|
|||||||
type RawBytes []byte
|
type RawBytes []byte
|
||||||
|
|
||||||
func (r RawBytes) WriteBytes(writer io.Writer) {
|
func (r RawBytes) WriteBytes(writer io.Writer) {
|
||||||
writer.Write(r) // nolint: errcheck
|
writer.Write(r) //nolint: errcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r RawBytes) Len() int {
|
func (r RawBytes) Len() int {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type Handshake struct {
|
|||||||
func (h *Handshake) WriteBytes(writer io.Writer) {
|
func (h *Handshake) WriteBytes(writer io.Writer) {
|
||||||
packetBuf := bytes.Buffer{}
|
packetBuf := bytes.Buffer{}
|
||||||
|
|
||||||
writer.Write([]byte{byte(h.Type)}) // nolint: errcheck
|
writer.Write([]byte{byte(h.Type)}) //nolint: errcheck
|
||||||
|
|
||||||
packetBuf.Write(h.Version.Bytes())
|
packetBuf.Write(h.Version.Bytes())
|
||||||
packetBuf.Write(h.Random[:])
|
packetBuf.Write(h.Random[:])
|
||||||
@@ -30,8 +30,8 @@ func (h *Handshake) WriteBytes(writer io.Writer) {
|
|||||||
sizeUint24Bytes := sizeUint24[:]
|
sizeUint24Bytes := sizeUint24[:]
|
||||||
sizeUint24Bytes[0], sizeUint24Bytes[2] = sizeUint24Bytes[2], sizeUint24Bytes[0]
|
sizeUint24Bytes[0], sizeUint24Bytes[2] = sizeUint24Bytes[2], sizeUint24Bytes[0]
|
||||||
|
|
||||||
writer.Write(sizeUint24Bytes) // nolint: errcheck
|
writer.Write(sizeUint24Bytes) //nolint: errcheck
|
||||||
packetBuf.WriteTo(writer) // nolint: errcheck
|
packetBuf.WriteTo(writer) //nolint: errcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handshake) Len() int {
|
func (h *Handshake) Len() int {
|
||||||
|
|||||||
+7
-5
@@ -16,9 +16,9 @@ type Record struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r Record) WriteBytes(writer io.Writer) {
|
func (r Record) WriteBytes(writer io.Writer) {
|
||||||
writer.Write([]byte{byte(r.Type)}) // nolint: errcheck
|
writer.Write([]byte{byte(r.Type)}) //nolint: errcheck
|
||||||
writer.Write(r.Version.Bytes()) // nolint: errcheck
|
writer.Write(r.Version.Bytes()) //nolint: errcheck
|
||||||
binary.Write(writer, binary.BigEndian, uint16(r.Data.Len())) // nolint: errcheck
|
binary.Write(writer, binary.BigEndian, uint16(r.Data.Len())) //nolint: errcheck
|
||||||
r.Data.WriteBytes(writer)
|
r.Data.WriteBytes(writer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,9 @@ func ReadRecord(reader io.Reader) (Record, error) {
|
|||||||
return rec, nil
|
return rec, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeRecords(raw []byte) (arr []Record) {
|
func MakeRecords(raw []byte) []Record {
|
||||||
|
var arr []Record
|
||||||
|
|
||||||
for len(raw) > 0 {
|
for len(raw) > 0 {
|
||||||
chunkSize := recordMaxChunkSize
|
chunkSize := recordMaxChunkSize
|
||||||
if chunkSize > len(raw) {
|
if chunkSize > len(raw) {
|
||||||
@@ -80,5 +82,5 @@ func MakeRecords(raw []byte) (arr []Record) {
|
|||||||
raw = raw[chunkSize:]
|
raw = raw[chunkSize:]
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return arr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ func (s ServerHello) WelcomePacket() []byte {
|
|||||||
}
|
}
|
||||||
recChangeCipher.WriteBytes(buf)
|
recChangeCipher.WriteBytes(buf)
|
||||||
|
|
||||||
hostCert := make([]byte, 1024+mrand.Intn(3092)) // nolint: gosec, gomnd
|
hostCert := make([]byte, 1024+mrand.Intn(3092)) //nolint: gosec, gomnd
|
||||||
rand.Read(hostCert) // nolint: errcheck
|
rand.Read(hostCert) //nolint: errcheck
|
||||||
|
|
||||||
recData := Record{
|
recData := Record{
|
||||||
Type: RecordTypeApplicationData,
|
Type: RecordTypeApplicationData,
|
||||||
@@ -66,8 +66,8 @@ func NewServerHello(clientHello *ClientHello) *ServerHello {
|
|||||||
rv.SessionID = make([]byte, len(clientHello.SessionID))
|
rv.SessionID = make([]byte, len(clientHello.SessionID))
|
||||||
copy(rv.SessionID, clientHello.SessionID)
|
copy(rv.SessionID, clientHello.SessionID)
|
||||||
|
|
||||||
tail := bytes.NewBuffer(CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes)
|
tail := bytes.NewBuffer(CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes) //nolint: nosnakecase
|
||||||
tail.WriteByte(0x00) // nolint: gomnd // no compression
|
tail.WriteByte(0x00) //nolint: gomnd // no compression
|
||||||
makeTLSExtensions(tail)
|
makeTLSExtensions(tail)
|
||||||
rv.Tail = RawBytes(tail.Bytes())
|
rv.Tail = RawBytes(tail.Bytes())
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ func NewServerHello(clientHello *ClientHello) *ServerHello {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func makeTLSExtensions(buf io.Writer) {
|
func makeTLSExtensions(buf io.Writer) {
|
||||||
buf.Write([]byte{ // nolint: errcheck
|
buf.Write([]byte{ //nolint: errcheck
|
||||||
0x00, 0x2e, // 46 bytes of data
|
0x00, 0x2e, // 46 bytes of data
|
||||||
0x00, 0x33, // Extension - Key Share
|
0x00, 0x33, // Extension - Key Share
|
||||||
0x00, 0x24, // 36 bytes
|
0x00, 0x24, // 36 bytes
|
||||||
@@ -85,11 +85,11 @@ func makeTLSExtensions(buf io.Writer) {
|
|||||||
|
|
||||||
var scalar [32]byte
|
var scalar [32]byte
|
||||||
|
|
||||||
rand.Read(scalar[:]) // nolint: errcheck
|
rand.Read(scalar[:]) //nolint: errcheck
|
||||||
curve, _ := curve25519.X25519(scalar[:], curve25519.Basepoint)
|
curve, _ := curve25519.X25519(scalar[:], curve25519.Basepoint)
|
||||||
buf.Write(curve) // nolint: errcheck
|
buf.Write(curve) //nolint: errcheck
|
||||||
|
|
||||||
buf.Write([]byte{ // nolint: errcheck
|
buf.Write([]byte{ //nolint: errcheck
|
||||||
0x00, 0x2b, // Extension - Supported Versions
|
0x00, 0x2b, // Extension - Supported Versions
|
||||||
0x00, 0x02, // 2 bytes are following
|
0x00, 0x02, // 2 bytes are following
|
||||||
0x03, 0x04, // TLS 1.3
|
0x03, 0x04, // TLS 1.3
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func InitTCP(conn net.Conn, readBufferSize, writeBufferSize int) error {
|
func InitTCP(conn net.Conn, readBufferSize, writeBufferSize int) error {
|
||||||
tcpConn := conn.(*net.TCPConn) // nolint: forcetypeassert
|
tcpConn := conn.(*net.TCPConn) //nolint: forcetypeassert
|
||||||
|
|
||||||
if err := tcpConn.SetNoDelay(true); err != nil {
|
if err := tcpConn.SetNoDelay(true); err != nil {
|
||||||
return fmt.Errorf("cannot set TCP_NO_DELAY: %w", err)
|
return fmt.Errorf("cannot set TCP_NO_DELAY: %w", err)
|
||||||
|
|||||||
+4
-3
@@ -4,14 +4,15 @@ import "io"
|
|||||||
|
|
||||||
const readFullBufferSize = 1024 + 1 // +1 because telegram opreates with blocks mod 4
|
const readFullBufferSize = 1024 + 1 // +1 because telegram opreates with blocks mod 4
|
||||||
|
|
||||||
func ReadFull(src io.Reader) (rv []byte, err error) {
|
func ReadFull(src io.Reader) ([]byte, error) {
|
||||||
buf := make([]byte, readFullBufferSize)
|
buf := make([]byte, readFullBufferSize)
|
||||||
n := readFullBufferSize
|
n := readFullBufferSize
|
||||||
|
rv := []byte{}
|
||||||
|
|
||||||
for n == len(buf) {
|
for n == len(buf) {
|
||||||
n, err = src.Read(buf)
|
n, err := src.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err // nolint: wrapcheck
|
return nil, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = append(rv, buf[:n]...)
|
rv = append(rv, buf[:n]...)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ func ReverseBytes(data []byte) []byte {
|
|||||||
rv := make([]byte, dataLen)
|
rv := make([]byte, dataLen)
|
||||||
rv[dataLen/2] = data[dataLen/2]
|
rv[dataLen/2] = data[dataLen/2]
|
||||||
|
|
||||||
for i := dataLen/2 - 1; i >= 0; i-- { // nolint: gomnd
|
for i := dataLen/2 - 1; i >= 0; i-- { //nolint: gomnd
|
||||||
opp := dataLen - i - 1
|
opp := dataLen - i - 1
|
||||||
rv[i], rv[opp] = data[opp], data[i]
|
rv[i], rv[opp] = data[opp], data[i]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
//go:build !windows
|
|
||||||
// +build !windows
|
|
||||||
|
|
||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
func SetLimits() error {
|
|
||||||
rLimit := unix.Rlimit{}
|
|
||||||
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rLimit); err != nil {
|
|
||||||
return fmt.Errorf("cannot get rlimit: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
rLimit.Cur = rLimit.Max
|
|
||||||
|
|
||||||
if err := unix.Setrlimit(unix.RLIMIT_NOFILE, &rLimit); err != nil {
|
|
||||||
return fmt.Errorf("cannot set rlimit: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
+2
-2
@@ -3,9 +3,9 @@ package utils
|
|||||||
type Uint24 [3]byte
|
type Uint24 [3]byte
|
||||||
|
|
||||||
func ToUint24(number uint32) Uint24 {
|
func ToUint24(number uint32) Uint24 {
|
||||||
return Uint24{byte(number), byte(number >> 8), byte(number >> 16)} // nolint: gomnd
|
return Uint24{byte(number), byte(number >> 8), byte(number >> 16)} //nolint: gomnd
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromUint24(number Uint24) uint32 {
|
func FromUint24(number Uint24) uint32 {
|
||||||
return uint32(number[0]) + (uint32(number[1]) << 8) + (uint32(number[2]) << 16) // nolint: gomnd
|
return uint32(number[0]) + (uint32(number[1]) << 8) + (uint32(number[2]) << 16) //nolint: gomnd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/conntypes"
|
"github.com/9seconds/mtg/conntypes"
|
||||||
@@ -28,10 +27,13 @@ var mtprotoFramePadding = []byte{0x04, 0x00, 0x00, 0x00}
|
|||||||
//
|
//
|
||||||
// MSGLEN is the length of the message + len of seqno and msglen.
|
// MSGLEN is the length of the message + len of seqno and msglen.
|
||||||
// SEQNO is the number of frame in the receive/send sequence. If client
|
// SEQNO is the number of frame in the receive/send sequence. If client
|
||||||
|
//
|
||||||
// sends a message with SeqNo 18, it has to receive message with SeqNo 18.
|
// sends a message with SeqNo 18, it has to receive message with SeqNo 18.
|
||||||
|
//
|
||||||
// MSG is the data which has to be written
|
// MSG is the data which has to be written
|
||||||
// CRC32 is the CRC32 checksum of MSGLEN + SEQNO + MSG
|
// CRC32 is the CRC32 checksum of MSGLEN + SEQNO + MSG
|
||||||
// PADDING is custom padding schema to complete frame length to such that
|
// PADDING is custom padding schema to complete frame length to such that
|
||||||
|
//
|
||||||
// len(frame) % 16 == 0
|
// len(frame) % 16 == 0
|
||||||
type wrapperMtprotoFrame struct {
|
type wrapperMtprotoFrame struct {
|
||||||
parent conntypes.StreamReadWriteCloser
|
parent conntypes.StreamReadWriteCloser
|
||||||
@@ -40,7 +42,7 @@ type wrapperMtprotoFrame struct {
|
|||||||
writeSeqNo int32
|
writeSeqNo int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperMtprotoFrame) Read() (conntypes.Packet, error) { // nolint: funlen, cyclop
|
func (w *wrapperMtprotoFrame) Read() (conntypes.Packet, error) { //nolint: funlen, cyclop
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
|
|
||||||
sum := crc32.NewIEEE()
|
sum := crc32.NewIEEE()
|
||||||
@@ -50,7 +52,7 @@ func (w *wrapperMtprotoFrame) Read() (conntypes.Packet, error) { // nolint: funl
|
|||||||
buf.Reset()
|
buf.Reset()
|
||||||
sum.Reset()
|
sum.Reset()
|
||||||
|
|
||||||
if _, err := io.CopyN(writer, w.parent, 4); err != nil { // nolint: gomnd
|
if _, err := io.CopyN(writer, w.parent, 4); err != nil { //nolint: gomnd
|
||||||
return nil, fmt.Errorf("cannot read frame padding: %w", err)
|
return nil, fmt.Errorf("cannot read frame padding: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,23 +74,23 @@ func (w *wrapperMtprotoFrame) Read() (conntypes.Packet, error) { // nolint: funl
|
|||||||
|
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
|
|
||||||
if _, err := io.CopyN(writer, w.parent, int64(messageLength)-4-4); err != nil { // nolint: gomnd
|
if _, err := io.CopyN(writer, w.parent, int64(messageLength)-4-4); err != nil { //nolint: gomnd
|
||||||
return nil, fmt.Errorf("cannot read the message frame: %w", err)
|
return nil, fmt.Errorf("cannot read the message frame: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var seqNo int32
|
var seqNo int32
|
||||||
|
|
||||||
binary.Read(buf, binary.LittleEndian, &seqNo) // nolint: errcheck
|
binary.Read(buf, binary.LittleEndian, &seqNo) //nolint: errcheck
|
||||||
|
|
||||||
if seqNo != w.readSeqNo {
|
if seqNo != w.readSeqNo {
|
||||||
return nil, fmt.Errorf("unexpected sequence number %d (wait for %d)", seqNo, w.readSeqNo)
|
return nil, fmt.Errorf("unexpected sequence number %d (wait for %d)", seqNo, w.readSeqNo)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, _ := ioutil.ReadAll(buf)
|
data, _ := io.ReadAll(buf)
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
// write to buf, not to writer. This is because we are going to fetch
|
// write to buf, not to writer. This is because we are going to fetch
|
||||||
// crc32 checksum.
|
// crc32 checksum.
|
||||||
if _, err := io.CopyN(buf, w.parent, 4); err != nil { // nolint: gomnd
|
if _, err := io.CopyN(buf, w.parent, 4); err != nil { //nolint: gomnd
|
||||||
return nil, fmt.Errorf("cannot read checksum: %w", err)
|
return nil, fmt.Errorf("cannot read checksum: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,18 +111,18 @@ func (w *wrapperMtprotoFrame) Read() (conntypes.Packet, error) { // nolint: funl
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperMtprotoFrame) Write(p conntypes.Packet) error {
|
func (w *wrapperMtprotoFrame) Write(p conntypes.Packet) error {
|
||||||
messageLength := 4 + 4 + len(p) + 4 // nolint: gomnd
|
messageLength := 4 + 4 + len(p) + 4 //nolint: gomnd
|
||||||
paddingLength := (aes.BlockSize - messageLength%aes.BlockSize) % aes.BlockSize
|
paddingLength := (aes.BlockSize - messageLength%aes.BlockSize) % aes.BlockSize
|
||||||
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
|
|
||||||
binary.Write(buf, binary.LittleEndian, uint32(messageLength)) // nolint: errcheck
|
binary.Write(buf, binary.LittleEndian, uint32(messageLength)) //nolint: errcheck
|
||||||
binary.Write(buf, binary.LittleEndian, w.writeSeqNo) // nolint: errcheck
|
binary.Write(buf, binary.LittleEndian, w.writeSeqNo) //nolint: errcheck
|
||||||
buf.Write(p)
|
buf.Write(p)
|
||||||
|
|
||||||
checksum := crc32.ChecksumIEEE(buf.Bytes())
|
checksum := crc32.ChecksumIEEE(buf.Bytes())
|
||||||
binary.Write(buf, binary.LittleEndian, checksum) // nolint: errcheck
|
binary.Write(buf, binary.LittleEndian, checksum) //nolint: errcheck
|
||||||
buf.Write(bytes.Repeat(mtprotoFramePadding, paddingLength/4)) // nolint: gomnd
|
buf.Write(bytes.Repeat(mtprotoFramePadding, paddingLength/4)) //nolint: gomnd
|
||||||
|
|
||||||
w.logger.Debugw("Write MTProto frame",
|
w.logger.Debugw("Write MTProto frame",
|
||||||
"length", len(p),
|
"length", len(p),
|
||||||
@@ -132,11 +134,11 @@ func (w *wrapperMtprotoFrame) Write(p conntypes.Packet) error {
|
|||||||
|
|
||||||
_, err := w.parent.Write(buf.Bytes())
|
_, err := w.parent.Write(buf.Bytes())
|
||||||
|
|
||||||
return err // nolint: wrapcheck
|
return err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperMtprotoFrame) Close() error {
|
func (w *wrapperMtprotoFrame) Close() error {
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperMtprotoFrame) Conn() net.Conn {
|
func (w *wrapperMtprotoFrame) Conn() net.Conn {
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ func (w *wrapperClientAbridged) Read(acks *conntypes.ConnectionAcks) (conntypes.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if msgLength == clientAbridgedSmallPacketLength {
|
if msgLength == clientAbridgedSmallPacketLength {
|
||||||
buf.Grow(3) // nolint: gomnd
|
buf.Grow(3) //nolint: gomnd
|
||||||
|
|
||||||
if _, err := io.CopyN(&buf, w.parent, 3); err != nil { // nolint: gomnd
|
if _, err := io.CopyN(&buf, w.parent, 3); err != nil { //nolint: gomnd
|
||||||
return nil, fmt.Errorf("cannot read correct message length: %w", err)
|
return nil, fmt.Errorf("cannot read correct message length: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ func (w *wrapperClientAbridged) Write(packet conntypes.Packet, acks *conntypes.C
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
packetLength := len(packet) / 4 // nolint: gomnd
|
packetLength := len(packet) / 4 //nolint: gomnd
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case packetLength < clientAbridgedSmallPacketLength:
|
case packetLength < clientAbridgedSmallPacketLength:
|
||||||
@@ -104,7 +104,7 @@ func (w *wrapperClientAbridged) Write(packet conntypes.Packet, acks *conntypes.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperClientAbridged) Close() error {
|
func (w *wrapperClientAbridged) Close() error {
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperClientAbridged) Conn() net.Conn {
|
func (w *wrapperClientAbridged) Conn() net.Conn {
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ type wrapperClientIntermediate struct {
|
|||||||
func (w *wrapperClientIntermediate) Read(acks *conntypes.ConnectionAcks) (conntypes.Packet, error) {
|
func (w *wrapperClientIntermediate) Read(acks *conntypes.ConnectionAcks) (conntypes.Packet, error) {
|
||||||
buf := bytes.Buffer{}
|
buf := bytes.Buffer{}
|
||||||
|
|
||||||
buf.Grow(4) // nolint: gomnd
|
buf.Grow(4) //nolint: gomnd
|
||||||
|
|
||||||
if _, err := io.CopyN(&buf, w.parent, 4); err != nil { // nolint: gomnd
|
if _, err := io.CopyN(&buf, w.parent, 4); err != nil { //nolint: gomnd
|
||||||
return nil, fmt.Errorf("cannot read message length: %w", err)
|
return nil, fmt.Errorf("cannot read message length: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ func (w *wrapperClientIntermediate) Write(packet conntypes.Packet, acks *conntyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperClientIntermediate) Close() error {
|
func (w *wrapperClientIntermediate) Close() error {
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperClientIntermediate) Conn() net.Conn {
|
func (w *wrapperClientIntermediate) Conn() net.Conn {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func (w *wrapperClientIntermediateSecure) Read(acks *conntypes.ConnectionAcks) (
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
length := len(data) - (len(data) % 4) // nolint: gomnd
|
length := len(data) - (len(data) % 4) //nolint: gomnd
|
||||||
|
|
||||||
return data[:length], nil
|
return data[:length], nil
|
||||||
}
|
}
|
||||||
@@ -35,11 +35,11 @@ func (w *wrapperClientIntermediateSecure) Write(packet conntypes.Packet, acks *c
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
paddingLength := rand.Intn(4) // nolint: gosec, gomnd
|
paddingLength := rand.Intn(4) //nolint: gosec, gomnd
|
||||||
|
|
||||||
buf.Grow(4 + len(packet) + paddingLength)
|
buf.Grow(4 + len(packet) + paddingLength)
|
||||||
|
|
||||||
binary.Write(buf, binary.LittleEndian, uint32(len(packet)+paddingLength)) // nolint: errcheck
|
binary.Write(buf, binary.LittleEndian, uint32(len(packet)+paddingLength)) //nolint: errcheck
|
||||||
buf.Write(packet)
|
buf.Write(packet)
|
||||||
buf.Write(make([]byte, paddingLength))
|
buf.Write(make([]byte, paddingLength))
|
||||||
|
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ func (w *wrapperProxy) Write(packet conntypes.Packet, acks *conntypes.Connection
|
|||||||
buf.Write(rpc.ProxyRequestProxyTag)
|
buf.Write(rpc.ProxyRequestProxyTag)
|
||||||
buf.WriteByte(byte(len(config.C.AdTag)))
|
buf.WriteByte(byte(len(config.C.AdTag)))
|
||||||
buf.Write(config.C.AdTag)
|
buf.Write(config.C.AdTag)
|
||||||
buf.Write(make([]byte, (4-buf.Len()%4)%4)) // nolint: gomnd
|
buf.Write(make([]byte, (4-buf.Len()%4)%4)) //nolint: gomnd
|
||||||
buf.Grow(len(packet))
|
buf.Grow(len(packet))
|
||||||
buf.Write(packet)
|
buf.Write(packet)
|
||||||
|
|
||||||
return w.proxy.Write(buf.Bytes()) // nolint: wrapcheck
|
return w.proxy.Write(buf.Bytes()) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperProxy) Read(acks *conntypes.ConnectionAcks) (conntypes.Packet, error) {
|
func (w *wrapperProxy) Read(acks *conntypes.ConnectionAcks) (conntypes.Packet, error) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func (w *wrapperPing) Read(p []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return n, err // nolint: wrapcheck
|
return n, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperPing) Write(p []byte) (int, error) {
|
func (w *wrapperPing) Write(p []byte) (int, error) {
|
||||||
@@ -32,11 +32,11 @@ func (w *wrapperPing) Write(p []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return n, err // nolint: wrapcheck
|
return n, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperPing) Close() error {
|
func (w *wrapperPing) Close() error {
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPing(ctx context.Context, parent io.ReadWriteCloser, channelPing chan<- struct{}) io.ReadWriteCloser {
|
func NewPing(ctx context.Context, parent io.ReadWriteCloser, channelPing chan<- struct{}) io.ReadWriteCloser {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (w *wrapperBlockCipher) Write(p []byte) (int, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.parent.Write(encrypted) // nolint: wrapcheck
|
return w.parent.Write(encrypted) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperBlockCipher) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperBlockCipher) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
@@ -35,7 +35,7 @@ func (w *wrapperBlockCipher) WriteTimeout(p []byte, timeout time.Duration) (int,
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.parent.WriteTimeout(encrypted, timeout) // nolint: wrapcheck
|
return w.parent.WriteTimeout(encrypted, timeout) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperBlockCipher) encrypt(p []byte) ([]byte, error) {
|
func (w *wrapperBlockCipher) encrypt(p []byte) ([]byte, error) {
|
||||||
@@ -50,7 +50,7 @@ func (w *wrapperBlockCipher) encrypt(p []byte) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperBlockCipher) Close() error {
|
func (w *wrapperBlockCipher) Close() error {
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperBlockCipher) Conn() net.Conn {
|
func (w *wrapperBlockCipher) Conn() net.Conn {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func (b *bufferedReader) ReadTimeout(p []byte, _ time.Duration) (int, error) {
|
|||||||
|
|
||||||
func (b *bufferedReader) flush(p []byte) (int, error) {
|
func (b *bufferedReader) flush(p []byte) (int, error) {
|
||||||
if b.buf.Len() > len(p) {
|
if b.buf.Len() > len(p) {
|
||||||
return b.buf.Read(p) // nolint: wrapcheck
|
return b.buf.Read(p) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
sizeToReturn := b.buf.Len()
|
sizeToReturn := b.buf.Len()
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (w *wrapperConn) Write(p []byte) (int, error) {
|
|||||||
w.Close()
|
w.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return n, err // nolint: wrapcheck
|
return n, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperConn) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperConn) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
@@ -64,13 +64,13 @@ func (w *wrapperConn) Read(p []byte) (int, error) {
|
|||||||
w.Close()
|
w.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return n, err // nolint: wrapcheck
|
return n, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperConn) Close() error {
|
func (w *wrapperConn) Close() error {
|
||||||
w.logger.Debugw("Close connection")
|
w.logger.Debugw("Close connection")
|
||||||
|
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperConn) Conn() net.Conn {
|
func (w *wrapperConn) Conn() net.Conn {
|
||||||
@@ -93,9 +93,9 @@ func newConn(parent net.Conn,
|
|||||||
connID conntypes.ConnID,
|
connID conntypes.ConnID,
|
||||||
purpose connPurpose,
|
purpose connPurpose,
|
||||||
) conntypes.StreamReadWriteCloser {
|
) conntypes.StreamReadWriteCloser {
|
||||||
localAddr := *parent.LocalAddr().(*net.TCPAddr) // nolint: forcetypeassert
|
localAddr := *parent.LocalAddr().(*net.TCPAddr) //nolint: forcetypeassert
|
||||||
|
|
||||||
if parent.RemoteAddr().(*net.TCPAddr).IP.To4() != nil { // nolint: forcetypeassert
|
if parent.RemoteAddr().(*net.TCPAddr).IP.To4() != nil { //nolint: forcetypeassert
|
||||||
if config.C.PublicIPv4.IP != nil {
|
if config.C.PublicIPv4.IP != nil {
|
||||||
localAddr.IP = config.C.PublicIPv4.IP
|
localAddr.IP = config.C.PublicIPv4.IP
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ func newConn(parent net.Conn,
|
|||||||
parent: parent,
|
parent: parent,
|
||||||
connID: connID,
|
connID: connID,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
remoteAddr: parent.RemoteAddr().(*net.TCPAddr), // nolint: forcetypeassert
|
remoteAddr: parent.RemoteAddr().(*net.TCPAddr), //nolint: forcetypeassert
|
||||||
localAddr: &localAddr,
|
localAddr: &localAddr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func (w *wrapperCtx) WriteTimeout(p []byte, timeout time.Duration) (int, error)
|
|||||||
|
|
||||||
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
||||||
default:
|
default:
|
||||||
return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
|
return w.parent.WriteTimeout(p, timeout) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ func (w *wrapperCtx) Write(p []byte) (int, error) {
|
|||||||
|
|
||||||
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
||||||
default:
|
default:
|
||||||
return w.parent.Write(p) // nolint: wrapcheck
|
return w.parent.Write(p) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ func (w *wrapperCtx) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
|||||||
|
|
||||||
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
||||||
default:
|
default:
|
||||||
return w.parent.ReadTimeout(p, timeout) // nolint: wrapcheck
|
return w.parent.ReadTimeout(p, timeout) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +56,14 @@ func (w *wrapperCtx) Read(p []byte) (int, error) {
|
|||||||
|
|
||||||
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
||||||
default:
|
default:
|
||||||
return w.parent.Read(p) // nolint: wrapcheck
|
return w.parent.Read(p) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperCtx) Close() error {
|
func (w *wrapperCtx) Close() error {
|
||||||
w.cancel()
|
w.cancel()
|
||||||
|
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperCtx) Conn() net.Conn {
|
func (w *wrapperCtx) Conn() net.Conn {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type wrapperFakeTLS struct {
|
|||||||
|
|
||||||
func (w *wrapperFakeTLS) Write(p []byte) (int, error) {
|
func (w *wrapperFakeTLS) Write(p []byte) (int, error) {
|
||||||
return w.write(p, func(b []byte) (int, error) {
|
return w.write(p, func(b []byte) (int, error) {
|
||||||
return w.parent.Write(b) // nolint: wrapcheck
|
return w.parent.Write(b) //nolint: wrapcheck
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ func (w *wrapperFakeTLS) WriteTimeout(p []byte, timeout time.Duration) (int, err
|
|||||||
return w.write(p, func(b []byte) (int, error) {
|
return w.write(p, func(b []byte) (int, error) {
|
||||||
elapsed := time.Since(startTime)
|
elapsed := time.Since(startTime)
|
||||||
if elapsed > timeout {
|
if elapsed > timeout {
|
||||||
return w.parent.WriteTimeout(b, timeout-elapsed) // nolint: wrapcheck
|
return w.parent.WriteTimeout(b, timeout-elapsed) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0, errors.New("timeout")
|
return 0, errors.New("timeout")
|
||||||
@@ -73,7 +73,7 @@ func (w *wrapperFakeTLS) RemoteAddr() *net.TCPAddr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperFakeTLS) Close() error {
|
func (w *wrapperFakeTLS) Close() error {
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFakeTLS(socket conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
func NewFakeTLS(socket conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
||||||
@@ -85,7 +85,7 @@ func NewFakeTLS(socket conntypes.StreamReadWriteCloser) conntypes.StreamReadWrit
|
|||||||
for {
|
for {
|
||||||
rec, err := tlstypes.ReadRecord(faketls.parent)
|
rec, err := tlstypes.ReadRecord(faketls.parent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err // nolint: wrapcheck
|
return nil, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
switch rec.Type {
|
switch rec.Type {
|
||||||
|
|||||||
@@ -100,11 +100,11 @@ func mtprotoDeriveKeys(purpose mtprotoCipherPurpose,
|
|||||||
message.Write(req.Nonce)
|
message.Write(req.Nonce)
|
||||||
|
|
||||||
data := message.Bytes()
|
data := message.Bytes()
|
||||||
md5sum := md5.Sum(data[1:]) // nolint: gas
|
md5sum := md5.Sum(data[1:]) //nolint: gas
|
||||||
sha1sum := sha1.Sum(data) // nolint: gosec
|
sha1sum := sha1.Sum(data) //nolint: gosec
|
||||||
|
|
||||||
key := append(md5sum[:12], sha1sum[:]...)
|
key := append(md5sum[:12], sha1sum[:]...)
|
||||||
iv := md5.Sum(data[2:]) // nolint: gas
|
iv := md5.Sum(data[2:]) //nolint: gas
|
||||||
|
|
||||||
return key, iv[:]
|
return key, iv[:]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func (w *wrapperObfuscated2) ReadTimeout(p []byte, timeout time.Duration) (int,
|
|||||||
func (w *wrapperObfuscated2) Read(p []byte) (int, error) {
|
func (w *wrapperObfuscated2) Read(p []byte) (int, error) {
|
||||||
n, err := w.parent.Read(p)
|
n, err := w.parent.Read(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return n, err // nolint: wrapcheck
|
return n, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
w.decryptor.XORKeyStream(p, p[:n])
|
w.decryptor.XORKeyStream(p, p[:n])
|
||||||
@@ -48,7 +48,7 @@ func (w *wrapperObfuscated2) WriteTimeout(p []byte, timeout time.Duration) (int,
|
|||||||
|
|
||||||
w.encryptor.XORKeyStream(buf, buf)
|
w.encryptor.XORKeyStream(buf, buf)
|
||||||
|
|
||||||
return w.parent.WriteTimeout(buf, timeout) // nolint: wrapcheck
|
return w.parent.WriteTimeout(buf, timeout) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperObfuscated2) Write(p []byte) (int, error) {
|
func (w *wrapperObfuscated2) Write(p []byte) (int, error) {
|
||||||
@@ -60,7 +60,7 @@ func (w *wrapperObfuscated2) Write(p []byte) (int, error) {
|
|||||||
|
|
||||||
w.encryptor.XORKeyStream(buf, buf)
|
w.encryptor.XORKeyStream(buf, buf)
|
||||||
|
|
||||||
return w.parent.Write(buf) // nolint: wrapcheck
|
return w.parent.Write(buf) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperObfuscated2) Conn() net.Conn {
|
func (w *wrapperObfuscated2) Conn() net.Conn {
|
||||||
@@ -80,7 +80,7 @@ func (w *wrapperObfuscated2) RemoteAddr() *net.TCPAddr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperObfuscated2) Close() error {
|
func (w *wrapperObfuscated2) Close() error {
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewObfuscated2(socket conntypes.StreamReadWriteCloser,
|
func NewObfuscated2(socket conntypes.StreamReadWriteCloser,
|
||||||
|
|||||||
@@ -24,25 +24,25 @@ type wrapperRewind struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) Write(p []byte) (int, error) {
|
func (w *wrapperRewind) Write(p []byte) (int, error) {
|
||||||
return w.parent.Write(p) // nolint: wrapcheck
|
return w.parent.Write(p) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperRewind) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
|
return w.parent.WriteTimeout(p, timeout) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) Read(p []byte) (int, error) {
|
func (w *wrapperRewind) Read(p []byte) (int, error) {
|
||||||
w.mutex.Lock()
|
w.mutex.Lock()
|
||||||
defer w.mutex.Unlock()
|
defer w.mutex.Unlock()
|
||||||
|
|
||||||
return w.activeReader.Read(p) // nolint: wrapcheck
|
return w.activeReader.Read(p) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) ReadTimeout(p []byte, _ time.Duration) (int, error) {
|
func (w *wrapperRewind) ReadTimeout(p []byte, _ time.Duration) (int, error) {
|
||||||
w.mutex.Lock()
|
w.mutex.Lock()
|
||||||
defer w.mutex.Unlock()
|
defer w.mutex.Unlock()
|
||||||
|
|
||||||
return w.activeReader.Read(p) // nolint: wrapcheck
|
return w.activeReader.Read(p) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) Conn() net.Conn {
|
func (w *wrapperRewind) Conn() net.Conn {
|
||||||
@@ -64,7 +64,7 @@ func (w *wrapperRewind) RemoteAddr() *net.TCPAddr {
|
|||||||
func (w *wrapperRewind) Close() error {
|
func (w *wrapperRewind) Close() error {
|
||||||
w.buf.Reset()
|
w.buf.Reset()
|
||||||
|
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) Rewind() {
|
func (w *wrapperRewind) Rewind() {
|
||||||
|
|||||||
@@ -17,19 +17,19 @@ type wrapperTelegramStats struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTelegramStats) Write(p []byte) (int, error) {
|
func (w *wrapperTelegramStats) Write(p []byte) (int, error) {
|
||||||
return w.parent.Write(p) // nolint: wrapcheck
|
return w.parent.Write(p) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTelegramStats) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperTelegramStats) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
|
return w.parent.WriteTimeout(p, timeout) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTelegramStats) Read(p []byte) (int, error) {
|
func (w *wrapperTelegramStats) Read(p []byte) (int, error) {
|
||||||
return w.parent.Read(p) // nolint: wrapcheck
|
return w.parent.Read(p) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTelegramStats) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperTelegramStats) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
return w.parent.ReadTimeout(p, timeout) // nolint: wrapcheck
|
return w.parent.ReadTimeout(p, timeout) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTelegramStats) Conn() net.Conn {
|
func (w *wrapperTelegramStats) Conn() net.Conn {
|
||||||
@@ -56,7 +56,7 @@ func (w *wrapperTelegramStats) Close() error {
|
|||||||
stats.Stats.TelegramDisconnected(w.dc, w.RemoteAddr())
|
stats.Stats.TelegramDisconnected(w.dc, w.RemoteAddr())
|
||||||
})
|
})
|
||||||
|
|
||||||
return err // nolint: wrapcheck
|
return err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTelegramStats(dc conntypes.DC, parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
func NewTelegramStats(dc conntypes.DC, parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
||||||
|
|||||||
@@ -17,28 +17,28 @@ func (w *wrapperTrafficStats) Write(p []byte) (int, error) {
|
|||||||
n, err := w.parent.Write(p)
|
n, err := w.parent.Write(p)
|
||||||
stats.Stats.EgressTraffic(n)
|
stats.Stats.EgressTraffic(n)
|
||||||
|
|
||||||
return n, err // nolint: wrapcheck
|
return n, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTrafficStats) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperTrafficStats) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
n, err := w.parent.WriteTimeout(p, timeout)
|
n, err := w.parent.WriteTimeout(p, timeout)
|
||||||
stats.Stats.EgressTraffic(n)
|
stats.Stats.EgressTraffic(n)
|
||||||
|
|
||||||
return n, err // nolint: wrapcheck
|
return n, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTrafficStats) Read(p []byte) (int, error) {
|
func (w *wrapperTrafficStats) Read(p []byte) (int, error) {
|
||||||
n, err := w.parent.Read(p)
|
n, err := w.parent.Read(p)
|
||||||
stats.Stats.IngressTraffic(n)
|
stats.Stats.IngressTraffic(n)
|
||||||
|
|
||||||
return n, err // nolint: wrapcheck
|
return n, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTrafficStats) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperTrafficStats) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
n, err := w.parent.ReadTimeout(p, timeout)
|
n, err := w.parent.ReadTimeout(p, timeout)
|
||||||
stats.Stats.IngressTraffic(n)
|
stats.Stats.IngressTraffic(n)
|
||||||
|
|
||||||
return n, err // nolint: wrapcheck
|
return n, err //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTrafficStats) Conn() net.Conn {
|
func (w *wrapperTrafficStats) Conn() net.Conn {
|
||||||
@@ -58,7 +58,7 @@ func (w *wrapperTrafficStats) RemoteAddr() *net.TCPAddr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTrafficStats) Close() error {
|
func (w *wrapperTrafficStats) Close() error {
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTrafficStats(parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
func NewTrafficStats(parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
||||||
|
|||||||
@@ -18,23 +18,23 @@ type wrapperTimeout struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperTimeout) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
|
return w.parent.WriteTimeout(p, timeout) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) Write(p []byte) (int, error) {
|
func (w *wrapperTimeout) Write(p []byte) (int, error) {
|
||||||
return w.parent.WriteTimeout(p, timeoutWrite) // nolint: wrapcheck
|
return w.parent.WriteTimeout(p, timeoutWrite) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperTimeout) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
return w.parent.ReadTimeout(p, timeout) // nolint: wrapcheck
|
return w.parent.ReadTimeout(p, timeout) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) Read(p []byte) (int, error) {
|
func (w *wrapperTimeout) Read(p []byte) (int, error) {
|
||||||
return w.parent.ReadTimeout(p, timeoutRead) // nolint: wrapcheck
|
return w.parent.ReadTimeout(p, timeoutRead) //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) Close() error {
|
func (w *wrapperTimeout) Close() error {
|
||||||
return w.parent.Close() // nolint: wrapcheck
|
return w.parent.Close() //nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) Conn() net.Conn {
|
func (w *wrapperTimeout) Conn() net.Conn {
|
||||||
|
|||||||
Reference in New Issue
Block a user