ing
This commit is contained in:
parent
e1d8c92a55
commit
e067b2c21c
|
@ -2,6 +2,7 @@ package health
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
@ -70,47 +71,52 @@ func (s *SocketHeahthCrawler) CheckHeahth(config *configM.Config) (result map[st
|
|||
port, _ := cuej.NumberToInt(connection.Port)
|
||||
info := cnsm.NewMatchInfo(connection.IP, port)
|
||||
|
||||
if s.m.IsPrePacket() == true {
|
||||
bytes := make([]byte, 1024)
|
||||
n, _ := conn.Read(bytes)
|
||||
p := cnsm.NewPacket(bytes, n)
|
||||
if s.m.Match(info, 0, p) == false {
|
||||
if s.m.IsPrePacket() {
|
||||
result["PacketType"] = "Pre"
|
||||
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := conn.Read(buf)
|
||||
p := cnsm.NewPacket(buf, n)
|
||||
if !s.m.Match(info, 0, p) {
|
||||
result["Packet"] = convertBase64(buf)
|
||||
result["Error"] = "Not Matched"
|
||||
return
|
||||
} else {
|
||||
|
||||
for i := 0; i < s.m.PacketCount(); i++ {
|
||||
pack := s.m.Packet(i)
|
||||
conn.Write(pack.Buffer)
|
||||
bytes := make([]byte, 1024)
|
||||
n, _ := conn.Read(bytes)
|
||||
|
||||
if !s.m.HasResponse(i + 1) { // empty last response
|
||||
break
|
||||
}
|
||||
|
||||
p := cnsm.NewPacket(bytes, n)
|
||||
if s.m.Match(info, i+1, p) == false {
|
||||
result["Error"] = "Not Matched"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
for i := 0; i < s.m.PacketCount(); i++ {
|
||||
pack := s.m.Packet(i)
|
||||
conn.Write(pack.Buffer)
|
||||
bytes := make([]byte, 1024)
|
||||
n, _ := conn.Read(bytes)
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := conn.Read(buf)
|
||||
|
||||
if !s.m.HasResponse(i + 1) { // empty last response
|
||||
break
|
||||
}
|
||||
|
||||
p := cnsm.NewPacket(buf, n)
|
||||
if s.m.Match(info, i+1, p) == false {
|
||||
result["Packet"] = convertBase64(buf)
|
||||
result["Error"] = "Not Matched"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
result["PacketType"] = "Post"
|
||||
|
||||
for i := 0; i < s.m.PacketCount(); i++ {
|
||||
pack := s.m.Packet(i)
|
||||
conn.Write(pack.Buffer)
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := conn.Read(buf)
|
||||
|
||||
if !s.m.HasResponse(i) { // empty last response
|
||||
break
|
||||
}
|
||||
|
||||
p := cnsm.NewPacket(bytes, n)
|
||||
p := cnsm.NewPacket(buf, n)
|
||||
if s.m.Match(info, i, p) == false {
|
||||
result["Packet"] = convertBase64(buf)
|
||||
result["Error"] = "Not Matched"
|
||||
return
|
||||
}
|
||||
|
@ -121,3 +127,7 @@ func (s *SocketHeahthCrawler) CheckHeahth(config *configM.Config) (result map[st
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
func convertBase64(buf []byte) string {
|
||||
return base64.StdEncoding.EncodeToString(buf)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user