matchCtx added

This commit is contained in:
crusader
2018-09-03 22:36:57 +09:00
parent 3e7b2fda79
commit c15fd7d46e
49 changed files with 505 additions and 542 deletions

View File

@@ -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()

View File

@@ -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)
}