Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kxg2020 committed Mar 28, 2023
1 parent 4a17718 commit 1d3031a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Core/ProxyServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (i *ProxyServer) Start() error {
}
i.listener = listener
i.Logo()
i.Install()
//i.Install()
i.MultiListen()
select {}
}
Expand Down
23 changes: 10 additions & 13 deletions Core/ProxySocks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"github.com/kxg3030/shermie-proxy/Log"
"io"
"net"
"strconv"
"strings"
Expand Down Expand Up @@ -72,21 +71,17 @@ func (i *ProxySocks5) Handle() {
Log.Log.Println("socks5支持方法参数错误")
return
}
// 是否需要账号密码验证
var requiredAuth bool
method := uint8(0x00)
// 代理默认不需要账号密码验证
var requiredAuth bool = false
// 读取所有的方法列表
for n := 0; n < int(methodNum); n++ {
method, err = i.reader.ReadByte()
_, err := i.reader.ReadByte()
if err != nil {
Log.Log.Println("读取socks5支持错误:" + err.Error())
return
}
if method == UsernamePassword {
requiredAuth = true
}
}
_, err = i.writer.Write([]byte{version, method})
_, err = i.writer.Write([]byte{Version, 0x00})
if err != nil {
Log.Log.Println("返回数据错误:" + err.Error())
return
Expand Down Expand Up @@ -207,6 +202,9 @@ func (i *ProxySocks5) Handle() {
} else {
_ = i.writer.WriteByte(0x00)
}
defer func() {
i.target.Close()
}()
// 写入Rsv
_ = i.writer.WriteByte(Rsv)
remoteAddr := i.target.RemoteAddr().String()
Expand All @@ -231,7 +229,7 @@ func (i *ProxySocks5) Handle() {
Log.Log.Println("写入socks5握手错误:" + err.Error())
return
}
out := make(chan error, 2)
out := make(chan error, 1)
if command == 0x01 {
go i.Transport(out, i.conn, i.target, SocketClient)
go i.Transport(out, i.target, i.conn, SocketServer)
Expand All @@ -245,6 +243,7 @@ func (i *ProxySocks5) Transport(out chan<- error, originConn net.Conn, targetCon
resolve := ResolveSocks5(func(buff []byte) (int, error) {
return targetConn.Write(buff)
})

var writeLen int
for {
readLen, err := originConn.Read(buff)
Expand All @@ -268,9 +267,7 @@ func (i *ProxySocks5) Transport(out chan<- error, originConn net.Conn, targetCon
}
}
if err != nil {
if err != io.EOF {
out <- errors.New("读取客户端数据错误-1")
}
out <- errors.New("读取客户端数据错误-1")
break
}
buff = buff[:]
Expand Down

0 comments on commit 1d3031a

Please sign in to comment.