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

Fix a bug that allowed IP V6 addresses to be resolved instead of IP V4. #3184

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 5 additions & 2 deletions app/src/main/java/com/eveningoutpost/dexdrip/utils/Mdns.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,17 @@ public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
locked_until = 0;
}

private boolean isIpV4Addresses(String address) {
return !address.contains(":");
}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {

final InetAddress host = serviceInfo.getHost();
final String address = host.getHostAddress();
UserError.Log.d(TAG, serviceInfo.getServiceName() + " Resolved address = " + address);
UserError.Log.d(TAG, serviceInfo.getServiceName() + " Resolved address = " + address );
final String short_name = shortenName(serviceInfo.getServiceName().toLowerCase());
if (!address.contains(":") || (iplookup.get(short_name) == null) || (JoH.msSince(iplookup.get(short_name).received) > 60000)) {
if (isIpV4Addresses(address) && ((iplookup.get(short_name) == null) || (JoH.msSince(iplookup.get(short_name).received) > 60000))) {
iplookup.put(short_name, new LookUpInfo(address, JoH.tsl(), serviceInfo));
} else {
UserError.Log.d(TAG, "Skipping overwrite of " + short_name + " with " + address + " due to ipv4 priority");
Expand Down
Loading