overflow_discovery/service/match/http/https_test.go

56 lines
843 B
Go
Raw Normal View History

2017-11-21 12:47:55 +00:00
package http
import (
"crypto/tls"
"fmt"
2017-11-21 12:52:45 +00:00
"git.loafle.net/overflow/overflow_discovery/service/matcher"
2017-11-21 12:47:55 +00:00
"log"
"net"
"testing"
"time"
)
func TestHTTPSMatcher_Match(t *testing.T) {
netinfo := "192.168.1.10:10443"
dialer := &net.Dialer{
Timeout: 5 * time.Second,
}
conn, err := tls.DialWithDialer(
dialer,
"tcp",
netinfo,
&tls.Config{
InsecureSkipVerify: true,
ServerName: "192.168.1.103",
},
)
if err != nil {
log.Println(err)
return
}
defer conn.Close()
//fmt.Println(conn)
h := NewHTTPMatcher()
pac := h.Packet(0)
//fmt.Println(pac)
//fmt.Println(pac.Buffer)
//bytes := make([]byte, 1024)
l, _ := conn.Write(pac.Buffer)
buf := make([]byte, 1024)
l, _ = conn.Read(buf)
fmt.Println(string(buf))
fmt.Println(l)
2017-11-21 12:52:45 +00:00
is := h.Match(0, matcher.NewPacket(buf, l), nil)
2017-11-21 12:47:55 +00:00
fmt.Println(is)
}