Skip to main content
Version: 0.8

Overview

drasyl is designed to work with zero-configuration. However, some use cases (e.g. using an own super peer) require customization configurations. For this situation there are various parameters available to adjust the behavior of drasyl nodes.

An overview of all available parameters, their purpose and default values can be found in the reference.conf file.

Create custom configurations​

Because drasyl's configuration is based on Lightbend Config library, there are many ways to create custom configurations.

Use DrasylConfig.Buidler​

With the DrasylConfig.Buidler class, configurations can be created within Java. This allows you to define individual configurations for each node. It is done by calling DrasylConfig.newBuilder() ... .build() . Available builder methods can be obtained from the Javadoc.

Configuration.java
import org.drasyl.node.*;
import java.nio.file.Path;
import java.util.Set;

public class Configuration {
public static void main(final String[] args) {
final DrasylConfig config = DrasylConfig.newBuilder()
.identityPath(Path.of("/Users/heiko/drasyl.identity"))
.networkId(22527)
.remoteSuperPeerEndpoints(Set.of(PeerEndpoint.of("udp://sp-fra1.drasyl.org:22527?publicKey=c0900bcfabc493d062ecd293265f571edb70b85313ba4cdda96c9f77163ba62d&networkId=1")))
.remoteEnabled(false)
.build();
}
}

The resulting DrasylConfig object can now be passed to the DrasylNode constructor .

Use application.conf file​

You can add a resource called application.conf to your java classpath to provide a custom config used by all your nodes. This file has to use the HOCON Syntax. The file only needs to contain the parameters you want to overwrite because it will be merged with the default values found in reference.conf.

application.conf
drasyl.identity.path = /Users/heiko/drasyl.identity
drasyl.network.id = 22527
drasyl.remote.super-peer.endpoint = "udp://sp-fra1.drasyl.org:22527?publicKey=c0900bcfabc493d062ecd293265f571edb70b85313ba4cdda96c9f77163ba62d&networkId=1"

Use environment variables​

By setting the JVM property -Dconfig.override_with_env_vars=true it is possible to override any configuration value using environment variables.

With this option enabled only environment variables starting with CONFIG_FORCE_ are considered, and the name is mangled as follows:

  • the prefix CONFIG_FORCE_ is stripped
  • single underscore(_) is converted into a dot(.)
  • double underscore(__) is converted into a dash(-)
  • triple underscore(___) is converted into a single underscore(_)

i.e. The environment variable CONFIG_FORCE_a_b__c___d set the configuration key a.b-c_d

$ CONFIG_FORCE_drasyl_identity_path=/Users/heiko/drasyl.identity \
CONFIG_FORCE_drasyl_network_id=22527 \
CONFIG_FORCE_drasyl_remote_super__peer_endpoint=udp://sp-fra1.drasyl.org:22527?publicKey=c0900bcfabc493d062ecd293265f571edb70b85313ba4cdda96c9f77163ba62d&networkId=1 \
your-application.jar
Advanced References

Further information regarding formatting can be taken directly from the configuration library that is used internally by drasyl: https://github.com/lightbend/config