mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-23 16:56:41 +00:00
Use try-with-resources
This commit is contained in:
committed by
Cameron Gutman
parent
51594e00b8
commit
a96e508ffb
@@ -48,6 +48,12 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
encoding "UTF-8"
|
||||||
|
sourceCompatibility JavaVersion.VERSION_11
|
||||||
|
targetCompatibility JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
|
||||||
lint {
|
lint {
|
||||||
disable 'MissingTranslation'
|
disable 'MissingTranslation'
|
||||||
lintConfig file('lint.xml')
|
lintConfig file('lint.xml')
|
||||||
@@ -129,6 +135,7 @@ dependencies {
|
|||||||
implementation 'org.jcodec:jcodec:0.2.3'
|
implementation 'org.jcodec:jcodec:0.2.3'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
|
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
|
||||||
implementation 'com.squareup.okio:okio:1.17.5'
|
implementation 'com.squareup.okio:okio:1.17.5'
|
||||||
|
// 3.5.8 requires minSdk 19, uses StandardCharsets.UTF_8 internally
|
||||||
implementation 'org.jmdns:jmdns:3.5.7'
|
implementation 'org.jmdns:jmdns:3.5.7'
|
||||||
implementation 'com.github.cgutman:ShieldControllerExtensions:1.0'
|
implementation 'com.github.cgutman:ShieldControllerExtensions:1.0'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,14 +67,12 @@ public class AndroidCryptoProvider implements LimelightCryptoProvider {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try (final FileInputStream fin = new FileInputStream(f)) {
|
||||||
FileInputStream fin = new FileInputStream(f);
|
|
||||||
byte[] fileData = new byte[(int) f.length()];
|
byte[] fileData = new byte[(int) f.length()];
|
||||||
if (fin.read(fileData) != f.length()) {
|
if (fin.read(fileData) != f.length()) {
|
||||||
// Failed to read
|
// Failed to read
|
||||||
fileData = null;
|
fileData = null;
|
||||||
}
|
}
|
||||||
fin.close();
|
|
||||||
return fileData;
|
return fileData;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return null;
|
return null;
|
||||||
@@ -160,32 +158,28 @@ public class AndroidCryptoProvider implements LimelightCryptoProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveCertKeyPair() {
|
private void saveCertKeyPair() {
|
||||||
try {
|
try (final FileOutputStream certOut = new FileOutputStream(certFile);
|
||||||
FileOutputStream certOut = new FileOutputStream(certFile);
|
final FileOutputStream keyOut = new FileOutputStream(keyFile)
|
||||||
FileOutputStream keyOut = new FileOutputStream(keyFile);
|
) {
|
||||||
|
|
||||||
// Write the certificate in OpenSSL PEM format (important for the server)
|
// Write the certificate in OpenSSL PEM format (important for the server)
|
||||||
StringWriter strWriter = new StringWriter();
|
StringWriter strWriter = new StringWriter();
|
||||||
JcaPEMWriter pemWriter = new JcaPEMWriter(strWriter);
|
try (final JcaPEMWriter pemWriter = new JcaPEMWriter(strWriter)) {
|
||||||
pemWriter.writeObject(cert);
|
pemWriter.writeObject(cert);
|
||||||
pemWriter.close();
|
}
|
||||||
|
|
||||||
// Line endings MUST be UNIX for the PC to accept the cert properly
|
// Line endings MUST be UNIX for the PC to accept the cert properly
|
||||||
OutputStreamWriter certWriter = new OutputStreamWriter(certOut);
|
try (final OutputStreamWriter certWriter = new OutputStreamWriter(certOut)) {
|
||||||
String pemStr = strWriter.getBuffer().toString();
|
String pemStr = strWriter.getBuffer().toString();
|
||||||
for (int i = 0; i < pemStr.length(); i++) {
|
for (int i = 0; i < pemStr.length(); i++) {
|
||||||
char c = pemStr.charAt(i);
|
char c = pemStr.charAt(i);
|
||||||
if (c != '\r')
|
if (c != '\r')
|
||||||
certWriter.append(c);
|
certWriter.append(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
certWriter.close();
|
|
||||||
|
|
||||||
// Write the private out in PKCS8 format
|
// Write the private out in PKCS8 format
|
||||||
keyOut.write(key.getEncoded());
|
keyOut.write(key.getEncoded());
|
||||||
|
|
||||||
certOut.close();
|
|
||||||
keyOut.close();
|
|
||||||
|
|
||||||
LimeLog.info("Saved generated key pair to disk");
|
LimeLog.info("Saved generated key pair to disk");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// This isn't good because it means we'll have
|
// This isn't good because it means we'll have
|
||||||
|
|||||||
@@ -887,8 +887,7 @@ public class MediaCodecHelper {
|
|||||||
|
|
||||||
public static String readCpuinfo() throws Exception {
|
public static String readCpuinfo() throws Exception {
|
||||||
StringBuilder cpuInfo = new StringBuilder();
|
StringBuilder cpuInfo = new StringBuilder();
|
||||||
BufferedReader br = new BufferedReader(new FileReader(new File("/proc/cpuinfo")));
|
try (final BufferedReader br = new BufferedReader(new FileReader(new File("/proc/cpuinfo")))) {
|
||||||
try {
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int ch = br.read();
|
int ch = br.read();
|
||||||
if (ch == -1)
|
if (ch == -1)
|
||||||
@@ -897,8 +896,6 @@ public class MediaCodecHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return cpuInfo.toString();
|
return cpuInfo.toString();
|
||||||
} finally {
|
|
||||||
br.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,28 +136,26 @@ public class ComputerDatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ComputerDetails> getAllComputers() {
|
public List<ComputerDetails> getAllComputers() {
|
||||||
Cursor c = computerDb.rawQuery("SELECT * FROM "+COMPUTER_TABLE_NAME, null);
|
try (final Cursor c = computerDb.rawQuery("SELECT * FROM "+COMPUTER_TABLE_NAME, null)) {
|
||||||
LinkedList<ComputerDetails> computerList = new LinkedList<>();
|
LinkedList<ComputerDetails> computerList = new LinkedList<>();
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
computerList.add(getComputerFromCursor(c));
|
computerList.add(getComputerFromCursor(c));
|
||||||
|
}
|
||||||
|
return computerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.close();
|
|
||||||
|
|
||||||
return computerList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputerDetails getComputerByUUID(String uuid) {
|
public ComputerDetails getComputerByUUID(String uuid) {
|
||||||
Cursor c = computerDb.query(COMPUTER_TABLE_NAME, null, COMPUTER_UUID_COLUMN_NAME+"=?", new String[]{ uuid }, null, null, null);
|
try (final Cursor c = computerDb.query(
|
||||||
if (!c.moveToFirst()) {
|
COMPUTER_TABLE_NAME, null, COMPUTER_UUID_COLUMN_NAME+"=?",
|
||||||
// No matching computer
|
new String[]{ uuid }, null, null, null)
|
||||||
c.close();
|
) {
|
||||||
return null;
|
if (!c.moveToFirst()) {
|
||||||
|
// No matching computer
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getComputerFromCursor(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputerDetails details = getComputerFromCursor(c);
|
|
||||||
c.close();
|
|
||||||
|
|
||||||
return details;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -849,18 +849,12 @@ public class ComputerManagerService extends Service {
|
|||||||
if (!appList.isEmpty() &&
|
if (!appList.isEmpty() &&
|
||||||
(!list.isEmpty() || emptyAppListResponses >= EMPTY_LIST_THRESHOLD)) {
|
(!list.isEmpty() || emptyAppListResponses >= EMPTY_LIST_THRESHOLD)) {
|
||||||
// Open the cache file
|
// Open the cache file
|
||||||
OutputStream cacheOut = null;
|
try (final OutputStream cacheOut = CacheHelper.openCacheFileForOutput(
|
||||||
try {
|
getCacheDir(), "applist", computer.uuid)
|
||||||
cacheOut = CacheHelper.openCacheFileForOutput(getCacheDir(), "applist", computer.uuid);
|
) {
|
||||||
CacheHelper.writeStringToOutputStream(cacheOut, appList);
|
CacheHelper.writeStringToOutputStream(cacheOut, appList);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (cacheOut != null) {
|
|
||||||
cacheOut.close();
|
|
||||||
}
|
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset empty count if it wasn't empty this time
|
// Reset empty count if it wasn't empty this time
|
||||||
|
|||||||
@@ -33,12 +33,11 @@ public class IdentityManager {
|
|||||||
private static String loadUniqueId(Context c) {
|
private static String loadUniqueId(Context c) {
|
||||||
// 2 Hex digits per byte
|
// 2 Hex digits per byte
|
||||||
char[] uid = new char[UID_SIZE_IN_BYTES * 2];
|
char[] uid = new char[UID_SIZE_IN_BYTES * 2];
|
||||||
InputStreamReader reader = null;
|
|
||||||
LimeLog.info("Reading UID from disk");
|
LimeLog.info("Reading UID from disk");
|
||||||
try {
|
try (final InputStreamReader reader =
|
||||||
reader = new InputStreamReader(c.openFileInput(UNIQUE_ID_FILE_NAME));
|
new InputStreamReader(c.openFileInput(UNIQUE_ID_FILE_NAME))
|
||||||
if (reader.read(uid) != UID_SIZE_IN_BYTES * 2)
|
) {
|
||||||
{
|
if (reader.read(uid) != UID_SIZE_IN_BYTES * 2) {
|
||||||
LimeLog.severe("UID file data is truncated");
|
LimeLog.severe("UID file data is truncated");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -50,12 +49,6 @@ public class IdentityManager {
|
|||||||
LimeLog.severe("Error while reading UID file");
|
LimeLog.severe("Error while reading UID file");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
|
||||||
if (reader != null) {
|
|
||||||
try {
|
|
||||||
reader.close();
|
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,20 +57,14 @@ public class IdentityManager {
|
|||||||
LimeLog.info("Generating new UID");
|
LimeLog.info("Generating new UID");
|
||||||
String uidStr = String.format((Locale)null, "%016x", new Random().nextLong());
|
String uidStr = String.format((Locale)null, "%016x", new Random().nextLong());
|
||||||
|
|
||||||
OutputStreamWriter writer = null;
|
try (final OutputStreamWriter writer =
|
||||||
try {
|
new OutputStreamWriter(c.openFileOutput(UNIQUE_ID_FILE_NAME, 0))
|
||||||
writer = new OutputStreamWriter(c.openFileOutput(UNIQUE_ID_FILE_NAME, 0));
|
) {
|
||||||
writer.write(uidStr);
|
writer.write(uidStr);
|
||||||
LimeLog.info("UID written to disk");
|
LimeLog.info("UID written to disk");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LimeLog.severe("Error while writing UID file");
|
LimeLog.severe("Error while writing UID file");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
|
||||||
if (writer != null) {
|
|
||||||
try {
|
|
||||||
writer.close();
|
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can return a UID even if I/O fails
|
// We can return a UID even if I/O fails
|
||||||
|
|||||||
@@ -68,37 +68,34 @@ public class LegacyDatabaseReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static List<ComputerDetails> getAllComputers(SQLiteDatabase db) {
|
private static List<ComputerDetails> getAllComputers(SQLiteDatabase db) {
|
||||||
Cursor c = db.rawQuery("SELECT * FROM " + COMPUTER_TABLE_NAME, null);
|
try (final Cursor c = db.rawQuery("SELECT * FROM " + COMPUTER_TABLE_NAME, null)) {
|
||||||
LinkedList<ComputerDetails> computerList = new LinkedList<>();
|
LinkedList<ComputerDetails> computerList = new LinkedList<>();
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
ComputerDetails details = getComputerFromCursor(c);
|
ComputerDetails details = getComputerFromCursor(c);
|
||||||
|
|
||||||
// If a critical field is corrupt or missing, skip the database entry
|
// If a critical field is corrupt or missing, skip the database entry
|
||||||
if (details.uuid == null) {
|
if (details.uuid == null) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
computerList.add(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
computerList.add(details);
|
return computerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.close();
|
|
||||||
|
|
||||||
return computerList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ComputerDetails> migrateAllComputers(Context c) {
|
public static List<ComputerDetails> migrateAllComputers(Context c) {
|
||||||
SQLiteDatabase computerDb = null;
|
try (final SQLiteDatabase computerDb = SQLiteDatabase.openDatabase(
|
||||||
try {
|
c.getDatabasePath(COMPUTER_DB_NAME).getPath(),
|
||||||
|
null, SQLiteDatabase.OPEN_READONLY)
|
||||||
|
) {
|
||||||
// Open the existing database
|
// Open the existing database
|
||||||
computerDb = SQLiteDatabase.openDatabase(c.getDatabasePath(COMPUTER_DB_NAME).getPath(), null, SQLiteDatabase.OPEN_READONLY);
|
|
||||||
return getAllComputers(computerDb);
|
return getAllComputers(computerDb);
|
||||||
} catch (SQLiteException e) {
|
} catch (SQLiteException e) {
|
||||||
return new LinkedList<ComputerDetails>();
|
return new LinkedList<ComputerDetails>();
|
||||||
} finally {
|
} finally {
|
||||||
// Close and delete the old DB
|
// Close and delete the old DB
|
||||||
if (computerDb != null) {
|
|
||||||
computerDb.close();
|
|
||||||
}
|
|
||||||
c.deleteDatabase(COMPUTER_DB_NAME);
|
c.deleteDatabase(COMPUTER_DB_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,37 +49,34 @@ public class LegacyDatabaseReader2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<ComputerDetails> getAllComputers(SQLiteDatabase computerDb) {
|
public static List<ComputerDetails> getAllComputers(SQLiteDatabase computerDb) {
|
||||||
Cursor c = computerDb.rawQuery("SELECT * FROM "+COMPUTER_TABLE_NAME, null);
|
try (final Cursor c = computerDb.rawQuery("SELECT * FROM "+COMPUTER_TABLE_NAME, null)) {
|
||||||
LinkedList<ComputerDetails> computerList = new LinkedList<>();
|
LinkedList<ComputerDetails> computerList = new LinkedList<>();
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
ComputerDetails details = getComputerFromCursor(c);
|
ComputerDetails details = getComputerFromCursor(c);
|
||||||
|
|
||||||
// If a critical field is corrupt or missing, skip the database entry
|
// If a critical field is corrupt or missing, skip the database entry
|
||||||
if (details.uuid == null) {
|
if (details.uuid == null) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
computerList.add(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
computerList.add(details);
|
return computerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.close();
|
|
||||||
|
|
||||||
return computerList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ComputerDetails> migrateAllComputers(Context c) {
|
public static List<ComputerDetails> migrateAllComputers(Context c) {
|
||||||
SQLiteDatabase computerDb = null;
|
try (final SQLiteDatabase computerDb = SQLiteDatabase.openDatabase(
|
||||||
try {
|
c.getDatabasePath(COMPUTER_DB_NAME).getPath(),
|
||||||
|
null, SQLiteDatabase.OPEN_READONLY)
|
||||||
|
) {
|
||||||
// Open the existing database
|
// Open the existing database
|
||||||
computerDb = SQLiteDatabase.openDatabase(c.getDatabasePath(COMPUTER_DB_NAME).getPath(), null, SQLiteDatabase.OPEN_READONLY);
|
|
||||||
return getAllComputers(computerDb);
|
return getAllComputers(computerDb);
|
||||||
} catch (SQLiteException e) {
|
} catch (SQLiteException e) {
|
||||||
return new LinkedList<ComputerDetails>();
|
return new LinkedList<ComputerDetails>();
|
||||||
} finally {
|
} finally {
|
||||||
// Close and delete the old DB
|
// Close and delete the old DB
|
||||||
if (computerDb != null) {
|
|
||||||
computerDb.close();
|
|
||||||
}
|
|
||||||
c.deleteDatabase(COMPUTER_DB_NAME);
|
c.deleteDatabase(COMPUTER_DB_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,21 +154,15 @@ public class DiskAssetLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void populateCacheWithStream(CachedAppAssetLoader.LoaderTuple tuple, InputStream input) {
|
public void populateCacheWithStream(CachedAppAssetLoader.LoaderTuple tuple, InputStream input) {
|
||||||
OutputStream out = null;
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try (final OutputStream out = CacheHelper.openCacheFileForOutput(
|
||||||
out = CacheHelper.openCacheFileForOutput(cacheDir, "boxart", tuple.computer.uuid, tuple.app.getAppId() + ".png");
|
cacheDir, "boxart", tuple.computer.uuid, tuple.app.getAppId() + ".png")
|
||||||
|
) {
|
||||||
CacheHelper.writeInputStreamToOutputStream(input, out, MAX_ASSET_SIZE);
|
CacheHelper.writeInputStreamToOutputStream(input, out, MAX_ASSET_SIZE);
|
||||||
success = true;
|
success = true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (out != null) {
|
|
||||||
try {
|
|
||||||
out.close();
|
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
LimeLog.warning("Unable to populate cache with tuple: "+tuple);
|
LimeLog.warning("Unable to populate cache with tuple: "+tuple);
|
||||||
CacheHelper.deleteCacheFile(cacheDir, "boxart", tuple.computer.uuid, tuple.app.getAppId() + ".png");
|
CacheHelper.deleteCacheFile(cacheDir, "boxart", tuple.computer.uuid, tuple.app.getAppId() + ".png");
|
||||||
|
|||||||
@@ -627,10 +627,9 @@ public class NvHTTP {
|
|||||||
return getAppListByReader(new StringReader(getAppListRaw()));
|
return getAppListByReader(new StringReader(getAppListRaw()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ResponseBody resp = openHttpConnection(baseUrlHttps, "applist", true);
|
try (final ResponseBody resp = openHttpConnection(baseUrlHttps, "applist", true)) {
|
||||||
LinkedList<NvApp> appList = getAppListByReader(new InputStreamReader(resp.byteStream()));
|
return getAppListByReader(new InputStreamReader(resp.byteStream()));
|
||||||
resp.close();
|
}
|
||||||
return appList;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,11 @@ public class WakeOnLanSender {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static void sendWolPacket(ComputerDetails computer) throws IOException {
|
public static void sendWolPacket(ComputerDetails computer) throws IOException {
|
||||||
DatagramSocket sock = new DatagramSocket(0);
|
|
||||||
byte[] payload = createWolPayload(computer);
|
byte[] payload = createWolPayload(computer);
|
||||||
IOException lastException = null;
|
IOException lastException = null;
|
||||||
boolean sentWolPacket = false;
|
boolean sentWolPacket = false;
|
||||||
|
|
||||||
try {
|
try (final DatagramSocket sock = new DatagramSocket(0)) {
|
||||||
// Try all resolved remote and local addresses and IPv4 broadcast address.
|
// Try all resolved remote and local addresses and IPv4 broadcast address.
|
||||||
// The broadcast address is required to avoid stale ARP cache entries
|
// The broadcast address is required to avoid stale ARP cache entries
|
||||||
// making the sleeping machine unreachable.
|
// making the sleeping machine unreachable.
|
||||||
@@ -52,8 +51,6 @@ public class WakeOnLanSender {
|
|||||||
lastException = e;
|
lastException = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
sock.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Propagate the DNS resolution exception if we didn't
|
// Propagate the DNS resolution exception if we didn't
|
||||||
@@ -65,18 +62,20 @@ public class WakeOnLanSender {
|
|||||||
|
|
||||||
private static byte[] macStringToBytes(String macAddress) {
|
private static byte[] macStringToBytes(String macAddress) {
|
||||||
byte[] macBytes = new byte[6];
|
byte[] macBytes = new byte[6];
|
||||||
@SuppressWarnings("resource")
|
|
||||||
Scanner scan = new Scanner(macAddress).useDelimiter(":");
|
try (@SuppressWarnings("resource")
|
||||||
for (int i = 0; i < macBytes.length && scan.hasNext(); i++) {
|
final Scanner scan = new Scanner(macAddress).useDelimiter(":")
|
||||||
try {
|
) {
|
||||||
macBytes[i] = (byte) Integer.parseInt(scan.next(), 16);
|
for (int i = 0; i < macBytes.length && scan.hasNext(); i++) {
|
||||||
} catch (NumberFormatException e) {
|
try {
|
||||||
LimeLog.warning("Malformed MAC address: "+macAddress+" (index: "+i+")");
|
macBytes[i] = (byte) Integer.parseInt(scan.next(), 16);
|
||||||
break;
|
} catch (NumberFormatException e) {
|
||||||
|
LimeLog.warning("Malformed MAC address: " + macAddress + " (index: " + i + ")");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return macBytes;
|
||||||
}
|
}
|
||||||
scan.close();
|
|
||||||
return macBytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] createWolPayload(ComputerDetails computer) {
|
private static byte[] createWolPayload(ComputerDetails computer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user