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

Discovery server port 8041 default #128

Merged
merged 1 commit into from
Oct 11, 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 @@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added
- Better troubleshooting for connection problems.
[#127](https://github.com/scionproto-contrib/jpan/pull/127)
- Auto-add port to discovery server setting + better error message.
[#128](https://github.com/scionproto-contrib/jpan/pull/128)

### Fixed
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,9 @@ If you have a topology file, you can specify it via environment variable `SCION_
or via Java property `org.scion.bootstrap.topoFile`:

```java
System.setProperty(Constants.PROPERTY_BOOTSTRAP_HOST, "youtTopoFile.json");
System.setProperty(Constants.PROPERTY_BOOTSTRAP_HOST, "yourTopoFile.json");
```





### Local testbed (scionproto) does not contain any path

A common problem is that the certificates of the testbed have expired (default validity: 3 days).
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/scion/jpan/internal/ScionBootstrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class ScionBootstrapper {
private final GlobalTopology world;

protected ScionBootstrapper(String topologyServiceAddress) {
this.topologyResource = topologyServiceAddress;
this.topologyResource = IPHelper.ensurePortOrDefault(topologyServiceAddress, 8041);
this.localAS = initLocal();
this.world = initGlobal();
}
Expand Down Expand Up @@ -142,7 +142,7 @@ public String fetchFile(String resource) {
return fetchFile(url);
} catch (IOException e) {
throw new ScionRuntimeException(
"While fetching resource '" + resource + "' from " + topologyResource);
"While fetching resource '" + resource + "' from " + topologyResource, e);
}
}

Expand Down
28 changes: 20 additions & 8 deletions src/test/java/org/scion/jpan/api/ScionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,9 @@ void defaultService_bootstrapAddress() {

MockNetwork.startTiny(MockNetwork.Mode.BOOTSTRAP);
try {
String host;
MockBootstrapServer mts = MockNetwork.getTopoServer();
if (mts.getAddress().getAddress() instanceof Inet6Address) {
host = "[" + mts.getAddress().getAddress().getHostAddress() + "]";
} else {
host = mts.getAddress().getHostString();
}
host += ":" + mts.getAddress().getPort();
InetSocketAddress discoveryAddress = MockNetwork.getTopoServer().getAddress();
String host = ToStringUtil.toString(discoveryAddress.getAddress());
host += ":" + discoveryAddress.getPort();

System.setProperty(Constants.PROPERTY_BOOTSTRAP_HOST, host);
ScionService service = Scion.defaultService();
Expand All @@ -164,6 +159,23 @@ void defaultService_bootstrapAddress() {
}
}

@Test
void defaultService_bootstrapAddress_defaultPort() {
MockNetwork.startTiny(MockNetwork.Mode.BOOTSTRAP);
try {
InetSocketAddress discoveryAddress = MockNetwork.getTopoServer().getAddress();
String host = ToStringUtil.toString(discoveryAddress.getAddress());
// We do _not_ add a port here.

System.setProperty(Constants.PROPERTY_BOOTSTRAP_HOST, host);
Throwable t = assertThrows(ScionRuntimeException.class, Scion::defaultService);
// Check that the default port 8041 was added
assertTrue(t.getMessage().contains(host + ":8041"));
} finally {
MockNetwork.stopTiny();
}
}

@Test
void defaultService_bootstrapNaptrRecord() {
long dstIA = ScionUtil.parseIA("1-ff00:0:112");
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/scion/jpan/demo/util/ToStringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,14 @@ public static String pathLong(byte[] raw) {
ph.read(ByteBuffer.wrap(raw));
return ph.toString();
}

public static String toString(InetAddress address) {
String host;
if (address instanceof Inet6Address) {
host = "[" + address.getHostAddress() + "]";
} else {
host = address.toString().substring(1);
}
return host;
}
}