diff --git a/android/app/src/main/kotlin/com/network/proxy/ProxyVpnService.kt b/android/app/src/main/kotlin/com/network/proxy/ProxyVpnService.kt index 2f63e72..66c9ce3 100644 --- a/android/app/src/main/kotlin/com/network/proxy/ProxyVpnService.kt +++ b/android/app/src/main/kotlin/com/network/proxy/ProxyVpnService.kt @@ -104,8 +104,8 @@ class ProxyVpnService : VpnService(), ProtectSocket { disconnect() } - override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { - return if (intent.action == ACTION_DISCONNECT) { + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + return if (intent?.action == ACTION_DISCONNECT) { disconnect() START_NOT_STICKY } else { diff --git a/android/app/src/main/kotlin/com/network/proxy/vpn/util/ProcessInfoManager.kt b/android/app/src/main/kotlin/com/network/proxy/vpn/util/ProcessInfoManager.kt index 9f02dc0..36994a1 100644 --- a/android/app/src/main/kotlin/com/network/proxy/vpn/util/ProcessInfoManager.kt +++ b/android/app/src/main/kotlin/com/network/proxy/vpn/util/ProcessInfoManager.kt @@ -53,10 +53,14 @@ class ProcessInfoManager private constructor() { val uid = getProcessInfoUid(sourceAddress, destinationAddress) val channel = connection.channel if (uid != null && uid != Process.INVALID_UID && channel is SocketChannel && channel.isOpen) { - val localAddress = channel.localAddress as InetSocketAddress - val networkInfo = - NetworkInfo(uid, destinationAddress.hostString, destinationAddress.port) - localPortCache.put(localAddress.port, networkInfo) + try { + val localAddress = channel.localAddress as InetSocketAddress + val networkInfo = + NetworkInfo(uid, destinationAddress.hostString, destinationAddress.port) + localPortCache.put(localAddress.port, networkInfo) + } catch (e: java.nio.channels.ClosedChannelException) { + Log.w("ProcessInfoManager", "setConnectionOwnerUid", e) + } } } } @@ -68,8 +72,12 @@ class ProcessInfoManager private constructor() { val channel = connection.channel if (channel is SocketChannel && channel.isOpen) { - val localAddress = channel.localAddress as InetSocketAddress - localPortCache.remove(localAddress.port) + try { + val localAddress = channel.localAddress as InetSocketAddress + localPortCache.remove(localAddress.port) + } catch (e: java.nio.channels.ClosedChannelException) { + Log.w("ProcessInfoManager", "removeConnection", e) + } } } @@ -206,4 +214,4 @@ class ProcessInfoManager private constructor() { return null } -} \ No newline at end of file +} diff --git a/lib/network/components/report_server_interceptor.dart b/lib/network/components/report_server_interceptor.dart index dddef33..6a11ce1 100644 --- a/lib/network/components/report_server_interceptor.dart +++ b/lib/network/components/report_server_interceptor.dart @@ -92,6 +92,11 @@ class ReportServerInterceptor extends Interceptor { final ioReq = await httpClient.postUrl(uri).timeout(const Duration(seconds: 5)); // Set headers + final matchedRule = server.name; + if (matchedRule.isNotEmpty) { + ioReq.headers.set('X-Report-Name', matchedRule); + } + ioReq.headers.set(HttpHeaders.contentTypeHeader, 'application/json; charset=utf-8'); if (compression == 'gzip') { ioReq.headers.set(HttpHeaders.contentEncodingHeader, 'gzip'); diff --git a/lib/ui/mobile/mobile.dart b/lib/ui/mobile/mobile.dart index 8ae3e51..c76ed7a 100644 --- a/lib/ui/mobile/mobile.dart +++ b/lib/ui/mobile/mobile.dart @@ -503,7 +503,7 @@ class _MobileAppBar extends StatelessWidget implements PreferredSizeWidget { actions: [ IconButton( tooltip: localizations.clear, - icon: const Icon(Icons.cleaning_services_outlined), + icon: const Icon(Icons.delete_outline), onPressed: () => MobileApp.requestStateKey.currentState?.clean()), const SizedBox(width: 2), MoreMenu(proxyServer: proxyServer, remoteDevice: remoteDevice),