Chromium Code Reviews| 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..633cb55a0d9d891a4f9a78f266185ccf91569a3f 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); |
| @@ -74,6 +76,9 @@ var ProxyView = (function() { |
| proxySettingsToString(original); |
| $(ProxyView.EFFECTIVE_SETTINGS_DIV_ID).innerText = |
| proxySettingsToString(effective); |
| + |
| + this.updateSocksHints_(effective); |
| + |
| return true; |
| }, |
| @@ -97,8 +102,59 @@ var ProxyView = (function() { |
| timeutil.addNodeWithDate(badUntilCell, badUntilDate); |
| } |
| return true; |
| + }, |
| + |
| + updateSocksHints_: function(proxySettings) { |
| + setNodeDisplay($(ProxyView.SOCKS_HINTS_DIV_ID), false); |
| + |
| + 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. |
|
mmenke
2013/03/07 20:16:57
If this isn't a TODO, should this be in the displa
eroman
2013/03/07 20:23:32
I considered just implementing this, however the s
mmenke
2013/03/07 20:26:06
That sounds reasonable. But I was actually thinki
|
| + 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 undefined; |
|
mmenke
2013/03/07 20:16:57
I think returning null is a bit more natural.
eroman
2013/03/07 20:23:32
Will do.
|
| + |
| + var hostPortString = matches[1]; |
| + |
| + matches = /^(.*):(\d+)$/.exec(hostPortString); |
| + if (!matches) |
| + return undefined; |
| + |
| + 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; |
| })(); |