-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BGP: Fix IPv4 listen addr configuration
Closes #450 Signed-off-by: Maximilian Wilhelm <[email protected]>
- Loading branch information
Maximilian Wilhelm
committed
Oct 11, 2023
1 parent
0e48eb2
commit 4ba4f23
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package tcp | ||
|
||
import ( | ||
"net" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIpv4AddrToArray(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
addr string | ||
expected [4]byte | ||
}{ | ||
{ | ||
name: "IPv4 / 0.0.0.0", | ||
addr: "0.0.0.0:179", | ||
expected: [4]byte{0, 0, 0, 0}, | ||
}, | ||
{ | ||
name: "IPv4 / 192.0.2.42", | ||
addr: "192.0.2.42:179", | ||
expected: [4]byte{192, 0, 2, 42}, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
tcpaddr, err := net.ResolveTCPAddr("tcp", test.addr) | ||
if err != nil { | ||
t.Fatalf("Failed to resolve TCPAddr: %v", err) | ||
} | ||
assert.Equal(t, test.expected, ipv4AddrToArray(tcpaddr.IP), test.name) | ||
} | ||
} |