From 63615747a715dd733d78545e96d41dcef1a97a2d Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 18 Mar 2023 01:26:34 +0000 Subject: [PATCH] Fix executable choosing for my phone, and fix broadcasting to each interface. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4232 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- Makefile | 6 +++--- src/android/com/unprompted/tildefriends/MainActivity.java | 2 ++ src/ssb.c | 8 +++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 5238e04f..cfa4c850 100644 --- a/Makefile +++ b/Makefile @@ -441,11 +441,11 @@ out/TildeFriends-debug.unsigned.apk: BUILD_TYPE := debug out/TildeFriends-release.unsigned.apk: BUILD_TYPE := release out/%.unsigned.apk: - @mkdir -p $(dir $@) out/apk$(BUILD_TYPE)/lib/arm64-v8a/ out/apk$(BUILD_TYPE)/lib/x86_64/ + @mkdir -p $(dir $@) out/apk$(BUILD_TYPE)/lib/aarch64/ out/apk$(BUILD_TYPE)/lib/x86_64/ @echo [aapt] $@ - @cp out/android$(BUILD_TYPE)/tildefriends out/apk$(BUILD_TYPE)/lib/arm64-v8a/ + @cp out/android$(BUILD_TYPE)/tildefriends out/apk$(BUILD_TYPE)/lib/aarch64/ @cp out/android$(BUILD_TYPE)-x86_64/tildefriends out/apk$(BUILD_TYPE)/lib/x86_64/ - @/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/lib/arm64-v8a/tildefriends + @/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/lib/aarch64/tildefriends @/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/lib/x86_64/tildefriends @cp out/res.apk $@ @cp out/apk/classes.dex out/apk$(BUILD_TYPE)/ diff --git a/src/android/com/unprompted/tildefriends/MainActivity.java b/src/android/com/unprompted/tildefriends/MainActivity.java index 97118f58..c5dccbce 100644 --- a/src/android/com/unprompted/tildefriends/MainActivity.java +++ b/src/android/com/unprompted/tildefriends/MainActivity.java @@ -47,8 +47,10 @@ public class MainActivity extends Activity { ZipInputStream zip = new ZipInputStream(new BufferedInputStream(new FileInputStream(getPackageResourcePath().toString()))); ZipEntry entry = null; String lookup = String.format("lib/%s/tildefriends", arch); + Log.w("tildefriends", "Looking for " + lookup); while ((entry = zip.getNextEntry()) != null) { if (entry.getName().equals(lookup)) { + Log.w("tildefriends", "Extracting " + entry.getName()); FileOutputStream out = new FileOutputStream(getFilesDir().toString().concat("/tildefriends")); byte[] buffer = new byte[32768]; int count; diff --git a/src/ssb.c b/src/ssb.c index 23e2bb2c..b1fcf1be 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -2554,7 +2554,7 @@ static void _tf_ssb_on_connection(uv_stream_t* stream, int status) uv_read_start((uv_stream_t*)&connection->tcp, _tf_ssb_connection_on_tcp_alloc, _tf_ssb_connection_on_tcp_recv); } -static void _tf_ssb_send_broadcast(tf_ssb_t* ssb, struct sockaddr_in* address) +static void _tf_ssb_send_broadcast(tf_ssb_t* ssb, struct sockaddr_in* address, struct sockaddr_in* netmask) { struct sockaddr server_addr; int len = (int)sizeof(server_addr); @@ -2581,7 +2581,9 @@ static void _tf_ssb_send_broadcast(tf_ssb_t* ssb, struct sockaddr_in* address) struct sockaddr_in broadcast_addr = { 0 }; broadcast_addr.sin_family = AF_INET; broadcast_addr.sin_port = htons(8008); - broadcast_addr.sin_addr.s_addr = INADDR_BROADCAST; + broadcast_addr.sin_addr.s_addr = + (address->sin_addr.s_addr & netmask->sin_addr.s_addr) | + (INADDR_BROADCAST & ~netmask->sin_addr.s_addr); int r = uv_udp_try_send(&ssb->broadcast_sender, &buf, 1, (struct sockaddr*)&broadcast_addr); if (r < 0) { @@ -2601,7 +2603,7 @@ static void _tf_ssb_broadcast_timer(uv_timer_t* timer) if (!info[i].is_internal && info[i].address.address4.sin_family == AF_INET) { - _tf_ssb_send_broadcast(ssb, &info[i].address.address4); + _tf_ssb_send_broadcast(ssb, &info[i].address.address4, &info[i].netmask.netmask4); } } uv_free_interface_addresses(info, count);