Skip to content

Commit

Permalink
fix: common
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfogre committed Mar 28, 2023
1 parent 351ae99 commit 6599803
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/common/outbound_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ package common

import (
"net"

log "github.com/sirupsen/logrus"
)

// https://stackoverflow.com/a/37382208
// Get preferred outbound ip of this machine
func GetOutboundIP() net.IP {
func GetOutboundIP() (net.IP, error) {
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
log.Fatal(err)
return nil, err
}
defer conn.Close()

localAddr := conn.LocalAddr().(*net.UDPAddr)

return localAddr.IP
return localAddr.IP, nil
}

0 comments on commit 6599803

Please sign in to comment.