2017-12-04 07:27:08 +00:00
|
|
|
package rmi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"net"
|
|
|
|
"testing"
|
2017-12-04 08:16:03 +00:00
|
|
|
|
|
|
|
cnsm "git.loafle.net/commons_go/network_service_matcher"
|
2017-12-04 07:27:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNew(t *testing.T) {
|
|
|
|
r := NewMatcher()
|
|
|
|
fmt.Println("TestNew: ", r)
|
|
|
|
}
|
|
|
|
func TestRMIMatcher_Match(t *testing.T) {
|
|
|
|
|
|
|
|
fmt.Println("Match")
|
|
|
|
|
|
|
|
hm := NewMatcher()
|
|
|
|
|
|
|
|
//port := types.NewPort("9840", types.NewHost("192.168.1.101"), types.TYPE_TCP)
|
|
|
|
//
|
|
|
|
//var ipport string
|
|
|
|
//ipport = port.Host.Ip + ":" + string(port.Port)
|
|
|
|
|
|
|
|
//fmt.Println(ipport)
|
|
|
|
|
|
|
|
client, err := net.Dial("tcp", "192.168.1.101:9840")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
defer client.Close()
|
|
|
|
|
|
|
|
pack := hm.Packet(0)
|
|
|
|
|
|
|
|
fmt.Println(pack.Buffer)
|
|
|
|
|
|
|
|
//writer.WriteString(pack)
|
|
|
|
client.Write(pack.Buffer)
|
|
|
|
|
|
|
|
bytes := make([]byte, 512)
|
|
|
|
|
|
|
|
l, _ := client.Read(bytes)
|
|
|
|
|
|
|
|
//fmt.Println(bytes)
|
|
|
|
|
|
|
|
t1 := hm.Match(nil, 0, cnsm.NewPacket(bytes, l))
|
|
|
|
|
|
|
|
fmt.Println(t1)
|
|
|
|
}
|