mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-03-15 04:23:17 +08:00
Add report name to header
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user