summarylogtreecommitdiffstats
path: root/tracker-ipv6.patch
blob: 226d92835f93dd2191bc65ebf1a88736be3162b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
diff --git a/src/torrent/connection_manager.cc b/src/torrent/connection_manager.cc
index ea5efc58..976ec696 100644
--- a/src/torrent/connection_manager.cc
+++ b/src/torrent/connection_manager.cc
@@ -1,45 +1,10 @@
-// libTorrent - BitTorrent library
-// Copyright (C) 2005-2011, Jari Sundell
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-// In addition, as a special exception, the copyright holders give
-// permission to link the code of portions of this program with the
-// OpenSSL library under certain conditions as described in each
-// individual source file, and distribute linked combinations
-// including the two.
-//
-// You must obey the GNU General Public License in all respects for
-// all of the code used other than OpenSSL.  If you modify file(s)
-// with this exception, you may extend this exception to your version
-// of the file(s), but you are not obligated to do so.  If you do not
-// wish to do so, delete this exception statement from your version.
-// If you delete this exception statement from all source files in the
-// program, then also delete it here.
-//
-// Contact:  Jari Sundell <jaris@ifi.uio.no>
-//
-//           Skomakerveien 33
-//           3185 Skoppum, NORWAY
-
 #include "config.h"
 
 #include <sys/types.h>
 
 #include <rak/address_info.h>
 #include <rak/socket_address.h>
+#include <net/socket_address.h>
 
 #include "net/listen.h"
 
@@ -70,10 +35,10 @@ resolve_host(const char* host, int family, int socktype, ConnectionManager::slot
   rak::socket_address sa;
   sa.copy(*ai->address(), ai->length());
   rak::address_info::free_address_info(ai);
-  
+
   if (manager->main_thread_main()->is_current())
     thread_base::acquire_global_lock();
-  
+
   slot(sa.c_sockaddr(), 0);
   return NULL;
 }
@@ -174,6 +139,12 @@ ConnectionManager::set_proxy_address(const sockaddr* sa) {
 
 uint32_t
 ConnectionManager::filter(const sockaddr* sa) {
+  if (!sa_is_any(sa)) {
+    if ((m_block_ipv4 && sa_is_inet(sa)) ||
+        (m_block_ipv6 && sa_is_inet6(sa)))
+      return 0;
+  }
+
   if (!m_slot_filter)
     return 1;
   else
diff --git a/src/torrent/connection_manager.h b/src/torrent/connection_manager.h
index 09ccdd28..2c44357f 100644
--- a/src/torrent/connection_manager.h
+++ b/src/torrent/connection_manager.h
@@ -1,41 +1,3 @@
-// libTorrent - BitTorrent library
-// Copyright (C) 2005-2011, Jari Sundell
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-// In addition, as a special exception, the copyright holders give
-// permission to link the code of portions of this program with the
-// OpenSSL library under certain conditions as described in each
-// individual source file, and distribute linked combinations
-// including the two.
-//
-// You must obey the GNU General Public License in all respects for
-// all of the code used other than OpenSSL.  If you modify file(s)
-// with this exception, you may extend this exception to your version
-// of the file(s), but you are not obligated to do so.  If you do not
-// wish to do so, delete this exception statement from your version.
-// If you delete this exception statement from all source files in the
-// program, then also delete it here.
-//
-// Contact:  Jari Sundell <jaris@ifi.uio.no>
-//
-//           Skomakerveien 33
-//           3185 Skoppum, NORWAY
-
-// Add some helpfull words here.
-
 #ifndef LIBTORRENT_CONNECTION_MANAGER_H
 #define LIBTORRENT_CONNECTION_MANAGER_H
 
@@ -106,7 +68,7 @@ public:
 
   ConnectionManager();
   ~ConnectionManager();
-  
+
   // Check that we have not surpassed the max number of open sockets
   // and that we're allowed to connect to the socket address.
   //
@@ -129,7 +91,7 @@ public:
   void                set_priority(priority_type p)           { m_priority = p; }
   void                set_send_buffer_size(uint32_t s);
   void                set_receive_buffer_size(uint32_t s);
-  void                set_encryption_options(uint32_t options); 
+  void                set_encryption_options(uint32_t options);
 
   // Setting the addresses creates a copy of the address.
   const sockaddr*     bind_address() const                    { return m_bindAddress; }
@@ -144,7 +106,7 @@ public:
   void                set_filter(const slot_filter_type& s)   { m_slot_filter = s; }
 
   bool                listen_open(port_type begin, port_type end);
-  void                listen_close();  
+  void                listen_close();
 
   // Since trackers need our port number, it doesn't get cleared after
   // 'listen_close()'. The client may change the reported port number,
@@ -208,4 +170,3 @@ private:
 }
 
 #endif
-