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

Unified Diff: webrtc/base/firewallsocketserver.cc

Issue 2936553003: Adding PortAllocator option to support cases where sockets can't be bound. (Closed)
Patch Set: Minor changes (comments, renaming, etc.) Created 3 years, 6 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 | « webrtc/base/firewallsocketserver.h ('k') | webrtc/base/natsocketfactory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/firewallsocketserver.cc
diff --git a/webrtc/base/firewallsocketserver.cc b/webrtc/base/firewallsocketserver.cc
index 30e5c3bfaa8c14a6cc4b9edaff4610763bd96d8a..4a2a4048f37684bc4c2e0cc7838e984cf0269ee9 100644
--- a/webrtc/base/firewallsocketserver.cc
+++ b/webrtc/base/firewallsocketserver.cc
@@ -24,6 +24,14 @@ class FirewallSocket : public AsyncSocketAdapter {
: AsyncSocketAdapter(socket), server_(server), type_(type) {
}
+ int Bind(const SocketAddress& addr) override {
+ if (!server_->IsBindableIp(addr.ipaddr())) {
+ SetError(EINVAL);
+ return SOCKET_ERROR;
+ }
+ return AsyncSocketAdapter::Bind(addr);
+ }
+
int Connect(const SocketAddress& addr) override {
if (type_ == SOCK_STREAM) {
if (!server_->Check(FP_TCP, GetLocalAddress(), addr)) {
@@ -176,6 +184,16 @@ bool FirewallSocketServer::Check(FirewallProtocol p,
return true;
}
+void FirewallSocketServer::SetUnbindableIps(
+ const std::vector<rtc::IPAddress>& unbindable_ips) {
+ unbindable_ips_ = unbindable_ips;
+}
+
+bool FirewallSocketServer::IsBindableIp(const rtc::IPAddress& ip) {
+ return std::find(unbindable_ips_.begin(), unbindable_ips_.end(), ip) ==
+ unbindable_ips_.end();
+}
+
Socket* FirewallSocketServer::CreateSocket(int type) {
return CreateSocket(AF_INET, type);
}
« no previous file with comments | « webrtc/base/firewallsocketserver.h ('k') | webrtc/base/natsocketfactory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698