Rename localIp/remoteIp fields to localAddress/remoteAddress to prepare for DNS names

This commit is contained in:
Cameron Gutman
2017-09-09 12:47:23 -07:00
parent d4f8d8f689
commit 60cd951774
4 changed files with 28 additions and 29 deletions
@@ -1,6 +1,5 @@
package com.limelight.computers;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.LinkedList;
@@ -63,8 +62,8 @@ public class ComputerDatabaseManager {
ContentValues values = new ContentValues();
values.put(COMPUTER_NAME_COLUMN_NAME, details.name);
values.put(COMPUTER_UUID_COLUMN_NAME, details.uuid.toString());
values.put(LOCAL_IP_COLUMN_NAME, ADDRESS_PREFIX+details.localIp.getHostAddress());
values.put(REMOTE_IP_COLUMN_NAME, ADDRESS_PREFIX+details.remoteIp.getHostAddress());
values.put(LOCAL_IP_COLUMN_NAME, ADDRESS_PREFIX+details.localAddress.getHostAddress());
values.put(REMOTE_IP_COLUMN_NAME, ADDRESS_PREFIX+details.remoteAddress.getHostAddress());
values.put(MAC_COLUMN_NAME, details.macAddress);
return -1 != computerDb.insertWithOnConflict(COMPUTER_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
}
@@ -87,14 +86,14 @@ public class ComputerDatabaseManager {
// too. To disambiguate, we'll need to prefix them with a string
// greater than the allowable IP address length.
try {
details.localIp = InetAddress.getByAddress(c.getBlob(2));
details.localAddress = InetAddress.getByAddress(c.getBlob(2));
LimeLog.warning("DB: Legacy local address for "+details.name);
} catch (UnknownHostException e) {
// This is probably a hostname/address with the prefix string
String stringData = c.getString(2);
if (stringData.startsWith(ADDRESS_PREFIX)) {
try {
details.localIp = InetAddress.getByName(c.getString(2).substring(ADDRESS_PREFIX.length()));
details.localAddress = InetAddress.getByName(c.getString(2).substring(ADDRESS_PREFIX.length()));
} catch (UnknownHostException e1) {
e1.printStackTrace();
}
@@ -105,14 +104,14 @@ public class ComputerDatabaseManager {
}
try {
details.remoteIp = InetAddress.getByAddress(c.getBlob(3));
details.remoteAddress = InetAddress.getByAddress(c.getBlob(3));
LimeLog.warning("DB: Legacy remote address for "+details.name);
} catch (UnknownHostException e) {
// This is probably a hostname/address with the prefix string
String stringData = c.getString(3);
if (stringData.startsWith(ADDRESS_PREFIX)) {
try {
details.remoteIp = InetAddress.getByName(c.getString(3).substring(ADDRESS_PREFIX.length()));
details.remoteAddress = InetAddress.getByName(c.getString(3).substring(ADDRESS_PREFIX.length()));
} catch (UnknownHostException e1) {
e1.printStackTrace();
}
@@ -138,7 +137,7 @@ public class ComputerDatabaseManager {
ComputerDetails details = getComputerFromCursor(c);
// If a field is corrupt or missing, skip the database entry
if (details.uuid == null || details.localIp == null || details.remoteIp == null ||
if (details.uuid == null || details.localAddress == null || details.remoteAddress == null ||
details.macAddress == null) {
continue;
}
@@ -164,7 +163,7 @@ public class ComputerDatabaseManager {
c.close();
// If a field is corrupt or missing, delete the database entry
if (details.uuid == null || details.localIp == null || details.remoteIp == null ||
if (details.uuid == null || details.localAddress == null || details.remoteAddress == null ||
details.macAddress == null) {
deleteComputer(details.name);
return null;