mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 16:01:55 +03:00
Run gofumpt
This commit is contained in:
@@ -73,8 +73,12 @@ docker:
|
||||
doc:
|
||||
@$(GOTOOL) godoc -http 0.0.0.0:10000
|
||||
|
||||
.PHONY: fmt
|
||||
fmt:
|
||||
@$(GOTOOL) gofumpt -w -extra "$(ROOT_DIR)"
|
||||
|
||||
.PHONY: install-tools
|
||||
install-tools: install-tools-lint install-tools-godoc
|
||||
install-tools: install-tools-lint install-tools-godoc install-tools-gofumpt
|
||||
|
||||
.PHONY: install-tools-lint
|
||||
install-tools-lint:
|
||||
@@ -87,6 +91,10 @@ install-tools-godoc:
|
||||
@mkdir -p "$(GOBIN)" || true && \
|
||||
$(GOTOOL) go get -u golang.org/x/tools/cmd/godoc
|
||||
|
||||
.PHONY: install-tools-gofumpt
|
||||
install-tools-gofumpt: .bin
|
||||
@$(GOTOOL) go install mvdan.cc/gofumpt@latest
|
||||
|
||||
.PHONY: update-deps
|
||||
upgrade-deps:
|
||||
$go get -u && go mod tidy
|
||||
|
||||
+2
-1
@@ -44,7 +44,8 @@ func middleConnection(request *protocol.TelegramRequest) {
|
||||
func middlePipe(dst conntypes.PacketAckWriteCloser,
|
||||
src conntypes.PacketAckReadCloser,
|
||||
wg *sync.WaitGroup,
|
||||
logger *zap.SugaredLogger) {
|
||||
logger *zap.SugaredLogger,
|
||||
) {
|
||||
defer func() {
|
||||
dst.Close()
|
||||
src.Close()
|
||||
|
||||
@@ -39,7 +39,8 @@ func (s *statsPrometheus) ClientDisconnected(connectionType conntypes.Connection
|
||||
|
||||
func (s *statsPrometheus) changeConnections(connectionType conntypes.ConnectionType,
|
||||
addr *net.TCPAddr,
|
||||
increment float64) {
|
||||
increment float64,
|
||||
) {
|
||||
labels := [...]string{
|
||||
"intermediate",
|
||||
"ipv4",
|
||||
|
||||
+4
-2
@@ -28,7 +28,8 @@ func (b *baseTelegram) Secret() []byte {
|
||||
}
|
||||
|
||||
func (b *baseTelegram) dial(dc conntypes.DC,
|
||||
protocol conntypes.ConnectionProtocol) (conntypes.StreamReadWriteCloser, error) {
|
||||
protocol conntypes.ConnectionProtocol,
|
||||
) (conntypes.StreamReadWriteCloser, error) {
|
||||
for _, addr := range b.getAddresses(dc, protocol) {
|
||||
conn, err := b.dialer.Dial("tcp", addr)
|
||||
if err != nil {
|
||||
@@ -74,7 +75,8 @@ func (b *baseTelegram) getAddresses(dc conntypes.DC, protocol conntypes.Connecti
|
||||
}
|
||||
|
||||
func (b *baseTelegram) chooseAddress(addresses map[conntypes.DC][]string,
|
||||
dc, defaultDC conntypes.DC) string {
|
||||
dc, defaultDC conntypes.DC,
|
||||
) string {
|
||||
addrs, ok := addresses[dc]
|
||||
if !ok {
|
||||
addrs = addresses[defaultDC]
|
||||
|
||||
+2
-1
@@ -29,7 +29,8 @@ type directTelegram struct {
|
||||
}
|
||||
|
||||
func (d *directTelegram) Dial(dc conntypes.DC,
|
||||
protocol conntypes.ConnectionProtocol) (conntypes.StreamReadWriteCloser, error) {
|
||||
protocol conntypes.ConnectionProtocol,
|
||||
) (conntypes.StreamReadWriteCloser, error) {
|
||||
switch {
|
||||
case dc < 0:
|
||||
dc = -dc
|
||||
|
||||
+2
-1
@@ -63,7 +63,8 @@ func (m *middleTelegram) backgroundUpdate() {
|
||||
}
|
||||
|
||||
func (m *middleTelegram) Dial(dc conntypes.DC,
|
||||
protocol conntypes.ConnectionProtocol) (conntypes.StreamReadWriteCloser, error) {
|
||||
protocol conntypes.ConnectionProtocol,
|
||||
) (conntypes.StreamReadWriteCloser, error) {
|
||||
if dc == 0 {
|
||||
dc = conntypes.DCDefaultIdx
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
|
||||
func InitTCP(conn net.Conn, readBufferSize, writeBufferSize int) error {
|
||||
tcpConn := conn.(*net.TCPConn) // nolint: forcetypeassert
|
||||
|
||||
if err := tcpConn.SetNoDelay(true); err != nil {
|
||||
|
||||
@@ -70,7 +70,8 @@ func (w *wrapperBlockCipher) RemoteAddr() *net.TCPAddr {
|
||||
}
|
||||
|
||||
func newBlockCipher(parent conntypes.StreamReadWriteCloser,
|
||||
encryptor, decryptor cipher.BlockMode) conntypes.StreamReadWriteCloser {
|
||||
encryptor, decryptor cipher.BlockMode,
|
||||
) conntypes.StreamReadWriteCloser {
|
||||
cipher := &wrapperBlockCipher{
|
||||
parent: parent,
|
||||
encryptor: encryptor,
|
||||
|
||||
@@ -91,7 +91,8 @@ func (w *wrapperConn) RemoteAddr() *net.TCPAddr {
|
||||
|
||||
func newConn(parent net.Conn,
|
||||
connID conntypes.ConnID,
|
||||
purpose connPurpose) conntypes.StreamReadWriteCloser {
|
||||
purpose connPurpose,
|
||||
) conntypes.StreamReadWriteCloser {
|
||||
localAddr := *parent.LocalAddr().(*net.TCPAddr)
|
||||
|
||||
if parent.RemoteAddr().(*net.TCPAddr).IP.To4() != nil {
|
||||
|
||||
@@ -84,7 +84,8 @@ func (w *wrapperCtx) RemoteAddr() *net.TCPAddr {
|
||||
|
||||
func NewCtx(ctx context.Context,
|
||||
cancel context.CancelFunc,
|
||||
parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
||||
parent conntypes.StreamReadWriteCloser,
|
||||
) conntypes.StreamReadWriteCloser {
|
||||
return &wrapperCtx{
|
||||
parent: parent,
|
||||
ctx: ctx,
|
||||
|
||||
@@ -26,7 +26,8 @@ var mtprotoEmptyIP = [4]byte{0x00, 0x00, 0x00, 0x00}
|
||||
func NewMiddleProxyCipher(parent conntypes.StreamReadWriteCloser,
|
||||
req *rpc.NonceRequest,
|
||||
resp *rpc.NonceResponse,
|
||||
secret []byte) conntypes.StreamReadWriteCloser {
|
||||
secret []byte,
|
||||
) conntypes.StreamReadWriteCloser {
|
||||
localAddr := parent.LocalAddr()
|
||||
remoteAddr := parent.RemoteAddr()
|
||||
|
||||
@@ -53,7 +54,8 @@ func mtprotoDeriveKeys(purpose mtprotoCipherPurpose,
|
||||
req *rpc.NonceRequest,
|
||||
resp *rpc.NonceResponse,
|
||||
client, remote *net.TCPAddr,
|
||||
secret []byte) ([]byte, []byte) {
|
||||
secret []byte,
|
||||
) ([]byte, []byte) {
|
||||
message := bytes.Buffer{}
|
||||
|
||||
message.Write(resp.Nonce)
|
||||
|
||||
@@ -84,7 +84,8 @@ func (w *wrapperObfuscated2) Close() error {
|
||||
}
|
||||
|
||||
func NewObfuscated2(socket conntypes.StreamReadWriteCloser,
|
||||
encryptor, decryptor cipher.Stream) conntypes.StreamReadWriteCloser {
|
||||
encryptor, decryptor cipher.Stream,
|
||||
) conntypes.StreamReadWriteCloser {
|
||||
return &wrapperObfuscated2{
|
||||
parent: socket,
|
||||
encryptor: encryptor,
|
||||
|
||||
Reference in New Issue
Block a user