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

Side by Side Diff: net/proxy/proxy_service.cc

Issue 73038: Allows a proxy bypass entry to match on a specific port, used by the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_config.h ('k') | net/proxy/proxy_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/proxy/proxy_service.h" 5 #include "net/proxy/proxy_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 bool ProxyService::ShouldBypassProxyForURL(const GURL& url) { 571 bool ProxyService::ShouldBypassProxyForURL(const GURL& url) {
572 std::string url_domain = url.scheme(); 572 std::string url_domain = url.scheme();
573 if (!url_domain.empty()) 573 if (!url_domain.empty())
574 url_domain += "://"; 574 url_domain += "://";
575 575
576 url_domain += url.host(); 576 url_domain += url.host();
577 // This isn't superfluous; GURL case canonicalization doesn't hit the embedded 577 // This isn't superfluous; GURL case canonicalization doesn't hit the embedded
578 // percent-encoded characters. 578 // percent-encoded characters.
579 StringToLowerASCII(&url_domain); 579 StringToLowerASCII(&url_domain);
580 580
581 std::string url_domain_and_port = url_domain + ":"
582 + IntToString(url.EffectiveIntPort());
583
581 if (config_.proxy_bypass_local_names) { 584 if (config_.proxy_bypass_local_names) {
582 if (url.host().find('.') == std::string::npos) 585 if (url.host().find('.') == std::string::npos)
583 return true; 586 return true;
584 } 587 }
585 588
586 for(std::vector<std::string>::const_iterator i = config_.proxy_bypass.begin(); 589 for(std::vector<std::string>::const_iterator i = config_.proxy_bypass.begin();
587 i != config_.proxy_bypass.end(); ++i) { 590 i != config_.proxy_bypass.end(); ++i) {
588 std::string bypass_url_domain = *i; 591 std::string bypass_url_domain = *i;
589 592
590 // The proxy server bypass list can contain entities with http/https 593 // The proxy server bypass list can contain entities with http/https
591 // If no scheme is specified then it indicates that all schemes are 594 // If no scheme is specified then it indicates that all schemes are
592 // allowed for the current entry. For matching this we just use 595 // allowed for the current entry. For matching this we just use
593 // the protocol scheme of the url passed in. 596 // the protocol scheme of the url passed in.
594 if (bypass_url_domain.find("://") == std::string::npos) { 597 size_t scheme_colon = bypass_url_domain.find("://");
598 if (scheme_colon == std::string::npos) {
595 std::string bypass_url_domain_with_scheme = url.scheme(); 599 std::string bypass_url_domain_with_scheme = url.scheme();
600 scheme_colon = bypass_url_domain_with_scheme.length();
596 bypass_url_domain_with_scheme += "://"; 601 bypass_url_domain_with_scheme += "://";
597 bypass_url_domain_with_scheme += bypass_url_domain; 602 bypass_url_domain_with_scheme += bypass_url_domain;
598 603
599 bypass_url_domain = bypass_url_domain_with_scheme; 604 bypass_url_domain = bypass_url_domain_with_scheme;
600 } 605 }
606 std::string* url_compare_reference = &url_domain;
607 size_t port_colon = bypass_url_domain.rfind(":");
608 if (port_colon > scheme_colon) {
609 // If our match pattern includes a colon followed by a digit,
610 // and either it's preceded by ']' (IPv6 with port)
611 // or has no other colon (IPv4),
612 // then match against <domain>:<port>.
613 // TODO(sdoyon): straighten this out, in particular the IPv6 brackets,
614 // and do the parsing in ProxyConfig when we do the CIDR matching
615 // mentioned below.
616 std::string::const_iterator domain_begin =
617 bypass_url_domain.begin() + scheme_colon + 3; // after ://
618 std::string::const_iterator port_iter =
619 bypass_url_domain.begin() + port_colon;
620 std::string::const_iterator end = bypass_url_domain.end();
621 if ((port_iter + 1) < end && IsAsciiDigit(*(port_iter + 1)) &&
622 (*(port_iter - 1) == ']' ||
623 std::find(domain_begin, port_iter, ':') == port_iter))
624 url_compare_reference = &url_domain_and_port;
625 }
601 626
602 StringToLowerASCII(&bypass_url_domain); 627 StringToLowerASCII(&bypass_url_domain);
603 628
604 if (MatchPattern(url_domain, bypass_url_domain)) 629 if (MatchPattern(*url_compare_reference, bypass_url_domain))
605 return true; 630 return true;
606 631
607 // Some systems (the Mac, for example) allow CIDR-style specification of 632 // Some systems (the Mac, for example) allow CIDR-style specification of
608 // proxy bypass for IP-specified hosts (e.g. "10.0.0.0/8"; see 633 // proxy bypass for IP-specified hosts (e.g. "10.0.0.0/8"; see
609 // http://www.tcd.ie/iss/internet/osx_proxy.php for a real-world example). 634 // http://www.tcd.ie/iss/internet/osx_proxy.php for a real-world example).
610 // That's kinda cool so we'll provide that for everyone. 635 // That's kinda cool so we'll provide that for everyone.
611 // TODO(avi): implement here 636 // TODO(avi): implement here. See: http://crbug.com/9835.
637 // IP addresses ought to be canonicalized for comparison (whether
638 // with CIDR, port, or IP address alone).
612 } 639 }
613 640
614 return false; 641 return false;
615 } 642 }
616 643
617 SyncProxyServiceHelper::SyncProxyServiceHelper(MessageLoop* io_message_loop, 644 SyncProxyServiceHelper::SyncProxyServiceHelper(MessageLoop* io_message_loop,
618 ProxyService* proxy_service) 645 ProxyService* proxy_service)
619 : io_message_loop_(io_message_loop), 646 : io_message_loop_(io_message_loop),
620 proxy_service_(proxy_service), 647 proxy_service_(proxy_service),
621 event_(false, false), 648 event_(false, false),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 OnCompletion(result_); 695 OnCompletion(result_);
669 } 696 }
670 } 697 }
671 698
672 void SyncProxyServiceHelper::OnCompletion(int rv) { 699 void SyncProxyServiceHelper::OnCompletion(int rv) {
673 result_ = rv; 700 result_ = rv;
674 event_.Signal(); 701 event_.Signal();
675 } 702 }
676 703
677 } // namespace net 704 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_config.h ('k') | net/proxy/proxy_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698