Skip to content

Commit

Permalink
PacketFilter does not need to implement net.PacketConn
Browse files Browse the repository at this point in the history
  • Loading branch information
AudriusButkevicius committed May 25, 2019
1 parent 9dca34a commit 730b0de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type FilteredConn struct {

// LocalAddr returns the local address
func (r *FilteredConn) LocalAddr() net.Addr {
return r.source.LocalAddr()
return r.source.conn.LocalAddr()
}

// SetReadDeadline sets a read deadline
Expand All @@ -33,7 +33,7 @@ func (r *FilteredConn) SetReadDeadline(t time.Time) error {

// SetWriteDeadline sets a write deadline
func (r *FilteredConn) SetWriteDeadline(t time.Time) error {
return r.source.SetWriteDeadline(t)
return r.source.conn.SetWriteDeadline(t)
}

// SetDeadline sets a read and a write deadline
Expand All @@ -53,7 +53,7 @@ func (r *FilteredConn) WriteTo(b []byte, addr net.Addr) (n int, err error) {
if r.filter != nil {
r.filter.Outgoing(b, addr)
}
return r.source.WriteTo(b, addr)
return r.source.conn.WriteTo(b, addr)
}

// ReadFrom reads from the filtered connection
Expand Down
6 changes: 3 additions & 3 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Filter interface {
// connection.
func NewPacketFilter(conn net.PacketConn) *PacketFilter {
d := &PacketFilter{
PacketConn: conn,
conn: conn,
}
return d
}
Expand All @@ -30,7 +30,7 @@ type PacketFilter struct {
dropped uint64
overflow uint64

net.PacketConn
conn net.PacketConn

conns []*FilteredConn
mut sync.Mutex
Expand Down Expand Up @@ -96,7 +96,7 @@ func (d *PacketFilter) loop() {
next:
for {
buf = bufPool.Get().([]byte)
n, addr, err := d.ReadFrom(buf)
n, addr, err := d.conn.ReadFrom(buf)
pkt := packet{
n: n,
addr: addr,
Expand Down

0 comments on commit 730b0de

Please sign in to comment.