Skip to content

Commit

Permalink
Merge pull request #62 from Galileo-Suite/master
Browse files Browse the repository at this point in the history
AIX support and build tag fixes
  • Loading branch information
schmichael authored Sep 16, 2024
2 parents 8187f9b + 355422a commit d05abfa
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
35 changes: 35 additions & 0 deletions route_info_aix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//go:build aix

package sockaddr

import (
"errors"
"os/exec"
)

var cmds map[string][]string = map[string][]string{
"route": {"/usr/sbin/route", "-n", "get", "default"},
}

// NewRouteInfo returns a BSD-specific implementation of the RouteInfo
// interface.
func NewRouteInfo() (routeInfo, error) {
return routeInfo{
cmds: cmds,
}, nil
}

// GetDefaultInterfaceName returns the interface name attached to the default
// route on the default interface.
func (ri routeInfo) GetDefaultInterfaceName() (string, error) {
out, err := exec.Command(cmds["route"][0], cmds["route"][1:]...).Output()
if err != nil {
return "", err
}

var ifName string
if ifName, err = parseDefaultIfNameFromRoute(string(out)); err != nil {
return "", errors.New("No default interface found")
}
return ifName, nil
}
6 changes: 2 additions & 4 deletions route_info_android.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
//go:build android

package sockaddr

import (
"errors"
"os/exec"
)

type routeInfo struct {
cmds map[string][]string
}

// NewRouteInfo returns a Android-specific implementation of the RouteInfo
// interface.
func NewRouteInfo() (routeInfo, error) {
Expand Down
4 changes: 2 additions & 2 deletions route_info_default.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build android || nacl || plan9 || js
// +build android nacl plan9 js
//go:build nacl || plan9 || js
// +build nacl plan9 js

package sockaddr

Expand Down
2 changes: 2 additions & 0 deletions route_info_solaris.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build solaris

package sockaddr

import (
Expand Down

0 comments on commit d05abfa

Please sign in to comment.