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