OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 void AddRule(bool allow, FirewallProtocol p = FP_ANY, | 51 void AddRule(bool allow, FirewallProtocol p = FP_ANY, |
52 FirewallDirection d = FD_ANY, | 52 FirewallDirection d = FD_ANY, |
53 const SocketAddress& addr = SocketAddress()); | 53 const SocketAddress& addr = SocketAddress()); |
54 void AddRule(bool allow, FirewallProtocol p, | 54 void AddRule(bool allow, FirewallProtocol p, |
55 const SocketAddress& src, const SocketAddress& dst); | 55 const SocketAddress& src, const SocketAddress& dst); |
56 void ClearRules(); | 56 void ClearRules(); |
57 | 57 |
58 bool Check(FirewallProtocol p, | 58 bool Check(FirewallProtocol p, |
59 const SocketAddress& src, const SocketAddress& dst); | 59 const SocketAddress& src, const SocketAddress& dst); |
60 | 60 |
61 // Set the IP addresses which can't be bound to using Bind. By default this | |
pthatcher1
2017/06/13 19:52:49
"which can't be bound to using Bind" => "for which
Taylor Brandstetter
2017/06/13 22:11:17
Done.
| |
62 // list is empty. This can be used to simulate a real OS that refuses to bind | |
63 // to addresses under various circumstances. | |
64 // | |
65 // No matter how many addresses are added (including INADDR_ANY), the server | |
66 // will still allow creating outgoing TCP connections, since they don't | |
67 // require explicitly binding a socket. | |
68 void SetInvalidBindIps(const std::vector<rtc::IPAddress>& invalid_bind_ips); | |
69 bool CanBindToIp(const rtc::IPAddress& ip); | |
pthatcher1
2017/06/13 19:52:49
Might make these symmetric: SetInvalidBindIps and
Taylor Brandstetter
2017/06/13 22:11:17
Done.
| |
70 | |
61 Socket* CreateSocket(int type) override; | 71 Socket* CreateSocket(int type) override; |
62 Socket* CreateSocket(int family, int type) override; | 72 Socket* CreateSocket(int family, int type) override; |
63 | 73 |
64 AsyncSocket* CreateAsyncSocket(int type) override; | 74 AsyncSocket* CreateAsyncSocket(int type) override; |
65 AsyncSocket* CreateAsyncSocket(int family, int type) override; | 75 AsyncSocket* CreateAsyncSocket(int family, int type) override; |
66 | 76 |
67 void SetMessageQueue(MessageQueue* queue) override; | 77 void SetMessageQueue(MessageQueue* queue) override; |
68 bool Wait(int cms, bool process_io) override; | 78 bool Wait(int cms, bool process_io) override; |
69 void WakeUp() override; | 79 void WakeUp() override; |
70 | 80 |
71 Socket * WrapSocket(Socket * sock, int type); | 81 Socket * WrapSocket(Socket * sock, int type); |
72 AsyncSocket * WrapSocket(AsyncSocket * sock, int type); | 82 AsyncSocket * WrapSocket(AsyncSocket * sock, int type); |
73 | 83 |
74 private: | 84 private: |
75 SocketServer * server_; | 85 SocketServer * server_; |
76 FirewallManager * manager_; | 86 FirewallManager * manager_; |
77 CriticalSection crit_; | 87 CriticalSection crit_; |
78 struct Rule { | 88 struct Rule { |
79 bool allow; | 89 bool allow; |
80 FirewallProtocol p; | 90 FirewallProtocol p; |
81 FirewallDirection d; | 91 FirewallDirection d; |
82 SocketAddress src; | 92 SocketAddress src; |
83 SocketAddress dst; | 93 SocketAddress dst; |
84 }; | 94 }; |
85 std::vector<Rule> rules_; | 95 std::vector<Rule> rules_; |
96 // IP addresses which can't be successfully bound to, using Bind. If this | |
97 // list is empty, any address is accepted. | |
pthatcher1
2017/06/13 19:52:49
You just need one comment to explain this, not two
Taylor Brandstetter
2017/06/13 22:11:17
Done.
| |
98 std::vector<rtc::IPAddress> invalid_bind_ips_; | |
86 bool should_delete_server_; | 99 bool should_delete_server_; |
87 bool udp_sockets_enabled_; | 100 bool udp_sockets_enabled_; |
88 bool tcp_sockets_enabled_; | 101 bool tcp_sockets_enabled_; |
89 bool tcp_listen_enabled_; | 102 bool tcp_listen_enabled_; |
90 }; | 103 }; |
91 | 104 |
92 // FirewallManager allows you to manage firewalls in multiple threads together | 105 // FirewallManager allows you to manage firewalls in multiple threads together |
93 | 106 |
94 class FirewallManager { | 107 class FirewallManager { |
95 public: | 108 public: |
96 FirewallManager(); | 109 FirewallManager(); |
97 ~FirewallManager(); | 110 ~FirewallManager(); |
98 | 111 |
99 void AddServer(FirewallSocketServer * server); | 112 void AddServer(FirewallSocketServer * server); |
100 void RemoveServer(FirewallSocketServer * server); | 113 void RemoveServer(FirewallSocketServer * server); |
101 | 114 |
102 void AddRule(bool allow, FirewallProtocol p = FP_ANY, | 115 void AddRule(bool allow, FirewallProtocol p = FP_ANY, |
103 FirewallDirection d = FD_ANY, | 116 FirewallDirection d = FD_ANY, |
104 const SocketAddress& addr = SocketAddress()); | 117 const SocketAddress& addr = SocketAddress()); |
105 void ClearRules(); | 118 void ClearRules(); |
106 | 119 |
107 private: | 120 private: |
108 CriticalSection crit_; | 121 CriticalSection crit_; |
109 std::vector<FirewallSocketServer *> servers_; | 122 std::vector<FirewallSocketServer *> servers_; |
110 }; | 123 }; |
111 | 124 |
112 } // namespace rtc | 125 } // namespace rtc |
113 | 126 |
114 #endif // WEBRTC_BASE_FIREWALLSOCKETSERVER_H_ | 127 #endif // WEBRTC_BASE_FIREWALLSOCKETSERVER_H_ |
OLD | NEW |