Skip to content

Commit

Permalink
Backport bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoBornholdt committed Mar 11, 2021
1 parent eeddadd commit 302975e
Show file tree
Hide file tree
Showing 66 changed files with 951 additions and 801 deletions.
70 changes: 0 additions & 70 deletions .gitlab-ci/Deployments.gitlab-ci.yml
Expand Up @@ -3,28 +3,6 @@ variables:
ROLLOUT_STATUS_DISABLED: 1
AUTO_DEVOPS_DEPLOY_DEBUG: 1

.deploy-base-docker: &deploy-base-docker
image: drasyl/drasyl-build-images:docker-18.02-docker-compose-1.19-git-2.15.4
script:
- sh ./prepare-environment-docker-compose.sh > docker-compose.yml
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker-compose pull
- docker-compose --project-name ${CI_PROJECT_NAME}-${CI_PROJECT_ID}-${CI_ENVIRONMENT_SLUG} up -d --remove-orphans
# We don't need cache for stop a environment
cache: {}

.stop-base-docker: &stop-base-docker
image: drasyl/drasyl-build-images:docker-18.02-docker-compose-1.19-git-2.15.4
before_script:
- git clone -n $CI_REPOSITORY_URL $CI_PROJECT_NAME
- cd $CI_PROJECT_NAME
- git checkout $CI_COMMIT_SHA || git checkout master
script:
- sh ./prepare-environment-docker-compose.sh > docker-compose.yml
- docker-compose --project-name ${CI_PROJECT_NAME}-${CI_PROJECT_ID}-${CI_ENVIRONMENT_SLUG} down
# We don't need cache for stop a environment
cache: {}

.auto-deploy:
image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v2.0.0"
dependencies: []
Expand Down Expand Up @@ -119,51 +97,3 @@ staging:
tags:
- kubernetes
- staging

production:
<<: *deploy-base-docker
stage: production
variables:
APP_IMAGE: "${CI_REGISTRY_IMAGE}:latest"
APP_DEPLOY_HOST: "production.${APP_HOST}"
PORT: 22527
DRASYL_NETWORK_ID: 1
DRASYL_PROOF_OF_WORK: 10992904
DRASYL_PUBLIC_KEY: 025fff6f625f5dee816d9f8fe43895479aecfda187cb6a3330894a07e698bc5bd8
# DRASYL_PRIVATE_KEY is defined securely in GitLab CI/CD Settings
SENTRY_ENVIRONMENT: production
environment:
name: production
url: https://$APP_HOST
on_stop: stop_production
only:
- master
- /^v\d+\.\d+/
when: manual
tags:
- docker
- production

stop_production:
<<: *stop-base-docker
stage: cleanup
variables:
GIT_STRATEGY: none
APP_IMAGE: "${CI_REGISTRY_IMAGE}:latest"
APP_DEPLOY_HOST: "production.${APP_HOST}"
PORT: 22527
SENTRY_ENVIRONMENT: production
DRASYL_NETWORK_ID: 1
DRASYL_PROOF_OF_WORK: 10992904
DRASYL_PUBLIC_KEY: 025fff6f625f5dee816d9f8fe43895479aecfda187cb6a3330894a07e698bc5bd8
# DRASYL_PRIVATE_KEY is defined securely in GitLab CI/CD Settings
only:
- master
- /^v\d+\.\d+/
when: manual
environment:
name: production
action: stop
tags:
- docker
- production
4 changes: 2 additions & 2 deletions .gitlab-ci/Maven.gitlab-ci.yml
Expand Up @@ -15,8 +15,8 @@ cache:
- echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import --no-tty --batch --yes
- echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust --no-tty --batch --yes
after_script:
- '/bin/bash coverage-jacoco.sh'
- for file in drasyl-*.zip; do sha256sum "$file" | awk '{print $1}' > "$file.sha256"; done
- awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' drasyl-all/target/site/jacoco-aggregate/jacoco.csv
coverage: '/\d+.\d+ \% covered/'
artifacts:
reports:
Expand All @@ -42,7 +42,7 @@ maven-deploy:
<<: *maven-base
stage: deploy
script:
- 'mvn $MAVEN_CLI_OPTS -Prelease,ossrh clean package source:jar gpg:sign install:install deploy:deploy sonar:sonar'
- 'mvn $MAVEN_CLI_OPTS -Prelease,ossrh clean verify source:jar gpg:sign install:install deploy:deploy sonar:sonar'
only:
- master
- /^v\d+\.\d+/
File renamed without changes.
25 changes: 20 additions & 5 deletions CHANGELOG.md
Expand Up @@ -5,7 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.0] - 2020-02-27
## [0.4.1] - 2021-03-11

