Package org.drasyl
Class DrasylConfig
- java.lang.Object
-
- org.drasyl.DrasylConfig
-
public class DrasylConfig extends Object
This class represents the configuration for aDrasylNode
. For example, it defines the identity and the Super Peer.This is an immutable object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DrasylConfig.Builder
-
Constructor Summary
Constructors Constructor Description DrasylConfig()
DrasylConfig(com.typesafe.config.Config config)
Creates a new config for a drasyl node.
-
Method Summary
-
-
-
Constructor Detail
-
DrasylConfig
public DrasylConfig()
-
DrasylConfig
public DrasylConfig(com.typesafe.config.Config config)
Creates a new config for a drasyl node.- Parameters:
config
- config to be loaded- Throws:
DrasylConfigException
- if config is invalid
-
-
Method Detail
-
getProofOfWork
public static ProofOfWork getProofOfWork(com.typesafe.config.Config config, String path)
Gets theProofOfWork
at the given path. Similar toConfig
, an exception is thrown for an invalid value.- Parameters:
config
- the application's portion of the configurationpath
- path expression- Returns:
- the
ProofOfWork
value at the requested path - Throws:
DrasylConfigException
- if value is absent or null
-
getPublicKey
public static CompressedPublicKey getPublicKey(com.typesafe.config.Config config, String path)
Gets theCompressedPublicKey
at the given path. Similar toConfig
, an exception is thrown for an invalid value.- Parameters:
config
- the application's portion of the configurationpath
- path expression- Returns:
- the
CompressedPublicKey
value at the requested path - Throws:
DrasylConfigException
- if value is not convertible to aCompressedPublicKey
-
getPrivateKey
public static CompressedPrivateKey getPrivateKey(com.typesafe.config.Config config, String path)
Gets theCompressedPrivateKey
at the given path. Similar toConfig
, an exception is thrown for an invalid value.- Parameters:
config
- the application's portion of the configurationpath
- path expression- Returns:
- the
CompressedPrivateKey
value at the requested path - Throws:
DrasylConfigException
- if value is not convertible to aCompressedPrivateKey
-
getPath
public static Path getPath(com.typesafe.config.Config config, String path)
Gets thePath
at the given path.- Parameters:
config
- the application's portion of the configurationpath
- path expression- Returns:
- the
Path
value at the requested path - Throws:
DrasylConfigException
- if value at path is invalid
-
getInetAddress
public static InetAddress getInetAddress(com.typesafe.config.Config config, String path)
- Throws:
DrasylConfigException
- if value at path is invalid
-
getEndpointList
public static List<Endpoint> getEndpointList(com.typesafe.config.Config config, String path)
- Throws:
DrasylConfigException
- if value at path is invalid
-
getEndpoint
public static Endpoint getEndpoint(com.typesafe.config.Config config, String path)
- Throws:
DrasylConfigException
- if value at path is invalid
-
getShort
public static short getShort(com.typesafe.config.Config config, String path)
Gets the short at the given path. Similar toConfig
, an exception is thrown for an out-of-range value.- Parameters:
config
- the application's portion of the configurationpath
- path expression- Returns:
- the short value at the requested path
- Throws:
DrasylConfigException
- if value is not convertible to a short
-
getByte
public static byte getByte(com.typesafe.config.Config config, String path)
Gets the byte at the given path. Similar toConfig
, an exception is thrown for an out-of-range value.- Parameters:
config
- the application's portion of the configurationpath
- path expression- Returns:
- the byte value at the requested path
- Throws:
DrasylConfigException
- if value is not convertible to a short
-
getURI
public static URI getURI(com.typesafe.config.Config config, String path)
Gets theURI
at the given path.- Parameters:
config
- the application's portion of the configurationpath
- path expression- Returns:
- the
URI
value at the requested path - Throws:
DrasylConfigException
- if value at path is invalid
-
getPlugins
public static Set<DrasylPlugin> getPlugins(com.typesafe.config.Config config, String path)
- Throws:
DrasylConfigException
- if value at path is invalid
-
getSerializationSerializers
public static Map<String,Serializer> getSerializationSerializers(com.typesafe.config.Config config, String path)
-
getSerializationBindings
public static Map<Class<?>,String> getSerializationBindings(com.typesafe.config.Config config, String path, Collection<String> serializers)
-
getInetSocketAddress
public static InetSocketAddress getInetSocketAddress(com.typesafe.config.Config config, String path)
- Throws:
DrasylConfigException
- if value at path is invalid
-
getStaticRoutes
public static Map<CompressedPublicKey,InetSocketAddressWrapper> getStaticRoutes(com.typesafe.config.Config config, String path)
- Throws:
DrasylConfigException
- if value at path is invalid
-
parseFile
public static DrasylConfig parseFile(File file)
Parses a file into a Config instance as with- Parameters:
file
- the file to parse- Returns:
- the parsed configuration
- Throws:
DrasylConfigException
- on IO or parse errors
-
parseString
public static DrasylConfig parseString(String s)
Parses a file into a Config instance as with- Parameters:
s
- string to parse- Returns:
- the parsed configuration
- Throws:
DrasylConfigException
- on IO or parse errors
-
newBuilder
public static DrasylConfig.Builder newBuilder()
Creates a new builder to build a customDrasylConfig
. The built configuration is derived from the default configuration. The builder must be finalized by callingDrasylConfig.Builder.build()
to create the resultingDrasylConfig
.- Returns:
- the new builder
-
newBuilder
public static DrasylConfig.Builder newBuilder(DrasylConfig config)
-
getRemotePingTimeout
public Duration getRemotePingTimeout()
-
getRemotePingCommunicationTimeout
public Duration getRemotePingCommunicationTimeout()
-
getRemoteUniteMinInterval
public Duration getRemoteUniteMinInterval()
-
getRemotePingMaxPeers
public int getRemotePingMaxPeers()
-
getNetworkId
public int getNetworkId()
-
isMonitoringEnabled
public boolean isMonitoringEnabled()
-
getMonitoringHostTag
public String getMonitoringHostTag()
-
getMonitoringInfluxUri
public URI getMonitoringInfluxUri()
-
getMonitoringInfluxUser
public String getMonitoringInfluxUser()
-
getMonitoringInfluxPassword
public String getMonitoringInfluxPassword()
-
getMonitoringInfluxDatabase
public String getMonitoringInfluxDatabase()
-
getMonitoringInfluxReportingFrequency
public Duration getMonitoringInfluxReportingFrequency()
-
isRemoteEnabled
public boolean isRemoteEnabled()
-
getRemoteBindHost
public InetAddress getRemoteBindHost()
-
getRemoteBindPort
public int getRemoteBindPort()
-
isRemoteExposeEnabled
public boolean isRemoteExposeEnabled()
-
getRemotePingInterval
public Duration getRemotePingInterval()
-
isRemoteSuperPeerEnabled
public boolean isRemoteSuperPeerEnabled()
-
getIdentityProofOfWork
public ProofOfWork getIdentityProofOfWork()
-
getIdentityPublicKey
public CompressedPublicKey getIdentityPublicKey()
-
getIdentityPrivateKey
public CompressedPrivateKey getIdentityPrivateKey()
-
getIdentityPath
public Path getIdentityPath()
-
getRemoteMessageMtu
public int getRemoteMessageMtu()
-
getRemoteMessageMaxContentLength
public int getRemoteMessageMaxContentLength()
-
getRemoteMessageComposedMessageTransferTimeout
public Duration getRemoteMessageComposedMessageTransferTimeout()
-
getRemoteMessageHopLimit
public byte getRemoteMessageHopLimit()
-
isRemoteMessageArmEnabled
public boolean isRemoteMessageArmEnabled()
-
getRemoteStaticRoutes
public Map<CompressedPublicKey,InetSocketAddressWrapper> getRemoteStaticRoutes()
-
isIntraVmDiscoveryEnabled
public boolean isIntraVmDiscoveryEnabled()
-
isRemoteLocalHostDiscoveryEnabled
public boolean isRemoteLocalHostDiscoveryEnabled()
-
getRemoteLocalHostDiscoveryPath
public Path getRemoteLocalHostDiscoveryPath()
-
getRemoteLocalHostDiscoveryLeaseTime
public Duration getRemoteLocalHostDiscoveryLeaseTime()
-
getPlugins
public Set<DrasylPlugin> getPlugins()
-
getSerializationSerializers
public Map<String,Serializer> getSerializationSerializers()
-
-