Class DrasylConfig

java.lang.Object
org.drasyl.node.DrasylConfig

public abstract class DrasylConfig extends Object
This class represents the configuration for a DrasylNode. For example, it defines the identity and the Super Peer.

This is an immutable object.

  • Field Details

  • Constructor Details

    • DrasylConfig

      public DrasylConfig()
  • Method Details

    • of

      public static DrasylConfig of()
    • of

      public static DrasylConfig of(com.typesafe.config.Config config)
    • getProofOfWork

      public static ProofOfWork getProofOfWork(com.typesafe.config.Config config, String path)
      Gets the ProofOfWork at the given path. Similar to Config, an exception is thrown for an invalid value.
      Parameters:
      config - the application's portion of the configuration
      path - path expression
      Returns:
      the ProofOfWork value at the requested path
      Throws:
      DrasylConfigException - if value is absent or null
    • getIdentityPublicKey

      public static IdentityPublicKey getIdentityPublicKey(com.typesafe.config.Config config, String path)
      Gets the IdentityPublicKey at the given path. Similar to Config, an exception is thrown for an invalid value.
      Parameters:
      config - the application's portion of the configuration
      path - path expression
      Returns:
      the IdentityPublicKey value at the requested path
      Throws:
      DrasylConfigException - if value is not convertible to a IdentityPublicKey
    • getIdentitySecretKey

      public static IdentitySecretKey getIdentitySecretKey(com.typesafe.config.Config config, String path)
      Gets the IdentitySecretKey at the given path. Similar to Config, an exception is thrown for an invalid value.
      Parameters:
      config - the application's portion of the configuration
      path - path expression
      Returns:
      the IdentitySecretKey value at the requested path
      Throws:
      DrasylConfigException - if value is not convertible to a IdentitySecretKey
    • getKeyAgreementPublicKey

      public static KeyAgreementPublicKey getKeyAgreementPublicKey(com.typesafe.config.Config config, String path)
      Gets the KeyAgreementPublicKey at the given path. Similar to Config, an exception is thrown for an invalid value.
      Parameters:
      config - the application's portion of the configuration
      path - path expression
      Returns:
      the IdentityPublicKey value at the requested path
      Throws:
      DrasylConfigException - if value is not convertible to a IdentityPublicKey
    • getKeyAgreementSecretKey

      public static KeyAgreementSecretKey getKeyAgreementSecretKey(com.typesafe.config.Config config, String path)
      Gets the KeyAgreementSecretKey at the given path. Similar to Config, an exception is thrown for an invalid value.
      Parameters:
      config - the application's portion of the configuration
      path - path expression
      Returns:
      the IdentitySecretKey value at the requested path
      Throws:
      DrasylConfigException - if value is not convertible to a IdentitySecretKey
    • getPath

      public static Path getPath(com.typesafe.config.Config config, String path)
      Gets the Path at the given path.
      Parameters:
      config - the application's portion of the configuration
      path - 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
    • getEndpointSet

      public static Set<PeerEndpoint> getEndpointSet(com.typesafe.config.Config config, String path)
      Throws:
      DrasylConfigException - if value at path is invalid
    • getEndpoint

      public static PeerEndpoint 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 to Config, an exception is thrown for an out-of-range value.
      Parameters:
      config - the application's portion of the configuration
      path - 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 to Config, an exception is thrown for an out-of-range value.
      Parameters:
      config - the application's portion of the configuration
      path - 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 the URI at the given path.
      Parameters:
      config - the application's portion of the configuration
      path - 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
    • getInetSocketAddressList

      public static List<InetSocketAddress> getInetSocketAddressList(com.typesafe.config.Config config, String path)
      Throws:
      DrasylConfigException - if value at path is invalid
    • getStaticRoutes

      public static Map<DrasylAddress,InetSocketAddress> 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.
      Parameters:
      file - the file to parse
      Returns:
      the parsed configuration
      Throws:
      DrasylConfigException - on IO or parse errors
    • parseFile

      public static DrasylConfig parseFile(Path path)
      Parses a file path into a Config instance.
      Parameters:
      path - the path to file to parse
      Returns:
      the parsed configuration
      Throws:
      DrasylConfigException - on IO or parse errors
    • parseFile

      public static DrasylConfig parseFile(String path)
      Parses a file path into a Config instance.
      Parameters:
      path - the path to file to parse
      Returns:
      the parsed configuration
      Throws:
      DrasylConfigException - on IO or parse errors
    • parseString

      public static DrasylConfig parseString(String s)
      Parses a string into a Config instance.
      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 custom DrasylConfig. The built configuration is derived from the default configuration. The builder must be finalized by calling DrasylConfig.Builder.build() to create the resulting DrasylConfig.
      Returns:
      the new builder
    • newBuilder

      public static DrasylConfig.Builder newBuilder(DrasylConfig config)
    • getNetworkId

      public abstract int getNetworkId()
    • getIdentityProofOfWork

      @Nullable public abstract ProofOfWork getIdentityProofOfWork()
    • getIdentitySecretKey

      @Nullable public abstract IdentitySecretKey getIdentitySecretKey()
    • getIdentity

      public Identity getIdentity()
      Returns:
      the identity specified in getIdentitySecretKey(), and getIdentityProofOfWork() or null if some of these properties are not present.
      Throws:
      IllegalStateException - if the key pair returned by getIdentitySecretKey() is not null and can not be converted to a key agreement key pair OR the getIdentityProofOfWork() does not match to the identity key pair/required difficulty specified in Identity.POW_DIFFICULTY.
    • getIdentityPath

      public abstract Path getIdentityPath()
    • getMessageBufferSize

      public abstract int getMessageBufferSize()
    • isRemoteEnabled

      public abstract boolean isRemoteEnabled()
    • getRemoteBindHost

      public abstract InetAddress getRemoteBindHost()
    • getRemoteBindPort

      public abstract int getRemoteBindPort()
    • isRemoteExposeEnabled

      public abstract boolean isRemoteExposeEnabled()
    • getRemotePingInterval

      public abstract Duration getRemotePingInterval()
    • getRemotePingTimeout

      public abstract Duration getRemotePingTimeout()
    • getRemotePingCommunicationTimeout

      public abstract Duration getRemotePingCommunicationTimeout()
    • getRemotePingMaxPeers

      public abstract int getRemotePingMaxPeers()
    • getRemoteUniteMinInterval

      public abstract Duration getRemoteUniteMinInterval()
    • isRemoteSuperPeerEnabled

      public abstract boolean isRemoteSuperPeerEnabled()
    • getRemoteSuperPeerEndpoints

      public abstract Set<PeerEndpoint> getRemoteSuperPeerEndpoints()
    • getRemoteStaticRoutes

      public abstract Map<DrasylAddress,InetSocketAddress> getRemoteStaticRoutes()
    • getRemoteHandshakeTimeout

      public abstract Duration getRemoteHandshakeTimeout()
    • isRemoteLocalHostDiscoveryEnabled

      public abstract boolean isRemoteLocalHostDiscoveryEnabled()
    • getRemoteLocalHostDiscoveryPath

      public abstract Path getRemoteLocalHostDiscoveryPath()
    • getRemoteLocalHostDiscoveryLeaseTime

      public abstract Duration getRemoteLocalHostDiscoveryLeaseTime()
    • isRemoteLocalHostDiscoveryWatchEnabled

      public abstract boolean isRemoteLocalHostDiscoveryWatchEnabled()
    • isRemoteLocalNetworkDiscoveryEnabled

      public abstract boolean isRemoteLocalNetworkDiscoveryEnabled()
    • getRemoteMessageMtu

      public abstract int getRemoteMessageMtu()
    • getRemoteMessageMaxContentLength

      public abstract int getRemoteMessageMaxContentLength()
    • getRemoteMessageComposedMessageTransferTimeout

      public abstract Duration getRemoteMessageComposedMessageTransferTimeout()
    • getRemoteMessageHopLimit

      public abstract byte getRemoteMessageHopLimit()
    • isRemoteMessageArmProtocolEnabled

      public abstract boolean isRemoteMessageArmProtocolEnabled()
    • getRemoteMessageArmProtocolSessionMaxCount

      public abstract int getRemoteMessageArmProtocolSessionMaxCount()
    • getRemoteMessageArmProtocolSessionExpireAfter

      public abstract Duration getRemoteMessageArmProtocolSessionExpireAfter()
    • isRemoteMessageArmApplicationEnabled

      public abstract boolean isRemoteMessageArmApplicationEnabled()
    • getRemoteMessageArmApplicationAgreementMaxCount

      public abstract int getRemoteMessageArmApplicationAgreementMaxCount()
    • getRemoteMessageArmApplicationAgreementExpireAfter

      public abstract Duration getRemoteMessageArmApplicationAgreementExpireAfter()
    • getRemoteMessageArmApplicationAgreementRetryInterval

      public abstract Duration getRemoteMessageArmApplicationAgreementRetryInterval()
    • isRemoteMessageArqEnabled

      public abstract boolean isRemoteMessageArqEnabled()
    • getRemoteMessageArqWindowSize

      public abstract int getRemoteMessageArqWindowSize()
    • getRemoteMessageArqRetryTimeout

      public abstract Duration getRemoteMessageArqRetryTimeout()
    • getRemoteMessageArqDeadPeerTimeout

      public abstract Duration getRemoteMessageArqDeadPeerTimeout()
    • getRemoteMessageArqClock

      public abstract Duration getRemoteMessageArqClock()
    • isRemoteTcpFallbackEnabled

      public abstract boolean isRemoteTcpFallbackEnabled()
    • getRemoteTcpFallbackServerBindHost

      public abstract InetAddress getRemoteTcpFallbackServerBindHost()
    • getRemoteTcpFallbackServerBindPort

      public abstract int getRemoteTcpFallbackServerBindPort()
    • getRemoteTcpFallbackClientTimeout

      public abstract Duration getRemoteTcpFallbackClientTimeout()
    • getRemoteTcpFallbackClientAddress

      public abstract InetSocketAddress getRemoteTcpFallbackClientAddress()
    • isIntraVmDiscoveryEnabled

      public abstract boolean isIntraVmDiscoveryEnabled()
    • getSntpServers

      public abstract List<SocketAddress> getSntpServers()
    • getPlugins

      public abstract Set<DrasylPlugin> getPlugins()
    • getSerializationSerializers

      public abstract Map<String,Serializer> getSerializationSerializers()
    • getSerializationsBindingsInbound

      public abstract Map<Class<?>,String> getSerializationsBindingsInbound()
    • getSerializationsBindingsOutbound

      public abstract Map<Class<?>,String> getSerializationsBindingsOutbound()
    • getChannelInactivityTimeout

      public abstract Duration getChannelInactivityTimeout()