Skip to content

Configuration

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.

Example:

DrasylConfig config = DrasylConfig.newBuilder()
    .identityPath(Path.of("/Users/heiko/drasyl.identity.json"))
    .networkId(-25421)
    .remoteSuperPeerEndpoint(Endpoint.of("udp://staging.env.drasyl.org#Awlq4wgKNpgppEhH1a8fZSvvP5kh6eG7rWSXC6vm08UC"))
    .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.

Example:

drasyl.identity.path = /Users/heiko/drasyl.identity.json
drasyl.network.id = -25421
drasyl.remote.super-peer.endpoint = "udp://staging.env.drasyl.org#Awlq4wgKNpgppEhH1a8fZSvvP5kh6eG7rWSXC6vm08UC"

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

Example:

$ CONFIG_FORCE_drasyl_identity_path=/Users/heiko/drasyl.identity.json \
    CONFIG_FORCE_drasyl_network_id=-25421 \
    CONFIG_FORCE_drasyl_remote_super__peer_endpoint=udp://staging.env.drasyl.org#Awlq4wgKNpgppEhH1a8fZSvvP5kh6eG7rWSXC6vm08UC \
    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


Last update: December 5, 2021