package ldap import ( "crypto/tls" "fmt" "net" "testing" cnsm "git.loafle.net/commons_go/network_service_matcher" ) //func SetUp() { // fmt.Println("SetUp") //} // //func TearDown() { // fmt.Println("TearDown") //} //func TestMain(m *testing.M) { // SetUp() // m.Run() // TearDown() //} func TestAAAA(t *testing.T) { ///animals := []Animal{Dog{}, Cat{}, Llama{}, JavaProgrammer{}} var ttt [][]int = make([][]int, 10) var aaa []int aaa = append(aaa, 111) ttt = append(ttt, aaa) fmt.Println(cap(ttt)) } func ldapRun(client net.Conn, t *testing.T) { lm := NewMatcher() //port := types.NewPort("389", types.NewHost("192.168.1.215"), types.TYPE_TCP) //scanInfo := scaninfo.NewServiceScanInfo(port) //var ipport string //ipport = port.Host.Ip + ":" + string(port.Port) // //fmt.Println(ipport) //client, _ := net.Dial("tcp", ipport) //defer client.Close() fmt.Println(lm.PacketCount()) for ii := 0; ii < lm.PacketCount(); ii++ { pack := lm.Packet(ii) bytes := make([]byte, 1024) client.Write(pack.Buffer) read, _ := client.Read(bytes) if read <= 0 { bb := lm.HasResponse(ii) if !bb { t.Log("HasResponse good") break } } fmt.Println(bytes) b := lm.Match(nil, ii, cnsm.NewPacket(bytes, read)) if b { t.Log("Good") } } } func TestLdapTls(t *testing.T) { conn, err := tls.Dial( "tcp", "192.168.1.15:636", &tls.Config{ InsecureSkipVerify: true, ServerName: "192.168.1.15", }, ) if err != nil { t.Fatal(err) } defer conn.Close() ldapRun(conn, t) } func TestLdapNormal(t *testing.T) { client, _ := net.Dial("tcp", "192.168.1.15:389") defer client.Close() ldapRun(client, t) }