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:
9seconds
2026-03-14 14:06:48 +01:00
parent 879ebd132d
commit bb90bcc127
2 changed files with 2 additions and 5 deletions
-4
View File
@@ -1,9 +1,5 @@
package relay
const (
copyBufferSize = 64 * 1024
)
type Logger interface {
Printf(msg string, args ...any)
}
+2 -1
View File
@@ -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