Package com.zerotier.sockets
Class ZeroTierNode
java.lang.Object
com.zerotier.sockets.ZeroTierNode
public class ZeroTierNode
extends java.lang.Object
Class that provides a control interface for nodes and networks by
wrapping the ZeroTierNative class.
-
Constructor Summary
Constructors Constructor Description ZeroTierNode()
-
Method Summary
Modifier and Type Method Description long
getId()
Get the identity of this node (public key)java.net.InetAddress
getIPv4Address(long networkId)
Get the first-assigned IPv4 addressjava.net.InetAddress
getIPv6Address(long networkId)
Get the first-assigned IPv6 addressjava.lang.String
getMACAddress(long networkId)
Get the first-assigned IPv6 addressint
initAllowIdCache(boolean allowed)
(Optional) Whether caching of identity key pairs to storage is allowed.int
initAllowNetworkCache(boolean allowed)
(Optional) Whether caching of network configuration data to storage is allowed.int
initAllowPeerCache(boolean allowed)
(Optional) Whether caching of peer address information to storage is allowed.int
initAllowRootsCache(boolean allowed)
(Optional) Whether caching of root topology to storage is allowed.int
initFromStorage(java.lang.String storagePath)
(Optional) Instruct ZeroTier to read and write identities and cache from a storage location.int
initSetEventHandler(ZeroTierEventListener handler)
(Optional) Set the event handler function.int
initSetPort(short port)
(Optional) Set the ZeroTier service port.boolean
isNetworkTransportReady(long networkId)
Return whether the given network is ready to process trafficboolean
isOnline()
Return whether the ZeroTier node is currently online (able to reach a root)int
join(long networkId)
Join a networkint
leave(long networkId)
Leave a networkint
start()
Start the ZeroTier nodeint
stop()
Stop the ZeroTier nodeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
ZeroTierNode
public ZeroTierNode()
-
-
Method Details
-
start
public int start()Start the ZeroTier node- Returns:
- Standard
-
stop
public int stop()Stop the ZeroTier node- Returns:
- return
-
initFromStorage
public int initFromStorage(java.lang.String storagePath)(Optional) Instruct ZeroTier to read and write identities and cache from a storage location. Note that this is an initialization method that should be called beforestart()
.- Parameters:
storagePath
- Where to read and write files- Returns:
- return
-
initAllowPeerCache
public int initAllowPeerCache(boolean allowed)(Optional) Whether caching of peer address information to storage is allowed. This is true by default ifinitFromStorage()
is used. Note that this is an initialization method that can only be called beforestart()
.- Parameters:
allowed
- Whether caching or storage of this item is allowed- Returns:
- return
-
initAllowNetworkCache
public int initAllowNetworkCache(boolean allowed)(Optional) Whether caching of network configuration data to storage is allowed. This is true by default ifinitFromStorage()
is used. Note that this is an initialization method that can only be called beforestart()
.- Parameters:
allowed
- Whether caching or storage of this item is allowed- Returns:
- return
-
initAllowIdCache
public int initAllowIdCache(boolean allowed)(Optional) Whether caching of identity key pairs to storage is allowed. This is true by default ifinitFromStorage()
is used. Note that this is an initialization method that can only be called beforestart()
.- Parameters:
allowed
- Whether caching or storage of this item is allowed- Returns:
- return
-
initAllowRootsCache
public int initAllowRootsCache(boolean allowed)(Optional) Whether caching of root topology to storage is allowed. This is true by default ifinitFromStorage()
is used. Note that this is an initialization method that can only be called beforestart()
.- Parameters:
allowed
- Whether caching or storage of this item is allowed- Returns:
- return
-
initSetPort
public int initSetPort(short port)(Optional) Set the ZeroTier service port. Note that this is an initialization method that can only be called beforestart()
.- Parameters:
port
- Port number- Returns:
- return
-
initSetEventHandler
(Optional) Set the event handler function. Note that this is an initialization method that can only be called beforestart()
.- Parameters:
handler
- Function to handle internal ZeroTier events- Returns:
- return
-
isOnline
public boolean isOnline()Return whether the ZeroTier node is currently online (able to reach a root)- Returns:
- return
-
join
public int join(long networkId)Join a network- Parameters:
networkId
- Network to join- Returns:
- return
-
leave
public int leave(long networkId)Leave a network- Parameters:
networkId
- Network to leave- Returns:
- return
-
isNetworkTransportReady
public boolean isNetworkTransportReady(long networkId)Return whether the given network is ready to process traffic- Parameters:
networkId
- Network to test- Returns:
- return
-
getId
public long getId()Get the identity of this node (public key)- Returns:
- 64-bit integer representing the 10-digit hexadecimal node ID
-
getIPv4Address
public java.net.InetAddress getIPv4Address(long networkId)Get the first-assigned IPv4 address- Parameters:
networkId
- Network to get assigned address for- Returns:
- address
-
getIPv6Address
public java.net.InetAddress getIPv6Address(long networkId)Get the first-assigned IPv6 address- Parameters:
networkId
- Network to get assigned address for- Returns:
- address
-
getMACAddress
public java.lang.String getMACAddress(long networkId)Get the first-assigned IPv6 address- Parameters:
networkId
- Network to get assigned address for- Returns:
- address
-