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

remove getHostName() #106

Merged
merged 1 commit into from
Jul 16, 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
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 String getHostName() {
return hostName;
return ipAddress.getHostName();

Check warning on line 56 in src/main/java/org/scion/jpan/ScionAddress.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/scion/jpan/ScionAddress.java#L56

Added line #L56 was not covered by tests
}

public InetAddress getInetAddress() {
Expand Down