56 lines
839 B
Go
56 lines
839 B
Go
package http
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"fmt"
|
|
"git.loafle.net/overflow/overflow_discovery/match/packet"
|
|
"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)
|
|
is := h.Match(0, packet.NewPacket(buf, l), nil)
|
|
fmt.Println(is)
|
|
|
|
}
|