aboutsummaryrefslogtreecommitdiff
path: root/cmd/vhost/main.go
diff options
context:
space:
mode:
authorDavid Doan <daviddoan@Davids-MacBook-Pro-70.local>2023-10-23 18:00:09 -0400
committerDavid Doan <daviddoan@Davids-MacBook-Pro-70.local>2023-10-23 18:00:09 -0400
commit8410dde94f746c254d62461947abbe68d25009b2 (patch)
tree27f4f3fef199d67c8b86ed82a0b3c24fd8db76a2 /cmd/vhost/main.go
parentaaa3e0e5279c534bb07856bbce867e4cde2ed255 (diff)
comments and refactoring
Diffstat (limited to 'cmd/vhost/main.go')
-rw-r--r--cmd/vhost/main.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/cmd/vhost/main.go b/cmd/vhost/main.go
index 26280ef..a72dc98 100644
--- a/cmd/vhost/main.go
+++ b/cmd/vhost/main.go
@@ -56,8 +56,9 @@ func main() {
// combine message into one string
messageToSend := strings.Join(message, " ")
messageToSendBytes := []byte(messageToSend)
-
- hop, err := ipstack.LongestPrefix(netip.MustParseAddr(ipAddr))
+
+ address, _ := netip.ParseAddr(ipAddr)
+ hop, err := ipstack.LongestPrefix(address)
if err != nil {
fmt.Println(err)
continue
@@ -65,7 +66,7 @@ func main() {
myAddr := hop.Interface.IpPrefix.Addr()
for _, neighbor := range ipstack.GetNeighbors()[hop.Interface.Name] {
// TODO: fix multiple send bug here on static route
- if neighbor.VipAddr == netip.MustParseAddr(ipAddr) ||
+ if neighbor.VipAddr == address ||
neighbor.VipAddr == hop.VIP && hop.Type == "S" {
bytesWritten, err := ipstack.SendIP(&myAddr, neighbor, ipstack.TEST_PROTOCOL, messageToSendBytes, ipAddr, nil)
if err != nil {