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