simplify connForward

This commit is contained in:
octeep 2022-03-28 18:58:13 +01:00
parent ca9e5ddb44
commit b77da8ec20

16
main.go
View file

@ -7,6 +7,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"io"
"log"
"math/rand"
"net"
@ -266,17 +267,10 @@ func (c CredentialValidator) Valid(username, password string) bool {
func connForward(bufSize int, from, to net.Conn) {
buf := make([]byte, bufSize)
for {
size, err := from.Read(buf)
if err != nil {
to.Close()
return
}
_, err = to.Write(buf[:size])
if err != nil {
to.Close()
return
}
_, err := io.CopyBuffer(to, from, buf)
if err != nil {
to.Close()
return
}
}