Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6183)

Unified Diff: chrome/browser/resources/net_internals/proxy_view.js

Issue 12549010: [net] Add an informational bubble to about:net-internals#proxy when using a single SOCKS v5 proxy s… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address mmenke comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/net_internals/proxy_view.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/net_internals/proxy_view.js
diff --git a/chrome/browser/resources/net_internals/proxy_view.js b/chrome/browser/resources/net_internals/proxy_view.js
index 4ddf53809711873a211e2b638b1d972ed144c542..7d21fc849d399ca973ccd3b825e7b9e630eec575 100644
--- a/chrome/browser/resources/net_internals/proxy_view.js
+++ b/chrome/browser/resources/net_internals/proxy_view.js
@@ -46,6 +46,8 @@ var ProxyView = (function() {
ProxyView.RELOAD_SETTINGS_BUTTON_ID = 'proxy-view-reload-settings';
ProxyView.BAD_PROXIES_TBODY_ID = 'proxy-view-bad-proxies-tbody';
ProxyView.CLEAR_BAD_PROXIES_BUTTON_ID = 'proxy-view-clear-bad-proxies';
+ ProxyView.SOCKS_HINTS_DIV_ID = 'proxy-view-socks-hints';
+ ProxyView.SOCKS_HINTS_FLAG_DIV_ID = 'proxy-view-socks-hints-flag';
cr.addSingletonGetter(ProxyView);
@@ -59,14 +61,15 @@ var ProxyView = (function() {
},
onProxySettingsChanged: function(proxySettings) {
- // Both |original| and |effective| are dictionaries describing the
- // settings.
$(ProxyView.ORIGINAL_SETTINGS_DIV_ID).innerHTML = '';
$(ProxyView.EFFECTIVE_SETTINGS_DIV_ID).innerHTML = '';
+ this.updateSocksHints_(null);
if (!proxySettings)
return false;
+ // Both |original| and |effective| are dictionaries describing the
+ // settings.
var original = proxySettings.original;
var effective = proxySettings.effective;
@@ -74,6 +77,9 @@ var ProxyView = (function() {
proxySettingsToString(original);
$(ProxyView.EFFECTIVE_SETTINGS_DIV_ID).innerText =
proxySettingsToString(effective);
+
+ this.updateSocksHints_(effective);
+
return true;
},
@@ -97,8 +103,62 @@ var ProxyView = (function() {
timeutil.addNodeWithDate(badUntilCell, badUntilDate);
}
return true;
+ },
+
+ updateSocksHints_: function(proxySettings) {
+ setNodeDisplay($(ProxyView.SOCKS_HINTS_DIV_ID), false);
+
+ if (!proxySettings)
+ return;
+
+ var socksProxy = getSocks5Proxy_(proxySettings.single_proxy);
+ if (!socksProxy)
+ return;
+
+ // Suggest a recommended --host-resolver-rules.
+ // NOTE: This does not compensate for any proxy bypass rules. If the
+ // proxy settings include proxy bypasses the user may need to expand the
+ // exclusions for host resolving.
+ var hostResolverRules = 'MAP * ~NOTFOUND , EXCLUDE ' + socksProxy.host;
+ var hostResolverRulesFlag = '--host-resolver-rules="' +
+ hostResolverRules + '"';
+
+ // TODO(eroman): On Linux the ClientInfo.command_line is wrong in that it
+ // doesn't include any quotes around the parameters. This means the
+ // string search above is going to fail :(
+ if (ClientInfo.command_line &&
+ ClientInfo.command_line.indexOf(hostResolverRulesFlag) != -1) {
+ // Chrome is already using the suggested resolver rules.
+ return;
+ }
+
+ $(ProxyView.SOCKS_HINTS_FLAG_DIV_ID).innerText = hostResolverRulesFlag;
+ setNodeDisplay($(ProxyView.SOCKS_HINTS_DIV_ID), true);
}
};
+ function getSocks5Proxy_(proxyString) {
+ var pattern = /^socks5:\/\/(.*)$/;
+ var matches = pattern.exec(proxyString);
+
+ if (!matches)
+ return null;
+
+ var hostPortString = matches[1];
+
+ matches = /^(.*):(\d+)$/.exec(hostPortString);
+ if (!matches)
+ return null;
+
+ var result = {host: matches[1], port: matches[2]};
+
+ // Strip brackets off of IPv6 literals.
+ matches = /^\[(.*)\]$/.exec(result.host);
+ if (matches)
+ result.host = matches[1];
+
+ return result;
+ }
+
return ProxyView;
})();
« no previous file with comments | « chrome/browser/resources/net_internals/proxy_view.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698