mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
More Go CLI work, and some cleanup.
This commit is contained in:
parent
cb147a3e8a
commit
e0492a7e69
6 changed files with 74 additions and 24 deletions
|
@ -46,9 +46,10 @@ Common Operations:
|
|||
blacklist if <prefix> <boolean> Toggle interface prefix blacklisting
|
||||
portmap <boolean> Toggle use of uPnP or NAT-PMP
|
||||
|
||||
· peer list List VL1 peers
|
||||
· peer <address> [command] [option] - Peer management commands
|
||||
show Show peer details (default)
|
||||
· peer [address] [command] [option] - Peer management commands
|
||||
list List peers
|
||||
listroots List root peers
|
||||
show Show peer details
|
||||
try <endpoint> [...] Try peer at explicit endpoint
|
||||
|
||||
· network list List VL2 networks
|
||||
|
|
|
@ -20,6 +20,13 @@ func Locator(args []string) int {
|
|||
}
|
||||
|
||||
switch args[0] {
|
||||
|
||||
case "new":
|
||||
|
||||
case "verify":
|
||||
|
||||
case "show":
|
||||
|
||||
}
|
||||
|
||||
return 0
|
||||
|
|
|
@ -211,3 +211,27 @@ func readJSONFile(p string, obj interface{}) error {
|
|||
}
|
||||
return json.Unmarshal(b, obj)
|
||||
}
|
||||
|
||||
func isValidAddress(a string) bool {
|
||||
if len(a) == zerotier.AddressStringLength {
|
||||
for _, c := range a {
|
||||
if !strings.ContainsRune("0123456789abcdefABCDEF", c) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isValidNetworkID(a string) bool {
|
||||
if len(a) == zerotier.NetworkIDStringLength {
|
||||
for _, c := range a {
|
||||
if !strings.ContainsRune("0123456789abcdefABCDEF", c) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -141,8 +141,10 @@ func Network(basePath string, authTokenGenerator func() string, args []string, j
|
|||
showNetwork(nwids, &network, jsonOutput)
|
||||
} else {
|
||||
switch args[1] {
|
||||
|
||||
case "show", "info":
|
||||
showNetwork(nwids, &network, jsonOutput)
|
||||
|
||||
case "set":
|
||||
if len(args) > 3 {
|
||||
Help()
|
||||
|
@ -178,6 +180,7 @@ func Network(basePath string, authTokenGenerator func() string, args []string, j
|
|||
fmt.Printf("globalroutes\t%s\n", allowedBlocked(network.Settings.AllowGlobalRoutes))
|
||||
fmt.Printf("defaultroute\t%s\n", allowedBlocked(network.Settings.AllowDefaultRouteOverride))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,11 +73,27 @@ func Peer(basePath string, authTokenGenerator func() string, args []string, json
|
|||
|
||||
authToken := authTokenGenerator()
|
||||
|
||||
if len(args) == 1 && args[0] == "list" {
|
||||
return listPeers(basePath, authToken, jsonOutput, false)
|
||||
//var addr zerotier.Address
|
||||
if isValidAddress(args[0]) {
|
||||
//addr, _ = zerotier.NewAddressFromString(args[0])
|
||||
args = args[1:]
|
||||
if len(args) < 1 {
|
||||
Help()
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
switch args[0] {
|
||||
|
||||
case "list":
|
||||
return listPeers(basePath, authToken, jsonOutput, false)
|
||||
case "listroots":
|
||||
return listPeers(basePath, authToken, jsonOutput, true)
|
||||
|
||||
case "show":
|
||||
|
||||
case "try":
|
||||
|
||||
}
|
||||
|
||||
return 0
|
||||
|
|
37
core/AES.cpp
37
core/AES.cpp
|
@ -62,25 +62,24 @@ ZT_INLINE uint8x16_t s_clmul_armneon_crypto(uint8x16_t h, uint8x16_t y, const ui
|
|||
|
||||
#endif // ZT_AES_NEON
|
||||
|
||||
ZT_INLINE void s_bmul32(const uint32_t x, const uint32_t y, uint32_t &rh, uint32_t &rl) noexcept
|
||||
{
|
||||
uint32_t x0 = x & 0x11111111U;
|
||||
uint32_t x1 = x & 0x22222222U;
|
||||
uint32_t x2 = x & 0x44444444U;
|
||||
uint32_t x3 = x & 0x88888888U;
|
||||
uint32_t y0 = y & 0x11111111U;
|
||||
uint32_t y1 = y & 0x22222222U;
|
||||
uint32_t y2 = y & 0x44444444U;
|
||||
uint32_t y3 = y & 0x88888888U;
|
||||
uint64_t z0 = (((uint64_t)x0 * y0) ^ ((uint64_t)x1 * y3) ^ ((uint64_t)x2 * y2) ^ ((uint64_t)x3 * y1)) & 0x1111111111111111ULL;
|
||||
uint64_t z1 = (((uint64_t)x0 * y1) ^ ((uint64_t)x1 * y0) ^ ((uint64_t)x2 * y3) ^ ((uint64_t)x3 * y2)) & 0x2222222222222222ULL;
|
||||
z0 |= z1;
|
||||
uint64_t z2 = (((uint64_t)x0 * y2) ^ ((uint64_t)x1 * y1) ^ ((uint64_t)x2 * y0) ^ ((uint64_t)x3 * y3)) & 0x4444444444444444ULL;
|
||||
z2 |= z0;
|
||||
uint64_t z3 = (((uint64_t)x0 * y3) ^ ((uint64_t)x1 * y2) ^ ((uint64_t)x2 * y1) ^ ((uint64_t)x3 * y0)) & 0x8888888888888888ULL;
|
||||
uint64_t z = z2 | z3;
|
||||
rh = (uint32_t)(z >> 32U);
|
||||
rl = (uint32_t)z;
|
||||
#define s_bmul32(x, y, rh, rl) { \
|
||||
uint32_t x0t = (x) & 0x11111111U; \
|
||||
uint32_t x1t = (x) & 0x22222222U; \
|
||||
uint32_t x2t = (x) & 0x44444444U; \
|
||||
uint32_t x3t = (x) & 0x88888888U; \
|
||||
uint32_t y0t = (y) & 0x11111111U; \
|
||||
uint32_t y1t = (y) & 0x22222222U; \
|
||||
uint32_t y2t = (y) & 0x44444444U; \
|
||||
uint32_t y3t = (y) & 0x88888888U; \
|
||||
uint64_t z0t = (((uint64_t)x0t * y0t) ^ ((uint64_t)x1t * y3t) ^ ((uint64_t)x2t * y2t) ^ ((uint64_t)x3t * y1t)) & 0x1111111111111111ULL; \
|
||||
uint64_t z1t = (((uint64_t)x0t * y1t) ^ ((uint64_t)x1t * y0t) ^ ((uint64_t)x2t * y3t) ^ ((uint64_t)x3t * y2t)) & 0x2222222222222222ULL; \
|
||||
z0t |= z1t; \
|
||||
uint64_t z2t = (((uint64_t)x0t * y2t) ^ ((uint64_t)x1t * y1t) ^ ((uint64_t)x2t * y0t) ^ ((uint64_t)x3t * y3t)) & 0x4444444444444444ULL; \
|
||||
z2t |= z0t; \
|
||||
uint64_t z3t = (((uint64_t)x0t * y3t) ^ ((uint64_t)x1t * y2t) ^ ((uint64_t)x2t * y1t) ^ ((uint64_t)x3t * y0t)) & 0x8888888888888888ULL; \
|
||||
uint64_t zt = z2t | z3t; \
|
||||
(rh) = (uint32_t)(zt >> 32U); \
|
||||
(rl) = (uint32_t)zt; \
|
||||
}
|
||||
|
||||
void s_gfmul(const uint64_t hh, const uint64_t hl, uint64_t &y0, uint64_t &y1) noexcept
|
||||
|
|
Loading…
Add table
Reference in a new issue