@ -193,6 +193,16 @@ var debugCmd = &ffcli.Command{
return fs
return fs
} ) ( ) ,
} ) ( ) ,
} ,
} ,
{
Name : "netmap" ,
Exec : runNetmap ,
ShortHelp : "print the current network map" ,
FlagSet : ( func ( ) * flag . FlagSet {
fs := newFlagSet ( "netmap" )
fs . BoolVar ( & netmapArgs . showPrivateKey , "show-private-key" , false , "include node private key in printed netmap" )
return fs
} ) ( ) ,
} ,
{
{
Name : "via" ,
Name : "via" ,
Exec : runVia ,
Exec : runVia ,
@ -448,6 +458,33 @@ func runWatchIPN(ctx context.Context, args []string) error {
return nil
return nil
}
}
var netmapArgs struct {
showPrivateKey bool
}
func runNetmap ( ctx context . Context , args [ ] string ) error {
ctx , cancel := context . WithTimeout ( ctx , 5 * time . Second )
defer cancel ( )
var mask ipn . NotifyWatchOpt = ipn . NotifyInitialNetMap
if ! netmapArgs . showPrivateKey {
mask |= ipn . NotifyNoPrivateKeys
}
watcher , err := localClient . WatchIPNBus ( ctx , mask )
if err != nil {
return err
}
defer watcher . Close ( )
n , err := watcher . Next ( )
if err != nil {
return err
}
j , _ := json . MarshalIndent ( n . NetMap , "" , "\t" )
fmt . Printf ( "%s\n" , j )
return nil
}
func runDERPMap ( ctx context . Context , args [ ] string ) error {
func runDERPMap ( ctx context . Context , args [ ] string ) error {
dm , err := localClient . CurrentDERPMap ( ctx )
dm , err := localClient . CurrentDERPMap ( ctx )
if err != nil {
if err != nil {