Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged SCION_DAEMON property #39

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
[#33](https://github.com/netsec-ethz/scion-java-client/pull/33)
- Fixed traffic class not set. [#36](https://github.com/netsec-ethz/scion-java-client/pull/36)
- Fixed handling of channel options. [#37](https://github.com/netsec-ethz/scion-java-client/pull/37)
- Merged SCION_DAEMON_HOST and SCION_DAEMON_PORT into a single SCION_DAEMON property.
[#39](https://github.com/netsec-ethz/scion-java-client/pull/39)

### Removed

Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,12 @@ attempt to get network information in the following order until it succeeds:
The reason that the daemon is checked last is that it has a default setting (`localhost:30255`)
while the other options are skipped if no property or environment variable is defined.

| Option | Java property | Environment variable | Default value |
|-------------------------------------|----------------------------------|------------------------------|---------------|
| Daemon host | `org.scion.daemon.host` | `SCION_DAEMON_HOST` | localhost |
| Daemon port | `org.scion.daemon.port` | `SCION_DAEMON_PORT` | 30255 |
| Bootstrap topology file path | `org.scion.bootstrap.topoFile` | `SCION_BOOTSTRAP_TOPO_FILE` | |
| Bootstrap server host | `org.scion.bootstrap.host` | `SCION_BOOTSTRAP_HOST` | |
| Bootstrap DNS NAPTR entry host name | `org.scion.bootstrap.naptr.name` | `SCION_BOOTSTRAP_NAPTR_NAME` | |
| Option | Java property | Environment variable | Default value |
|-------------------------------------|----------------------------------|------------------------------|-----------------|
| Daemon port | `org.scion.daemon.port` | `SCION_DAEMON` | localhost:30255 |
| Bootstrap topology file path | `org.scion.bootstrap.topoFile` | `SCION_BOOTSTRAP_TOPO_FILE` | |
| Bootstrap server host | `org.scion.bootstrap.host` | `SCION_BOOTSTRAP_HOST` | |
| Bootstrap DNS NAPTR entry host name | `org.scion.bootstrap.naptr.name` | `SCION_BOOTSTRAP_NAPTR_NAME` | |

### Other

Expand Down
9 changes: 3 additions & 6 deletions src/main/java/org/scion/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
package org.scion;

public final class Constants {
public static final String PROPERTY_DAEMON_HOST = "org.scion.daemon.host";
public static final String ENV_DAEMON_HOST = "SCION_DAEMON_HOST";
public static final String DEFAULT_DAEMON_HOST = "localhost";
public static final String PROPERTY_DAEMON_PORT = "org.scion.daemon.port";
public static final String ENV_DAEMON_PORT = "SCION_DAEMON_PORT";
public static final String DEFAULT_DAEMON_PORT = "30255";
public static final String PROPERTY_DAEMON = "org.scion.daemon";
public static final String ENV_DAEMON = "SCION_DAEMON";
public static final String DEFAULT_DAEMON = "localhost:30255";

/** Address of bootstrap server (http), e.g. 192.168.42.42 */
public static final String PROPERTY_BOOTSTRAP_HOST = "org.scion.bootstrap.host";
Expand Down
16 changes: 5 additions & 11 deletions src/main/java/org/scion/ScionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@

package org.scion;

import static org.scion.Constants.DEFAULT_DAEMON_HOST;
import static org.scion.Constants.DEFAULT_DAEMON_PORT;
import static org.scion.Constants.DEFAULT_DAEMON;
import static org.scion.Constants.ENV_BOOTSTRAP_HOST;
import static org.scion.Constants.ENV_BOOTSTRAP_NAPTR_NAME;
import static org.scion.Constants.ENV_BOOTSTRAP_TOPO_FILE;
import static org.scion.Constants.ENV_DAEMON_HOST;
import static org.scion.Constants.ENV_DAEMON_PORT;
import static org.scion.Constants.ENV_DAEMON;
import static org.scion.Constants.PROPERTY_BOOTSTRAP_HOST;
import static org.scion.Constants.PROPERTY_BOOTSTRAP_NAPTR_NAME;
import static org.scion.Constants.PROPERTY_BOOTSTRAP_TOPO_FILE;
import static org.scion.Constants.PROPERTY_DAEMON_HOST;
import static org.scion.Constants.PROPERTY_DAEMON_PORT;
import static org.scion.Constants.PROPERTY_DAEMON;

import io.grpc.*;
import java.io.IOException;
Expand Down Expand Up @@ -160,12 +157,9 @@ static ScionService defaultService() {
}

// try daemon
String daemonHost =
ScionUtil.getPropertyOrEnv(PROPERTY_DAEMON_HOST, ENV_DAEMON_HOST, DEFAULT_DAEMON_HOST);
String daemonPort =
ScionUtil.getPropertyOrEnv(PROPERTY_DAEMON_PORT, ENV_DAEMON_PORT, DEFAULT_DAEMON_PORT);
String daemon = ScionUtil.getPropertyOrEnv(PROPERTY_DAEMON, ENV_DAEMON, DEFAULT_DAEMON);
try {
defaultService = new ScionService(daemonHost + ":" + daemonPort, Mode.DAEMON);
defaultService = new ScionService(daemon, Mode.DAEMON);
return defaultService;
} catch (ScionRuntimeException e) {
throw new ScionRuntimeException(
Expand Down
9 changes: 3 additions & 6 deletions src/test/java/org/scion/api/ScionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class ScionTest {

@BeforeAll
public static void beforeAll() {
System.clearProperty(Constants.PROPERTY_DAEMON_HOST);
System.clearProperty(Constants.PROPERTY_DAEMON_PORT);
System.clearProperty(Constants.PROPERTY_DAEMON);
System.clearProperty(Constants.PROPERTY_BOOTSTRAP_HOST);
System.clearProperty(Constants.PROPERTY_BOOTSTRAP_NAPTR_NAME);
System.clearProperty(Constants.PROPERTY_BOOTSTRAP_TOPO_FILE);
Expand All @@ -66,8 +65,7 @@ public void beforeEach() {

@AfterEach
public void afterEach() throws IOException {
System.clearProperty(Constants.PROPERTY_DAEMON_HOST);
System.clearProperty(Constants.PROPERTY_DAEMON_PORT);
System.clearProperty(Constants.PROPERTY_DAEMON);
System.clearProperty(Constants.PROPERTY_BOOTSTRAP_HOST);
System.clearProperty(Constants.PROPERTY_BOOTSTRAP_NAPTR_NAME);
System.clearProperty(Constants.PROPERTY_BOOTSTRAP_TOPO_FILE);
Expand All @@ -81,8 +79,7 @@ void defaultService_daemon() throws IOException {
InetSocketAddress dstAddress = new InetSocketAddress("::1", 12345);

MockDaemon.createAndStartDefault();
System.setProperty(Constants.PROPERTY_DAEMON_HOST, "[::1]");
System.setProperty(Constants.PROPERTY_DAEMON_PORT, String.valueOf(DEFAULT_PORT));
System.setProperty(Constants.PROPERTY_DAEMON, "[::1]:" + DEFAULT_PORT);
try {
ScionService service = Scion.defaultService();
RequestPath path = service.getPaths(dstIA, dstAddress).get(0);
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/org/scion/demo/DemoTopology.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ static void shutDown() {
}

private static void configurePathService(String address, int port) {
System.setProperty(Constants.PROPERTY_DAEMON_HOST, address);
System.setProperty(Constants.PROPERTY_DAEMON_PORT, String.valueOf(port));
System.setProperty(Constants.PROPERTY_DAEMON, address + ":" + port);
}
}
10 changes: 2 additions & 8 deletions src/test/java/org/scion/demo/ScmpTracerouteDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ public static void main(String[] args) throws IOException, InterruptedException
{
// System.setProperty(Constants.PROPERTY_BOOTSTRAP_TOPO_FILE,
// "topologies/scionproto-tiny-110.json");
System.setProperty(
Constants.PROPERTY_DAEMON_HOST, toHost(DemoConstants.daemon1111_minimal));
System.setProperty(
Constants.PROPERTY_DAEMON_PORT, toPort(DemoConstants.daemon1111_minimal));
System.setProperty(Constants.PROPERTY_DAEMON, DemoConstants.daemon1111_minimal);
ScmpTracerouteDemo demo = new ScmpTracerouteDemo();
demo.runDemo(DemoConstants.ia110);
break;
Expand All @@ -71,10 +68,7 @@ public static void main(String[] args) throws IOException, InterruptedException
{
// System.setProperty(Constants.PROPERTY_BOOTSTRAP_TOPO_FILE,
// "topologies/minimal/ASff00_0_1111/topology.json");
System.setProperty(
Constants.PROPERTY_DAEMON_HOST, toHost(DemoConstants.daemon1111_minimal));
System.setProperty(
Constants.PROPERTY_DAEMON_PORT, toPort(DemoConstants.daemon1111_minimal));
System.setProperty(Constants.PROPERTY_DAEMON, DemoConstants.daemon1111_minimal);
ScmpTracerouteDemo demo = new ScmpTracerouteDemo();
demo.runDemo(DemoConstants.ia211);
break;
Expand Down
6 changes: 2 additions & 4 deletions src/test/java/org/scion/testutil/MockDaemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public class MockDaemon implements AutoCloseable {
};

private static void setEnvironment() {
System.setProperty(Constants.PROPERTY_DAEMON_HOST, DEFAULT_IP);
System.setProperty(Constants.PROPERTY_DAEMON_PORT, "" + DEFAULT_PORT);
System.setProperty(Constants.PROPERTY_DAEMON, DEFAULT_IP + ":" + DEFAULT_PORT);
}

public static MockDaemon createForBorderRouter(List<InetSocketAddress> borderRouter) {
Expand All @@ -83,8 +82,7 @@ public static void closeDefault() throws IOException {
DEFAULT.close();
DEFAULT = null;
}
System.clearProperty(Constants.PROPERTY_DAEMON_HOST);
System.clearProperty(Constants.PROPERTY_DAEMON_PORT);
System.clearProperty(Constants.PROPERTY_DAEMON);
}

private MockDaemon(InetSocketAddress address) {
Expand Down