Commit ad95b31c authored by rakshasa's avatar rakshasa

Use inet6 if bind is not set.

parent a6b67331
......@@ -61,7 +61,8 @@ Listen::open(uint16_t first, uint16_t last, int backlog, const rak::socket_addre
if (first == 0 || first > last)
throw input_error("Tried to open listening port with an invalid range.");
if (bindAddress->family() != rak::socket_address::af_inet &&
if (bindAddress->family() != 0 &&
bindAddress->family() != rak::socket_address::af_inet &&
bindAddress->family() != rak::socket_address::af_inet6)
throw input_error("Listening socket must be bound to an inet or inet6 address.");
......@@ -71,7 +72,13 @@ Listen::open(uint16_t first, uint16_t last, int backlog, const rak::socket_addre
throw resource_error("Could not allocate socket for listening.");
rak::socket_address sa;
sa.copy(*bindAddress, bindAddress->length());
// TODO: Temporary until we refactor:
if (bindAddress->family() == 0) {
sa.sa_inet6()->clear();
} else {
sa.copy(*bindAddress, bindAddress->length());
}
do {
sa.set_port(first);
......
......@@ -4,13 +4,17 @@
#ifndef LIBTORRENT_UTILS_SOCKET_ADDRESS_KEY_H
#define LIBTORRENT_UTILS_SOCKET_ADDRESS_KEY_H
#include <string>
#include <inttypes.h>
#include <netinet/in.h>
// Unique key for the socket address, excluding port numbers, etc.
// TODO: Add include files...
namespace torrent {
class LIBTORRENT_EXPORT socket_address_key {
class socket_address_key {
public:
// TODO: Disable default ctor?
......
......@@ -62,7 +62,7 @@ namespace torrent {
ipv4_table PeerList::m_ipv4_table;
// Clean up...
// TODO: Clean up...
bool
socket_address_less(const sockaddr* s1, const sockaddr* s2) {
const rak::socket_address* sa1 = rak::socket_address::cast_from(s1);
......@@ -87,12 +87,6 @@ socket_address_less(const sockaddr* s1, const sockaddr* s2) {
}
}
// inline bool
// socket_address_key::is_comparable(const sockaddr* sa) {
// return rak::socket_address::cast_from(sa)->family() == rak::socket_address::af_inet ||
// rak::socket_address::cast_from(sa)->family() == rak::socket_address::af_inet6;
// }
struct peer_list_equal_port : public std::binary_function<PeerList::reference, uint16_t, bool> {
bool operator () (PeerList::reference p, uint16_t port) {
return rak::socket_address::cast_from(p.second->socket_address())->port() == port;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment