123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- /*
- * Copyright (c)2013-2020 ZeroTier, Inc.
- *
- * Use of this software is governed by the Business Source License included
- * in the LICENSE.TXT file in the project's root directory.
- *
- * Change Date: 2024-01-01
- *
- * On the date above, in accordance with the Business Source License, use
- * of this software will be governed by version 2.0 of the Apache License.
- */
- /****/
- package cli
- import (
- "fmt"
- "os"
- "zerotier/pkg/zerotier"
- )
- func Networks(basePath, authToken string, args []string, jsonOutput bool) {
- var networks []zerotier.APINetwork
- apiGet(basePath, authToken, "/network", &networks)
- if jsonOutput {
- fmt.Println(jsonDump(networks))
- } else {
- fmt.Printf("%-16s %-24s %-17s %-8s <type> <device> <managed IP(s)>\n", "<id>", "<name>", "<mac>", "<status>")
- for _, nw := range networks {
- t := "PRIVATE"
- if nw.Config.Type == zerotier.NetworkTypePublic {
- t = "PUBLIC"
- }
- fmt.Printf("%.16x %-24s %-17s %-16s %-7s %-16s ", uint64(nw.ID), nw.Config.Name, nw.Config.MAC.String(), networkStatusStr(nw.Config.Status), t, nw.PortName)
- for i, ip := range nw.Config.AssignedAddresses {
- if i > 0 {
- fmt.Print(",")
- }
- fmt.Print(ip.String())
- }
- fmt.Print("\n")
- }
- }
- os.Exit(0)
- }
|