-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
48 lines (42 loc) · 911 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package quicfuzz
import (
"github.com/goburrow/quic/transport"
)
var clientConfig = newClientConfig()
// FuzzClientInitial runs fuzzing client handling initial packet.
func FuzzClientInitial(b []byte) int {
conn := newClient(cid)
_, err := conn.Read(buf)
if err != nil {
panic(err)
}
n, err := conn.Write(b)
if err != nil || n == 0 {
return 0
}
conn.Read(buf)
return 1
}
// FuzzClient runs fuzzing connected client connection.
func FuzzClient(b []byte) int {
conn, peer := newEndpoint()
_, err1 := conn.Write(b)
_, err2 := conn.Write(peer.BuildPacket(b))
conn.Read(buf)
if err1 != nil || err2 != nil {
return 0
}
return 1
}
func newClient(scid []byte) *transport.Conn {
conn, err := transport.Connect(scid, scid, clientConfig)
if err != nil {
panic(err)
}
return conn
}
func newClientConfig() *transport.Config {
c := newConfig()
c.TLS.InsecureSkipVerify = true
return c
}