Browse Source

Run gofumpt

tags/v1.0.11
9seconds 4 years ago
parent
commit
8da55410de

+ 9
- 1
Makefile View File

73
 doc:
73
 doc:
74
 	@$(GOTOOL) godoc -http 0.0.0.0:10000
74
 	@$(GOTOOL) godoc -http 0.0.0.0:10000
75
 
75
 
76
+.PHONY: fmt
77
+fmt:
78
+	@$(GOTOOL) gofumpt -w -extra "$(ROOT_DIR)"
79
+
76
 .PHONY: install-tools
80
 .PHONY: install-tools
77
-install-tools: install-tools-lint install-tools-godoc
81
+install-tools: install-tools-lint install-tools-godoc install-tools-gofumpt
78
 
82
 
79
 .PHONY: install-tools-lint
83
 .PHONY: install-tools-lint
80
 install-tools-lint:
84
 install-tools-lint:
87
 	@mkdir -p "$(GOBIN)" || true && \
91
 	@mkdir -p "$(GOBIN)" || true && \
88
 		$(GOTOOL) go get -u golang.org/x/tools/cmd/godoc
92
 		$(GOTOOL) go get -u golang.org/x/tools/cmd/godoc
89
 
93
 
94
+.PHONY: install-tools-gofumpt
95
+install-tools-gofumpt: .bin
96
+	@$(GOTOOL) go install mvdan.cc/gofumpt@latest
97
+
90
 .PHONY: update-deps
98
 .PHONY: update-deps
91
 upgrade-deps:
99
 upgrade-deps:
92
 	$go get -u && go mod tidy
100
 	$go get -u && go mod tidy

+ 2
- 1
proxy/middle.go View File

44
 func middlePipe(dst conntypes.PacketAckWriteCloser,
44
 func middlePipe(dst conntypes.PacketAckWriteCloser,
45
 	src conntypes.PacketAckReadCloser,
45
 	src conntypes.PacketAckReadCloser,
46
 	wg *sync.WaitGroup,
46
 	wg *sync.WaitGroup,
47
-	logger *zap.SugaredLogger) {
47
+	logger *zap.SugaredLogger,
48
+) {
48
 	defer func() {
49
 	defer func() {
49
 		dst.Close()
50
 		dst.Close()
50
 		src.Close()
51
 		src.Close()

+ 2
- 1
stats/stats_prometheus.go View File

39
 
39
 
40
 func (s *statsPrometheus) changeConnections(connectionType conntypes.ConnectionType,
40
 func (s *statsPrometheus) changeConnections(connectionType conntypes.ConnectionType,
41
 	addr *net.TCPAddr,
41
 	addr *net.TCPAddr,
42
-	increment float64) {
42
+	increment float64,
43
+) {
43
 	labels := [...]string{
44
 	labels := [...]string{
44
 		"intermediate",
45
 		"intermediate",
45
 		"ipv4",
46
 		"ipv4",

+ 4
- 2
telegram/base.go View File

28
 }
28
 }
29
 
29
 
30
 func (b *baseTelegram) dial(dc conntypes.DC,
30
 func (b *baseTelegram) dial(dc conntypes.DC,
31
-	protocol conntypes.ConnectionProtocol) (conntypes.StreamReadWriteCloser, error) {
31
+	protocol conntypes.ConnectionProtocol,
32
+) (conntypes.StreamReadWriteCloser, error) {
32
 	for _, addr := range b.getAddresses(dc, protocol) {
33
 	for _, addr := range b.getAddresses(dc, protocol) {
33
 		conn, err := b.dialer.Dial("tcp", addr)
34
 		conn, err := b.dialer.Dial("tcp", addr)
34
 		if err != nil {
35
 		if err != nil {
74
 }
75
 }
75
 
76
 
76
 func (b *baseTelegram) chooseAddress(addresses map[conntypes.DC][]string,
77
 func (b *baseTelegram) chooseAddress(addresses map[conntypes.DC][]string,
77
-	dc, defaultDC conntypes.DC) string {
78
+	dc, defaultDC conntypes.DC,
79
+) string {
78
 	addrs, ok := addresses[dc]
80
 	addrs, ok := addresses[dc]
79
 	if !ok {
81
 	if !ok {
80
 		addrs = addresses[defaultDC]
82
 		addrs = addresses[defaultDC]

+ 2
- 1
telegram/direct.go View File

29
 }
29
 }
30
 
30
 
31
 func (d *directTelegram) Dial(dc conntypes.DC,
31
 func (d *directTelegram) Dial(dc conntypes.DC,
32
-	protocol conntypes.ConnectionProtocol) (conntypes.StreamReadWriteCloser, error) {
32
+	protocol conntypes.ConnectionProtocol,
33
+) (conntypes.StreamReadWriteCloser, error) {
33
 	switch {
34
 	switch {
34
 	case dc < 0:
35
 	case dc < 0:
35
 		dc = -dc
36
 		dc = -dc

+ 2
- 1
telegram/middle.go View File

63
 }
63
 }
64
 
64
 
65
 func (m *middleTelegram) Dial(dc conntypes.DC,
65
 func (m *middleTelegram) Dial(dc conntypes.DC,
66
-	protocol conntypes.ConnectionProtocol) (conntypes.StreamReadWriteCloser, error) {
66
+	protocol conntypes.ConnectionProtocol,
67
+) (conntypes.StreamReadWriteCloser, error) {
67
 	if dc == 0 {
68
 	if dc == 0 {
68
 		dc = conntypes.DCDefaultIdx
69
 		dc = conntypes.DCDefaultIdx
69
 	}
70
 	}

+ 1
- 1
utils/init_tcp.go View File

5
 	"net"
5
 	"net"
6
 )
6
 )
7
 
7
 
8
-func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
8
+func InitTCP(conn net.Conn, readBufferSize, writeBufferSize int) error {
9
 	tcpConn := conn.(*net.TCPConn) // nolint: forcetypeassert
9
 	tcpConn := conn.(*net.TCPConn) // nolint: forcetypeassert
10
 
10
 
11
 	if err := tcpConn.SetNoDelay(true); err != nil {
11
 	if err := tcpConn.SetNoDelay(true); err != nil {

+ 2
- 1
wrappers/stream/blockcipher.go View File

70
 }
70
 }
71
 
71
 
72
 func newBlockCipher(parent conntypes.StreamReadWriteCloser,
72
 func newBlockCipher(parent conntypes.StreamReadWriteCloser,
73
-	encryptor, decryptor cipher.BlockMode) conntypes.StreamReadWriteCloser {
73
+	encryptor, decryptor cipher.BlockMode,
74
+) conntypes.StreamReadWriteCloser {
74
 	cipher := &wrapperBlockCipher{
75
 	cipher := &wrapperBlockCipher{
75
 		parent:    parent,
76
 		parent:    parent,
76
 		encryptor: encryptor,
77
 		encryptor: encryptor,

+ 2
- 1
wrappers/stream/conn.go View File

91
 
91
 
92
 func newConn(parent net.Conn,
92
 func newConn(parent net.Conn,
93
 	connID conntypes.ConnID,
93
 	connID conntypes.ConnID,
94
-	purpose connPurpose) conntypes.StreamReadWriteCloser {
94
+	purpose connPurpose,
95
+) conntypes.StreamReadWriteCloser {
95
 	localAddr := *parent.LocalAddr().(*net.TCPAddr)
96
 	localAddr := *parent.LocalAddr().(*net.TCPAddr)
96
 
97
 
97
 	if parent.RemoteAddr().(*net.TCPAddr).IP.To4() != nil {
98
 	if parent.RemoteAddr().(*net.TCPAddr).IP.To4() != nil {

+ 2
- 1
wrappers/stream/ctx.go View File

84
 
84
 
85
 func NewCtx(ctx context.Context,
85
 func NewCtx(ctx context.Context,
86
 	cancel context.CancelFunc,
86
 	cancel context.CancelFunc,
87
-	parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
87
+	parent conntypes.StreamReadWriteCloser,
88
+) conntypes.StreamReadWriteCloser {
88
 	return &wrapperCtx{
89
 	return &wrapperCtx{
89
 		parent: parent,
90
 		parent: parent,
90
 		ctx:    ctx,
91
 		ctx:    ctx,

+ 4
- 2
wrappers/stream/mtproto_cipher.go View File

26
 func NewMiddleProxyCipher(parent conntypes.StreamReadWriteCloser,
26
 func NewMiddleProxyCipher(parent conntypes.StreamReadWriteCloser,
27
 	req *rpc.NonceRequest,
27
 	req *rpc.NonceRequest,
28
 	resp *rpc.NonceResponse,
28
 	resp *rpc.NonceResponse,
29
-	secret []byte) conntypes.StreamReadWriteCloser {
29
+	secret []byte,
30
+) conntypes.StreamReadWriteCloser {
30
 	localAddr := parent.LocalAddr()
31
 	localAddr := parent.LocalAddr()
31
 	remoteAddr := parent.RemoteAddr()
32
 	remoteAddr := parent.RemoteAddr()
32
 
33
 
53
 	req *rpc.NonceRequest,
54
 	req *rpc.NonceRequest,
54
 	resp *rpc.NonceResponse,
55
 	resp *rpc.NonceResponse,
55
 	client, remote *net.TCPAddr,
56
 	client, remote *net.TCPAddr,
56
-	secret []byte) ([]byte, []byte) {
57
+	secret []byte,
58
+) ([]byte, []byte) {
57
 	message := bytes.Buffer{}
59
 	message := bytes.Buffer{}
58
 
60
 
59
 	message.Write(resp.Nonce)
61
 	message.Write(resp.Nonce)

+ 2
- 1
wrappers/stream/obfuscated2.go View File

84
 }
84
 }
85
 
85
 
86
 func NewObfuscated2(socket conntypes.StreamReadWriteCloser,
86
 func NewObfuscated2(socket conntypes.StreamReadWriteCloser,
87
-	encryptor, decryptor cipher.Stream) conntypes.StreamReadWriteCloser {
87
+	encryptor, decryptor cipher.Stream,
88
+) conntypes.StreamReadWriteCloser {
88
 	return &wrapperObfuscated2{
89
 	return &wrapperObfuscated2{
89
 		parent:    socket,
90
 		parent:    socket,
90
 		encryptor: encryptor,
91
 		encryptor: encryptor,

Loading…
Cancel
Save