mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 08:25:22 +00:00
Merge branch 'upstream/main' into fix/wifi-aware-socket-binding
This commit is contained in:
+12
-1
@@ -590,13 +590,16 @@ class WifiAwareMeshService(private val context: Context) {
|
|||||||
|
|
||||||
val req = NetworkRequest.Builder()
|
val req = NetworkRequest.Builder()
|
||||||
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_AWARE)
|
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_AWARE)
|
||||||
|
.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
|
||||||
.setNetworkSpecifier(spec)
|
.setNetworkSpecifier(spec)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val cb = object : ConnectivityManager.NetworkCallback() {
|
val cb = object : ConnectivityManager.NetworkCallback() {
|
||||||
override fun onAvailable(network: Network) {
|
override fun onAvailable(network: Network) {
|
||||||
try {
|
try {
|
||||||
val client = ss.accept().apply { keepAlive = true }
|
val client = ss.accept()
|
||||||
|
try { network.bindSocket(client) } catch (e: Exception) { Log.w(TAG, "Server bindSocket EPERM: \${e.message}") }
|
||||||
|
client.keepAlive = true
|
||||||
Log.d(TAG, "SERVER: accepted TCP from \${peerId.take(8)}… addr=\${client.inetAddress?.hostAddress}")
|
Log.d(TAG, "SERVER: accepted TCP from \${peerId.take(8)}… addr=\${client.inetAddress?.hostAddress}")
|
||||||
peerSockets[peerId] = client
|
peerSockets[peerId] = client
|
||||||
try { peerManager.setDirectConnection(peerId, true) } catch (_: Exception) {}
|
try { peerManager.setDirectConnection(peerId, true) } catch (_: Exception) {}
|
||||||
@@ -697,6 +700,7 @@ class WifiAwareMeshService(private val context: Context) {
|
|||||||
.build()
|
.build()
|
||||||
val req = NetworkRequest.Builder()
|
val req = NetworkRequest.Builder()
|
||||||
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_AWARE)
|
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_AWARE)
|
||||||
|
.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
|
||||||
.setNetworkSpecifier(spec)
|
.setNetworkSpecifier(spec)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
@@ -715,6 +719,13 @@ class WifiAwareMeshService(private val context: Context) {
|
|||||||
try {
|
try {
|
||||||
val sock = Socket()
|
val sock = Socket()
|
||||||
network.bindSocket(sock)
|
network.bindSocket(sock)
|
||||||
|
|
||||||
|
val lp = cm.getLinkProperties(network)
|
||||||
|
val iface = lp?.interfaceName
|
||||||
|
|
||||||
|
try {
|
||||||
|
val sock = Socket()
|
||||||
|
try { network.bindSocket(sock) } catch (e: Exception) { Log.w(TAG, "Client bindSocket EPERM: \${e.message}") }
|
||||||
sock.tcpNoDelay = true
|
sock.tcpNoDelay = true
|
||||||
sock.keepAlive = true
|
sock.keepAlive = true
|
||||||
|
|
||||||
Reference in New Issue
Block a user