### Changed

- Dependencies were updated.

### Fixed

- Fixed an NPE when requesting a port forwarding if the Internet Gateway Device responds with an
error.
- Since the super peer sp-ham1 has connectivity problems, this has been replaced by the sp-fra1.
- Public and private keys are now displayed everywhere in the classic format.
- Unused dependencies removed.
- Some additional minor fixes.

## [0.4.0] - 2021-02-27

### Added

Expand All @@ -16,8 +31,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- When changing the network, new port mappings are now automatically created on the new network.
- `DrasylNode`'s API has been enhanced with `@NotNull` and `@Nullable` annotations.
- Messages that can be delivered within the same JVM are now passed by reference (previously these
messages have been unnecessarily serialized).
**So make sure you either send copies of your objects or it's
messages have been unnecessarily serialized).
**So make sure you either send copies of your objects or it's
fine for other nodes to make changes to that object.**
- Static routes to other remote peers can now be defined. This allows discovery to be omitted in
static environments (or test setups).
Expand All @@ -33,7 +48,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Changed

- By default, each node now listens on a port in the range 22528 and 65528, which is derived from
- By default, each node now listens on a port in the range 22528 and 65528, which is derived from
its identity. This means that the chance for a port collision is now reduced when
multiple nodes are running on one computer.
- UDP is now used instead of TCP for communication with remote peers.
Expand All @@ -43,7 +58,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Documentation has been revised (Javadoc and/or documentation at https://docs.drasyl.org).
- Messages can now be additionally serialized by protobuf or Java. Furthermore, own serializers can
be implemented. Read more at https://docs.drasyl.org.
- The third-party portmapper library has been replaced with our own more lightweight
- The third-party portmapper library has been replaced with our own more lightweight
and more resilient implementation.
- All dependencies have been updated to the latest versions.

Expand Down
90 changes: 35 additions & 55 deletions README.md
@@ -1,4 +1,9 @@
# <img src="https://docs.drasyl.org/master/assets/img/logo.svg" alt="drasyl" width="200"/>
[<img src="https://docs.drasyl.org/master/assets/img/logo.svg" alt="drasyl" width="200"/>](https://drasyl.org)

[Website](https://drasyl.org) |
[Documentation](https://docs.drasyl.org) |
[Contributing](CONTRIBUTING.md) |
[Changelog](CHANGELOG.md)

[![Build Status](https://git.informatik.uni-hamburg.de/sane-public/drasyl/badges/master/pipeline.svg)](https://git.informatik.uni-hamburg.de/sane-public/drasyl/-/pipelines)
[![LGPL v3](https://img.shields.io/badge/license-LGPL%20v3-blue)](https://www.gnu.org/licenses/lgpl-3.0)
Expand All @@ -8,68 +13,43 @@
[![Chocolatey](https://img.shields.io/chocolatey/v/drasyl)](https://chocolatey.org/packages/drasyl)
[![Gitter](https://badges.gitter.im/drasyl-overlay/drasyl.svg)](https://gitter.im/drasyl-overlay/drasyl)

drasyl is a general-purpose overlay network framework for rapid development of distributed P2P applications.
# drasyl

drasyl is a general-purpose overlay network framework for rapid development of distributed P2P
applications.

By using drasyl developers can fully concentrate on creating distributed applications.
With drasyl, boundaries between IP-based networks will be eliminated and secure communication channels between any peers will be provided.
Zero-configuration is required to use drasyl.
Developers can run a new drasyl node without having to write configuration files or provide IP addresses of peers.
By using drasyl developers can fully concentrate on creating distributed applications. With drasyl,
boundaries between IP-based networks will be eliminated and secure communication channels between
any peers will be provided. Zero-configuration is required to use drasyl. Developers can run a new
drasyl node without having to write configuration files or provide IP addresses of peers.

![drasyl architecture](https://docs.drasyl.org/master/assets/img/drasyl-architecture.png)

_As drasyl is primarily developed for the research project
[Smart Networks for Urban Participation (SANE)](https://sane.city/) and focuses on functionalities necessary for the project. However, drasyl is open to
contributions made by the community._

## Maven/Gradle Dependencies

Maven:
```xml
<dependency>
<groupId>org.drasyl</groupId>
<artifactId>drasyl-core</artifactId>
<version>0.3.0</version>
</dependency>
```

Gradle:

```compile group: 'org.drasyl', name: 'drasyl-core', version: '0.3.0'```

## Standalone Command Line Interface

There is a drasyl command line interface with some utilities that can be found on the releases page: https://github.com/drasyl-overlay/drasyl/releases

It is also available in docker:

```docker run drasyl/drasyl help```

## Create and Start drasyl Node

```java
DrasylNode node = new DrasylNode() {
@Override
public void onEvent(Event event) {
// handle incoming events (messages) here
System.out.println("Event received: " + event);
}
};
node.start();

// wait till NodeOnlineEvent has been received
[Smart Networks for Urban Participation (SANE)](https://sane.city/) and focuses on functionalities
necessary for the project. However, drasyl is open to contributions made by the community._

// send message to another node
node.send("0229041b273dd5ee1c2bef2d77ae17dbd00d2f0a2e939e22d42ef1c4bf05147ea9", "Hello World");
# Features

// shutdown node
node.shutdown();
```
* Provides Communication Channels between any two Nodes (on the Internet).
* Automatic Discovery of Peers running within same Process, Computer, LAN, or the Internet.
* Automatic Handover to most local Communication Channel.
* Overcomes Network Barriers (Statefull Firewalls, NATs).
* UDP Hole Punching.
* Port Mapping (UPnP-IGD, NAT-PMP, PCP).
* Reacts to Network Changes.
* Asynchronous and Event-Driven.
* Lightweight.
* Extensible.

## Documentation
# Usage & Documentation

More information can be found in the [documentation](https://docs.drasyl.org).
* [Getting Started](https://docs.drasyl.org/getting-started/)
* [Configuration](https://docs.drasyl.org/configuration/)
* [JavaDoc](https://www.javadoc.io/doc/org.drasyl/drasyl-core/latest/index.html)
* [Command Line Interface](https://docs.drasyl.org/cli/)
* [Chat](https://gitter.im/drasyl-overlay/drasyl)

-------------------------------------
_Licensed under [GNU Lesser General Public License v3.0](LICENSE)_
# License

_Inspired by [ZeroTier's Peer to Peer Network](https://www.zerotier.com/manual/#2_1)_
This is free software under the terms of the [GNU Lesser General Public License v3.0](LICENSE)
24 changes: 0 additions & 24 deletions coverage-jacoco.sh

This file was deleted.

7 changes: 3 additions & 4 deletions docs/content/public-super-peers.md
Expand Up @@ -6,10 +6,9 @@ We run some public super peers, so you don't have to.

| **Endpoint** | **Used drasyl version** |
|---------------|--------------------------|
| `udp://sp-ham1.drasyl.org:22527?publicKey=0211d40b6e57c8da1780f6b326e9c972cb8f62c522984fb43aec42049efb5b564f&networkId=1` | Latest stable [release](https://github.com/drasyl-overlay/drasyl/releases) |
| `udp://sp-nue1.drasyl.org:22527?publicKey=0261ee8817141b626d3573a76715aad053ccee7410d7a820c2fc98faa4c485a580&networkId=1` | Latest stable [release](https://github.com/drasyl-overlay/drasyl/releases) |
| `udp://staging.env.drasyl.org?publicKey=03096ae3080a369829a44847d5af1f652bef3f9921e9e1bbad64970babe6d3c502&networkId=-25421` | Latest [nightly](https://git.informatik.uni-hamburg.de/sane-public/drasyl/-/pipelines?page=1&scope=all&ref=master&status=success) |
| ```udp://sp-fra1.drasyl.org:22527?publicKey=025101da43b6b6fbd7b863deb64dd060a86c90568895083a8e6b0b94594f055a18&networkId=1``` | Latest stable [release](https://github.com/drasyl-overlay/drasyl/releases) |
| ```udp://sp-nue1.drasyl.org:22527?publicKey=0261ee8817141b626d3573a76715aad053ccee7410d7a820c2fc98faa4c485a580&networkId=1``` | Latest stable [release](https://github.com/drasyl-overlay/drasyl/releases) |

By default, all drasyl nodes are configured to use the super peers `sp-ham1.drasyl.org`
By default, all drasyl nodes are configured to use the super peers `sp-fra1.drasyl.org`
and `sp-nue1.drasyl.org`.

34 changes: 23 additions & 11 deletions drasyl-cli/src/main/java/org/drasyl/cli/Cli.java
Expand Up @@ -25,9 +25,11 @@
import org.drasyl.cli.command.PerfCommand;
import org.drasyl.cli.command.VersionCommand;
import org.drasyl.cli.command.WormholeCommand;
import org.drasyl.util.logging.Logger;
import org.drasyl.util.logging.LoggerFactory;

import java.io.PrintStream;
import java.util.Map;
import java.util.function.Consumer;

import static java.util.Objects.requireNonNull;

Expand All @@ -37,7 +39,10 @@
*/
@SuppressWarnings("SameParameterValue")
public class Cli {
private static final Logger LOG = LoggerFactory.getLogger(Cli.class);
public static final Map<String, Command> COMMANDS;
public static final int EXIT_SUCCESS = 0;
public static final int EXIT_FAILURE = 1;

static {
COMMANDS = Map.of(
Expand All @@ -50,18 +55,18 @@ public class Cli {
);
}

private final PrintStream err;
private final Map<String, Command> myCommands;
private final Consumer<Integer> exitSupplier;

public Cli() {
this(System.err, COMMANDS); // NOSONAR
this(COMMANDS, System::exit); // NOSONAR
}

@SuppressWarnings("SameParameterValue")
Cli(final PrintStream err,
final Map<String, Command> myCommands) {
this.err = requireNonNull(err);
Cli(final Map<String, Command> myCommands,
final Consumer<Integer> exitSupplier) {
this.myCommands = requireNonNull(myCommands);
this.exitSupplier = requireNonNull(exitSupplier);
}

public static void main(final String[] args) {
Expand All @@ -78,12 +83,19 @@ public void run(String[] args) {
args = new String[0];
}

final Command command = myCommands.get(commandName);
if (command != null) {
command.execute(args);
try {
final Command command = myCommands.get(commandName);
if (command != null) {
command.execute(args);
exitSupplier.accept(EXIT_SUCCESS);
}
else {
throw new CliException("Unknown command \"" + commandName + "\" for \"drasyl\".");
}
}
else {
err.println("ERR: Unknown command \"" + commandName + "\" for \"drasyl\".");
catch (final CliException e) {
LOG.error("", e);
exitSupplier.accept(EXIT_FAILURE);
}
}
}
Expand Up @@ -28,6 +28,7 @@
import org.apache.commons.cli.ParseException;
import org.drasyl.DrasylConfig;
import org.drasyl.DrasylNode;
import org.drasyl.cli.CliException;
import org.drasyl.util.logging.Logger;
import org.drasyl.util.logging.LoggerFactory;

Expand Down Expand Up @@ -77,8 +78,7 @@ public void execute(final String[] args) {
}
}
catch (final ParseException e) {
err.println("ERR: Unable to parse args.");
e.printStackTrace(err);
throw new CliException(e);
}
}

Expand Down

0 comments on commit 302975e

Please sign in to comment.