mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-05-20 16:15:47 +08:00
exclude DNS over HTTPS protocol
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:proxypin/network/channel/host_port.dart';
|
||||
import 'package:proxypin/network/util/process_info.dart';
|
||||
|
||||
class ProcessInfoPlugin {
|
||||
@@ -14,7 +15,14 @@ class ProcessInfoPlugin {
|
||||
os: Platform.operatingSystem,
|
||||
icon: process['icon'],
|
||||
remoteHost: process['remoteHost'],
|
||||
remotePost: process['remotePost']);
|
||||
remotePost: process['remotePort']);
|
||||
});
|
||||
}
|
||||
|
||||
static Future<HostAndPort?> getRemoteAddressByPort(int port) {
|
||||
return _methodChannel.invokeMethod<Map>('getRemoteAddressByPort', {"port": port}).then((process) {
|
||||
if (process == null) return null;
|
||||
return HostAndPort.host(process['remoteHost'], process['remotePort']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:proxypin/native/process_info.dart';
|
||||
import 'package:proxypin/network/bin/configuration.dart';
|
||||
import 'package:proxypin/network/channel/channel.dart';
|
||||
import 'package:proxypin/network/channel/channel_context.dart';
|
||||
@@ -141,17 +142,24 @@ class Server extends Network {
|
||||
var hostAndPort = channelContext.host;
|
||||
try {
|
||||
String? serviceName = TLS.getDomain(data) ?? hostAndPort?.host;
|
||||
bool isHttp = true;
|
||||
|
||||
if (hostAndPort == null) {
|
||||
var domain = serviceName;
|
||||
var port = 443;
|
||||
|
||||
if (domain == null) {
|
||||
var process = await ProcessInfoUtils.getProcessByPort(
|
||||
channel.remoteSocketAddress, channel.remoteSocketAddress.toString());
|
||||
domain = process?.remoteHost;
|
||||
port = process?.remotePost ?? port;
|
||||
var remote = await ProcessInfoPlugin.getRemoteAddressByPort(channel.remoteSocketAddress.port);
|
||||
domain = remote?.host;
|
||||
port = remote?.port ?? port;
|
||||
serviceName = domain;
|
||||
|
||||
// DNS over HTTPS
|
||||
if (remote?.port == 853 && TLS.supportProtocols(data)?.contains("http/1.1") == false) {
|
||||
isHttp = false;
|
||||
}
|
||||
}
|
||||
|
||||
hostAndPort = HostAndPort.host(domain!, port, scheme: HostAndPort.httpsScheme);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user