Skip to content

Instantly share code, notes, and snippets.

@dgryski
Created November 28, 2018 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgryski/df3408b52b3d6a228ec57a922864f666 to your computer and use it in GitHub Desktop.
Save dgryski/df3408b52b3d6a228ec57a922864f666 to your computer and use it in GitHub Desktop.
// +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