ソースを参照

Run gofumpt

tags/v1.0.11
9seconds 4年前
コミット
8da55410de

+ 9
- 1
Makefile ファイルの表示

@@ -73,8 +73,12 @@ docker:
73 73
 doc:
74 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 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 83
 .PHONY: install-tools-lint
80 84
 install-tools-lint:
@@ -87,6 +91,10 @@ install-tools-godoc:
87 91
 	@mkdir -p "$(GOBIN)" || true && \
88 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 98
 .PHONY: update-deps
91 99
 upgrade-deps:
92 100
 	$go get -u && go mod tidy

+ 2
- 1
proxy/middle.go ファイルの表示

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

+ 2
- 1
stats/stats_prometheus.go ファイルの表示

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

+ 4
- 2
telegram/base.go ファイルの表示

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

+ 2
- 1
telegram/direct.go ファイルの表示

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

+ 2
- 1
telegram/middle.go ファイルの表示

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

+ 1
- 1
utils/init_tcp.go ファイルの表示

@@ -5,7 +5,7 @@ import (
5 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 9
 	tcpConn := conn.(*net.TCPConn) // nolint: forcetypeassert
10 10
 
11 11
 	if err := tcpConn.SetNoDelay(true); err != nil {

+ 2
- 1
wrappers/stream/blockcipher.go ファイルの表示

@@ -70,7 +70,8 @@ func (w *wrapperBlockCipher) RemoteAddr() *net.TCPAddr {
70 70
 }
71 71
 
72 72
 func newBlockCipher(parent conntypes.StreamReadWriteCloser,
73
-	encryptor, decryptor cipher.BlockMode) conntypes.StreamReadWriteCloser {
73
+	encryptor, decryptor cipher.BlockMode,
74
+) conntypes.StreamReadWriteCloser {
74 75
 	cipher := &wrapperBlockCipher{
75 76
 		parent:    parent,
76 77
 		encryptor: encryptor,

+ 2
- 1
wrappers/stream/conn.go ファイルの表示

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

+ 2
- 1
wrappers/stream/ctx.go ファイルの表示

@@ -84,7 +84,8 @@ func (w *wrapperCtx) RemoteAddr() *net.TCPAddr {
84 84
 
85 85
 func NewCtx(ctx context.Context,
86 86
 	cancel context.CancelFunc,
87
-	parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
87
+	parent conntypes.StreamReadWriteCloser,
88
+) conntypes.StreamReadWriteCloser {
88 89
 	return &wrapperCtx{
89 90
 		parent: parent,
90 91
 		ctx:    ctx,

+ 4
- 2
wrappers/stream/mtproto_cipher.go ファイルの表示

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

+ 2
- 1
wrappers/stream/obfuscated2.go ファイルの表示

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

読み込み中…
キャンセル
保存