-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1309 from skycoin/feature/autopeering
auto-peering visors to the hypervisor (skybian)
- Loading branch information
Showing
10 changed files
with
256 additions
and
87 deletions.
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
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,43 @@ | ||
package clihv | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
"os" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/skycoin/skywire-utilities/pkg/netutil" | ||
"github.com/skycoin/skywire/pkg/visor" | ||
) | ||
|
||
func init() { | ||
if os.Getenv("SKYBIAN") == "true" { | ||
RootCmd.AddCommand(pkCmd) | ||
} | ||
localIPs, err = netutil.DefaultNetworkInterfaceIPs() | ||
if err != nil { | ||
logger.WithError(err).Fatalln("Could not determine network interface IP address") | ||
} | ||
if len(localIPs) == 0 { | ||
localIPs = append(localIPs, net.ParseIP("192.168.0.1")) | ||
} | ||
var s string | ||
if idx := strings.LastIndex(localIPs[0].String(), "."); idx != -1 { | ||
s = localIPs[0].String()[:idx] | ||
} | ||
pkCmd.Flags().StringVarP(&ipAddr, "ip", "i", s+".2:7998", "ip:port to query") | ||
} | ||
|
||
var pkCmd = &cobra.Command{ | ||
Use: "pk", | ||
Short: "Fetch Hypervisor Public Key", | ||
Run: func(_ *cobra.Command, _ []string) { | ||
s, err := visor.FetchHvPk(ipAddr) | ||
if err != nil { | ||
logger.WithError(err).Fatalln("failed to fetch hypervisor public key") | ||
} | ||
fmt.Printf("%s\n", s) | ||
}, | ||
} |
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
Oops, something went wrong.