Skip to content

Commit 9c16254

Browse files
committed
do not let router fail
1 parent e9a7386 commit 9c16254

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

router.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,21 @@ func (r *Route) String() string {
3131
}
3232

3333
func GetRoute(ip net.IP) (*Route, error) {
34-
r, err := routing.New()
34+
hostname, err := os.Hostname()
3535
if err != nil {
36-
return nil, err
36+
hostname = "localhost"
3737
}
3838

39-
hostname, err := os.Hostname()
39+
r, err := routing.New()
4040
if err != nil {
41-
hostname = ""
41+
return &Route{
42+
SourceHostname: hostname,
43+
SourceInterfaceName: "",
44+
SourceHardwareAddress: nil,
45+
SourceIP: nil,
46+
GatewayIP: nil,
47+
DestinationIP: ip},
48+
err
4249
}
4350

4451
iface, gateway, source, err := r.Route(ip)

0 commit comments

Comments
 (0)