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

Side by Side Diff: net/base/ip_mapping_rules.h

Issue 215623003: Revert "Support replacement of IP address resolutions via command line flag" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/public/common/content_switches.cc ('k') | net/base/ip_mapping_rules.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_BASE_IP_MAPPING_RULES_H_
6 #define NET_BASE_IP_MAPPING_RULES_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "net/base/net_export.h"
13
14 namespace net {
15
16 class AddressList;
17
18 // This class contains a list of rules, that can be used to process (Rewrite) a
19 // set of DNS resolutions (IP addresses) in accordance with those rules.
20 // Currently the only rules supported use a pattern match against some given IP
21 // addresses, and may, if there is a match, place one new IP address at the
22 // start of the rewritten address list (re: the "PREFACE" directive). This
23 // supports a common use case where the matching detects an address in a given
24 // edge network server group, and the inserted address points to a server that
25 // is expected to handle all requests that would otherwise have gone to the
26 // given group of servers.
27 class NET_EXPORT_PRIVATE IPMappingRules {
28 public:
29 IPMappingRules();
30 ~IPMappingRules();
31
32 // Modifies |*addresses| based on the current rules. Returns true if
33 // |addresses| was modified, false otherwise.
34 bool RewriteAddresses(AddressList* addresses) const;
35
36 // Adds a rule to this mapper.
37 // Rules are evaluated against an address list until a first matching rule is
38 // found that applies, causing a modification of the address list.
39 // Each rule consists of one or more of the following pattern and action
40 // directives.
41 //
42 // RULE: CHANGE_DIRECTIVE | EMPTY
43 // CHANGE_DIRECTIVE: "PREFACE" SPACE IP_PATTERN SPACE IP_LITERAL
44 // SPACE: " "
45 // EMPTY:
46 //
47 // IP_LITERAL: IP_V6_LITERAL | IP_V4_LITERAL
48 //
49 // IP_V4_LITERAL: OCTET "." OCTET "." OCTET "." OCTET
50 // OCTET: decimal number in range 0 ... 255
51 //
52 // IP_V6_LITERAL: HEX_COMPONENT | IP_V6_LITERAL ":" HEX_COMPONENT
53 // HEX_COMPONENT: hexadecimal values with no more than 4 hex digits
54 //
55 // IP_PATTERN: IP_V6_PATTERN | IP_V4_PATTERN
56 //
57 // IP_V6_PATTERN: HEX_PATTERN | IP_V6_PATTERN ":" HEX_PATTERN
58 // HEX_PATTERN: HEX_COMPONENT | "[" HEX_GROUP_PATTERN "]" | "*"
59 // HEX_GROUP_PATTERN: HEX_RANGE | HEX_GROUP_PATTERN "," HEX_RANGE
60 // HEX_RANGE: HEX_COMPONENT | HEX_COMPONENT "-" HEX_COMPONENT
61 //
62 // IP_V4_PATTERN: OCTET_PATTERN "." OCTET_PATTERN "." OCTET_PATTERN
63 // "." OCTET_PATTERN
64 // OCTET_PATTERN: OCTET | "[" OCTET_GROUP_PATTERN "]" | "*"
65 // OCTET_GROUP_PATTERN: OCTET_RANGE | OCTET_GROUP_PATTERN "," OCTET_RANGE
66 // OCTET_RANGE: OCTET | OCTET "-" OCTET
67 //
68 // All literals are required to have all their components specified (4
69 // components for IPv4, and 8 for IPv6). Specifically, there is currently no
70 // support for elided compenents in an IPv6 address (e.g., "::").
71 // Returns true if the rule was successfully parsed and added.
72 bool AddRuleFromString(const std::string& rule_string);
73
74 // Sets the rules from a semicolon separated list of rules.
75 // Returns true if all the rules were successfully parsed and added.
76 bool SetRulesFromString(const std::string& rules_string);
77
78 private:
79 class Rule;
80 typedef std::vector<Rule*> RuleList;
81
82 // We own all rules in this list, and are responsible for their destruction.
83 RuleList rules_;
84
85 DISALLOW_COPY_AND_ASSIGN(IPMappingRules);
86 };
87
88 } // namespace net
89
90 #endif // NET_BASE_IP_MAPPING_RULES_H_
OLDNEW
« no previous file with comments | « content/public/common/content_switches.cc ('k') | net/base/ip_mapping_rules.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698