simplify connForward
This commit is contained in:
10
main.go
10
main.go
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net"
|
||||
@@ -266,18 +267,11 @@ 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)
|
||||
_, err := io.CopyBuffer(to, from, buf)
|
||||
if err != nil {
|
||||
to.Close()
|
||||
return
|
||||
}
|
||||
_, err = to.Write(buf[:size])
|
||||
if err != nil {
|
||||
to.Close()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func tcpClientForward(tnet *netstack.Net, target string, conn net.Conn) {
|
||||
|
||||
Reference in New Issue
Block a user