判断connection 是否为http协议
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"io"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -40,11 +41,24 @@ func newConnGroup(dst, src io.ReadWriteCloser, wg *sync.WaitGroup, n *int64, flo
|
||||
func CopyBuffer(dst io.Writer, src io.Reader, flow *file.Flow) (err error) {
|
||||
buf := common.CopyBuff.Get()
|
||||
defer common.CopyBuff.Put(buf)
|
||||
i := 0
|
||||
for {
|
||||
nr, er := src.Read(buf)
|
||||
//if len(pr)>0 && pr[0] && nr > 50 {
|
||||
// logs.Warn(string(buf[:50]))
|
||||
//}
|
||||
|
||||
if i == 0 {
|
||||
firstLine := string(buf[0:nr])
|
||||
if len(firstLine) > 3 {
|
||||
method := firstLine[0:3]
|
||||
if method != "" && (method == "HTT" || method == "GET" || method == "POS" || method == "HEA" || method == "PUT" || method == "DEL") {
|
||||
logs.Info("HTTP Request: " + firstLine[0:strings.Index(firstLine, "\n")])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i++
|
||||
if nr > 0 {
|
||||
nw, ew := dst.Write(buf[0:nr])
|
||||
if nw > 0 {
|
||||
|
||||
@@ -103,6 +103,8 @@ func ProcessTunnel(c *conn.Conn, s *TunnelModeServer) error {
|
||||
logs.Warn("tcp port %d ,client id %d,task id %d connect error %s", s.task.Port, s.task.Client.Id, s.task.Id, err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
logs.Info(c.RemoteAddr().String())
|
||||
//return s.DealClient(c, s.task.Client, targetAddr, nil, common.CONN_TCP, nil, s.task.Flow, s.task.Target.LocalProxy)
|
||||
return s.DealClient(c, s.task.Client, targetAddr, nil, common.CONN_TCP, nil, s.task.Client.Flow, s.task.Target.LocalProxy)
|
||||
}
|
||||
|
||||
@@ -462,7 +462,6 @@ func GetDashboardData() map[string]interface{} {
|
||||
// 实例化流量数据到文件
|
||||
func flowSession(m time.Duration) {
|
||||
ticker := time.NewTicker(m)
|
||||
logs.Info("实例化流量数据到文件.........")
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user