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

topofile without discovery #126

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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Inherit DatagramChannel
- Consider using https://github.com/ascopes/protobuf-maven-plugin (more up to date)

### Fixed
- Do not immediately fail if discovery server is missing in topo file.
[#126](https://github.com/scionproto-contrib/jpan/pull/126)

## [0.3.0] - 2024-10-09

### Added
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,14 @@ 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 port, IP, or IP:port | `org.scion.daemon` | `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` | |
| List of DNS search domains | `org.scion.dnsSearchDomains` | `SCION_DNS_SEARCH_DOMAINS` | |
| Use OS search domains, e.g. /etc/resolv.conf | `org.scion.test.useOsSearchDomains` | `SCION_USE_OS_SEARCH_DOMAINS` | true |
| Option | Java property | Environment variable | Default value |
|-----------------------------------------------|-------------------------------------|-------------------------------|-----------------|
| Daemon port, IP, or IP:port | `org.scion.daemon` | `SCION_DAEMON` | localhost:30255 |
| Bootstrap topology file path | `org.scion.bootstrap.topoFile` | `SCION_BOOTSTRAP_TOPO_FILE` | |
| Bootstrap server host + port (typically 8041) | `org.scion.bootstrap.host` | `SCION_BOOTSTRAP_HOST` | |
| Bootstrap DNS NAPTR entry host name | `org.scion.bootstrap.naptr.name` | `SCION_BOOTSTRAP_NAPTR_NAME` | |
| List of DNS search domains | `org.scion.dnsSearchDomains` | `SCION_DNS_SEARCH_DOMAINS` | |
| Use OS search domains, e.g. /etc/resolv.conf | `org.scion.test.useOsSearchDomains` | `SCION_USE_OS_SEARCH_DOMAINS` | true |


### DNS
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/scion/jpan/internal/LocalTopology.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ private void parseTopologyFile(String topologyFile) {
JsonObject cs = e.getValue().getAsJsonObject();
controlServices.add(new ServiceNode(e.getKey(), cs.get("addr").getAsString()));
}
JsonObject dss = safeGet(o, "discovery_service").getAsJsonObject();
for (Map.Entry<String, JsonElement> e : dss.entrySet()) {
JsonObject ds = e.getValue().getAsJsonObject();
discoveryServices.add(new ServiceNode(e.getKey(), ds.get("addr").getAsString()));
JsonElement dss = o.get("discovery_service");
if (dss != null) {
for (Map.Entry<String, JsonElement> e : dss.getAsJsonObject().entrySet()) {
JsonObject ds = e.getValue().getAsJsonObject();
discoveryServices.add(new ServiceNode(e.getKey(), ds.get("addr").getAsString()));
}
}
JsonArray attr = safeGet(o, "attributes").getAsJsonArray();
for (int i = 0; i < attr.size(); i++) {
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/org/scion/jpan/api/ScionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,24 @@ void defaultService_bootstrapTopoFile() {
}
}

@Test
void defaultService_bootstrapTopoFile_withoutDiscovery() {
long dstIA = ScionUtil.parseIA("1-ff00:0:112");
InetSocketAddress dstAddress = new InetSocketAddress("::1", 12345);
MockNetwork.startTiny(MockNetwork.Mode.AS_ONLY);
try {
// String file = "topologies/scionproto-tiny/topology-110.json"
String file = "topologies/no-discovery.json";
System.setProperty(Constants.PROPERTY_BOOTSTRAP_TOPO_FILE, file);
ScionService service = Scion.defaultService();
Path path = service.getPaths(dstIA, dstAddress).get(0);
assertNotNull(path);
assertEquals(0, MockDaemon.getAndResetCallCount()); // Daemon is not used!
} finally {
MockNetwork.stopTiny();
}
}

@Test
void defaultService_bootstrapTopoFile_IOError_NoSuchFile() {
System.setProperty(Constants.PROPERTY_BOOTSTRAP_TOPO_FILE, TOPO_FILE + ".x");
Expand Down
43 changes: 43 additions & 0 deletions src/test/resources/topologies/no-discovery.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"attributes": [
"core"
],
"isd_as": "1-ff00:0:110",
"mtu": 1400,
"control_service": {
"cs1-ff00_0_110-1": {
"addr": "127.0.0.11:31000"
}
},
"border_routers": {
"br1-ff00_0_110-1": {
"internal_addr": "127.0.0.9:31002",
"interfaces": {
"1": {
"underlay": {
"public": "127.0.0.4:50000",
"remote": "127.0.0.5:50000"
},
"isd_as": "1-ff00:0:111",
"link_to": "child",
"mtu": 1280
}
}
},
"br1-ff00_0_110-2": {
"internal_addr": "127.0.0.10:31004",
"interfaces": {
"2": {
"underlay": {
"public": "[fd00:f00d:cafe::7f00:4]:50000",
"remote": "[fd00:f00d:cafe::7f00:5]:50000"
},
"isd_as": "1-ff00:0:112",
"link_to": "child",
"mtu": 1472
}
}
}
}
}