Skip to content

Commit

Permalink
returns error if no next hop is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Dec 10, 2024
1 parent 9d1f711 commit 68a9128
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hopper.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ const (
mtuLimit = 1500
)

var (
errNoNextHop = errors.New("no next hop provided")
)

type (
// OnClientInCallback is a callback function that processes incoming packets from clients
OnClientInCallback func(client net.Addr, in []byte) (out []byte)
Expand Down Expand Up @@ -119,6 +123,10 @@ func ListenWithOptions(laddr string,
return nil, errors.WithStack(err)
}

if len(nexthops) == 0 {
return nil, errors.WithStack(errNoNextHop)
}

err = conn.SetReadBuffer(sockbuf)
if err != nil {
return nil, errors.WithStack(err)
Expand Down

0 comments on commit 68a9128

Please sign in to comment.