mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 01:24:02 +03:00
Decrease relay buffer size
Even if it makes sense to have a huge buffers, we do artificial delays now. In that case we could achieve the same results with a lower buffer. If not, then we won't send a packet bigger that this value
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
package relay
|
||||
|
||||
const (
|
||||
copyBufferSize = 64 * 1024
|
||||
)
|
||||
|
||||
type Logger interface {
|
||||
Printf(msg string, args ...any)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
|
||||
"github.com/9seconds/mtg/v2/essentials"
|
||||
"github.com/9seconds/mtg/v2/mtglib/internal/tls"
|
||||
)
|
||||
|
||||
func Relay(ctx context.Context, log Logger, telegramConn, clientConn essentials.Conn) {
|
||||
@@ -35,7 +36,7 @@ func Relay(ctx context.Context, log Logger, telegramConn, clientConn essentials.
|
||||
}
|
||||
|
||||
func pump(log Logger, src, dst essentials.Conn, direction string) {
|
||||
var buf [copyBufferSize]byte
|
||||
var buf [tls.MaxRecordPayloadSize]byte
|
||||
|
||||
defer src.CloseRead() //nolint: errcheck
|
||||
defer dst.CloseWrite() //nolint: errcheck
|
||||
|
||||
Reference in New Issue
Block a user