Created
November 28, 2018 22:54
-
-
Save dgryski/df3408b52b3d6a228ec57a922864f666 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build gofuzz | |
package viaproxy | |
import ( | |
"bytes" | |
"io" | |
"net" | |
) | |
// from conn_test.go | |
type conn struct { | |
net.Conn | |
data io.Reader | |
} | |
func (c *conn) Read(b []byte) (n int, err error) { return c.data.Read(b) } | |
func (c *conn) LocalAddr() net.Addr { return &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 9876} } | |
func (c *conn) RemoteAddr() net.Addr { return &net.TCPAddr{IP: net.ParseIP("10.0.1.2"), Port: 1234} } | |
func testConn(data []byte) net.Conn { return &conn{data: bytes.NewReader(data)} } | |
func Fuzz(data []byte) int { | |
conn := testConn(data) | |
if _, err := Wrap(conn); err != nil { | |
return 0 | |
} | |
return 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment