feat(flutter_tools): Added proxy validator IPV6 loopback check (#95159)

* feat(flutter_tools): Added proxy validator IPV6 lookback check

* Remove whitespace.

Co-authored-by: Zachary Anderson <zanderso@users.noreply.github.com>
This commit is contained in:
crisboarna
2021-12-16 17:56:45 +02:00
committed by GitHub
parent 31eb8fcd98
commit 1fb9b5b3d2
2 changed files with 188 additions and 14 deletions

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'base/io.dart';
import 'base/platform.dart';
import 'doctor_validator.dart';
@@ -43,7 +44,7 @@ class ProxyValidator extends DoctorValidator {
else
...<ValidationMessage>[
ValidationMessage('NO_PROXY is $_noProxy'),
for (String host in const <String>['127.0.0.1', 'localhost'])
for (final String host in await _getLoopbackAddresses())
if (_noProxy.contains(host))
ValidationMessage('NO_PROXY contains $host')
else
@@ -59,4 +60,21 @@ class ProxyValidator extends DoctorValidator {
messages,
);
}
Future<List<String>> _getLoopbackAddresses() async {
final List<String> loopBackAddresses = <String>['localhost'];
final List<NetworkInterface> networkInterfaces =
await listNetworkInterfaces(includeLinkLocal: true, includeLoopback: true);
for (final NetworkInterface networkInterface in networkInterfaces) {
for (final InternetAddress internetAddress in networkInterface.addresses) {
if (internetAddress.isLoopback) {
loopBackAddresses.add(internetAddress.address);
}
}
}
return loopBackAddresses;
}
}