Skip to content

Commit

Permalink
remove getHostName() (#106)
Browse files Browse the repository at this point in the history
Co-authored-by: Tilmann Zäschke <tilmann.zaeschke@inf.ethz.ch>
  • Loading branch information
tzaeschke and Tilmann Zäschke authored Jul 16, 2024
1 parent 3e77c32 commit aea492b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed
- Remove use of 0.0.0.0 and "::". [#103](https://github.com/scionproto-contrib/jpan/pull/103)
- Remove use of getHostName() in ScionAddress. [#106](https://github.com/scionproto-contrib/jpan/pull/106)

### Removed
- Removed some useless IP printing functions.
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/org/scion/jpan/ScionAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,21 @@
@Deprecated // This will be made package private in 0.3.0
public class ScionAddress {
private final long isdAs;
private final String hostName;
private final InetAddress ipAddress;

private ScionAddress(long isdAs, String hostName, InetAddress ip) {
this.hostName = hostName;
private ScionAddress(long isdAs, InetAddress ip) {
this.ipAddress = ip;
this.isdAs = isdAs;
}

static ScionAddress create(long isdAs, InetAddress address) {
return new ScionAddress(isdAs, address.getHostName(), address);
return new ScionAddress(isdAs, address);
}

static ScionAddress create(long isdAs, String hostName, byte[] ipBytes) {
try {
InetAddress ip = InetAddress.getByAddress(hostName, ipBytes);
return new ScionAddress(isdAs, hostName, ip);
return new ScionAddress(isdAs, ip);
} catch (UnknownHostException e) {
// This should never happen because we always call getByName() with an IP address
throw new ScionRuntimeException(e);
Expand All @@ -55,7 +53,7 @@ public long getIsdAs() {
}

public String getHostName() {
return hostName;
return ipAddress.getHostName();
}

public InetAddress getInetAddress() {
Expand Down

0 comments on commit aea492b

Please sign in to comment.