matchCtx added
This commit is contained in:
16
smb/smb.go
16
smb/smb.go
@@ -52,31 +52,27 @@ type SMBMatcher struct {
|
||||
osm.Matchers
|
||||
}
|
||||
|
||||
func (t *SMBMatcher) Key() string {
|
||||
func (m *SMBMatcher) Key() string {
|
||||
return "SMB"
|
||||
}
|
||||
|
||||
func (t *SMBMatcher) Name() string {
|
||||
func (m *SMBMatcher) Name(matchCtx *osm.MatchCtx) string {
|
||||
return "SMB"
|
||||
}
|
||||
|
||||
func (t *SMBMatcher) Meta() osm.Metadata {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *SMBMatcher) IsPrePacket() bool {
|
||||
func (m *SMBMatcher) IsPrePacket(matchCtx *osm.MatchCtx) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *SMBMatcher) HasResponse(index int) bool {
|
||||
func (m *SMBMatcher) HasResponse(matchCtx *osm.MatchCtx, index int) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *SMBMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
|
||||
func (m *SMBMatcher) IsError(matchCtx *osm.MatchCtx, index int, packet *osm.Packet) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *SMBMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
|
||||
func (m *SMBMatcher) Match(matchCtx *osm.MatchCtx, index int, packet *osm.Packet) error {
|
||||
|
||||
if packet == nil || !packet.Valid() {
|
||||
return osm.NoPacketReceivedError()
|
||||
|
||||
@@ -16,16 +16,17 @@ func TestSMBMatcher(t *testing.T) {
|
||||
m := NewMatcher()
|
||||
|
||||
conn, err := net.Dial("tcp", ADDR)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
|
||||
for i := 0; i < m.PacketCount(); i++ {
|
||||
matchCtx := osm.NewMatchCtx("192.168.1.101", 445)
|
||||
|
||||
pack := m.Packet(i)
|
||||
for i := 0; i < m.PacketCount(matchCtx); i++ {
|
||||
|
||||
pack := m.Packet(matchCtx, i)
|
||||
conn.Write(pack.Buffer)
|
||||
bytes := make([]byte, 1024)
|
||||
n, _ := conn.Read(bytes)
|
||||
@@ -36,6 +37,6 @@ func TestSMBMatcher(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
t.Log(m.Name())
|
||||
t.Log(m.Meta())
|
||||
t.Log(m.Name(matchCtx))
|
||||
t.Log(matchCtx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user