mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 16:57:08 +00:00
feat: reduce log of use of closed network connection
This commit is contained in:
parent
16eca98798
commit
5bd322f960
2
build.sh
2
build.sh
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
project_name="ua3f"
|
||||
release_version="0.1.0"
|
||||
release_version="0.1.1"
|
||||
target=cmd/ua3f.go
|
||||
|
||||
release_dir=./bin
|
||||
|
||||
21
cmd/ua3f.go
21
cmd/ua3f.go
@ -16,7 +16,7 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var version = "0.1.0"
|
||||
var version = "0.1.1"
|
||||
var payloadByte []byte
|
||||
var cache *expirable.LRU[string, string]
|
||||
|
||||
@ -137,10 +137,12 @@ func Socks5Connect(client net.Conn) (net.Conn, error) {
|
||||
}
|
||||
port := binary.BigEndian.Uint16(buf[:2])
|
||||
destAddrPort := fmt.Sprintf("%s:%d", addr, port)
|
||||
logrus.Debug(fmt.Sprintf("Connecting %s", destAddrPort))
|
||||
dest, err := net.Dial("tcp", destAddrPort)
|
||||
if err != nil {
|
||||
return nil, errors.New("dial dst:" + err.Error())
|
||||
}
|
||||
logrus.Debug(fmt.Sprintf("Connected %s", destAddrPort))
|
||||
_, err = client.Write([]byte{0x05, 0x00, 0x00, 0x01, 0, 0, 0, 0, 0, 0})
|
||||
if err != nil {
|
||||
dest.Close()
|
||||
@ -199,7 +201,7 @@ func CopyPileline(dst io.Writer, src io.Reader) {
|
||||
var m int
|
||||
m, err = src.Read(buf[nr:])
|
||||
if err != nil {
|
||||
logrus.Error("read error: ", err)
|
||||
logrus.Error("read error in http accumulation: ", err)
|
||||
break
|
||||
}
|
||||
nr += m
|
||||
@ -239,12 +241,12 @@ func CopyPileline(dst io.Writer, src io.Reader) {
|
||||
for left > 0 {
|
||||
m, err := src.Read(buf[0:left])
|
||||
if err != nil {
|
||||
logrus.Error("read error: ", err)
|
||||
logrus.Error("read error in large body: ", err)
|
||||
break
|
||||
}
|
||||
_, ew := dst.Write(buf[0:m])
|
||||
if ew != nil {
|
||||
logrus.Error("write error: ", ew)
|
||||
logrus.Error("write error in large body: ", ew)
|
||||
break
|
||||
}
|
||||
left -= m
|
||||
@ -259,11 +261,14 @@ func CopyPileline(dst io.Writer, src io.Reader) {
|
||||
|
||||
m, err := src.Read(buf[nr:])
|
||||
nr += m
|
||||
if err != nil && err != io.EOF {
|
||||
logrus.Error("read error: ", err)
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
logrus.Debug("read EOF in next phase")
|
||||
} else if strings.Contains(err.Error(), "use of closed network connection") {
|
||||
logrus.Debug("read closed in next phase: ", err)
|
||||
} else {
|
||||
logrus.Error("read error in next phase: ", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,11 +16,12 @@ getcpucore() {
|
||||
cd /root
|
||||
getcpucore
|
||||
|
||||
version=0.1.0
|
||||
version=0.1.1
|
||||
ua3f_tar=ua3f-$version-$cpucore.tar.gz
|
||||
|
||||
if [ -f "ua3f" ]; then
|
||||
rm "ua3f"
|
||||
killall ua3f >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
chmod ugo+w /var/log
|
||||
@ -53,4 +54,5 @@ mv ua3f.service /etc/init.d/ && chmod +x /etc/init.d/ua3f.service
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Install UA3F Success."
|
||||
echo "Use /etc/init.d/ua3f.service {start|stop|restart} to control UA3F."
|
||||
fi
|
||||
Loading…
Reference in New Issue
Block a user