mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
Ported branch commits 2980/1: cleaned the code in IP address lists management. Removed some bugs. Changed the strategy a bit: only keep the most recent port for identical ips. Changed the interface of extAddrFinder to make it mroe secure.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2983 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
591a141a18
commit
757aa7a95d
6 changed files with 346 additions and 313 deletions
|
@ -72,7 +72,7 @@ void sockaddr_clear(struct sockaddr_in *addr)
|
|||
}
|
||||
|
||||
|
||||
bool isValidNet(struct in_addr *addr)
|
||||
bool isValidNet(const struct in_addr *addr)
|
||||
{
|
||||
// invalid address.
|
||||
if((*addr).s_addr == INADDR_NONE)
|
||||
|
@ -84,13 +84,13 @@ bool isValidNet(struct in_addr *addr)
|
|||
}
|
||||
|
||||
|
||||
bool isLoopbackNet(struct in_addr *addr)
|
||||
bool isLoopbackNet(const struct in_addr *addr)
|
||||
{
|
||||
in_addr_t taddr = ntohl(addr->s_addr);
|
||||
return (taddr == (127 << 24 | 1));
|
||||
}
|
||||
|
||||
bool isPrivateNet(struct in_addr *addr)
|
||||
bool isPrivateNet(const struct in_addr *addr)
|
||||
{
|
||||
in_addr_t taddr = ntohl(addr->s_addr);
|
||||
|
||||
|
@ -111,7 +111,7 @@ bool isPrivateNet(struct in_addr *addr)
|
|||
}
|
||||
}
|
||||
|
||||
bool isExternalNet(struct in_addr *addr)
|
||||
bool isExternalNet(const struct in_addr *addr)
|
||||
{
|
||||
if (!isValidNet(addr))
|
||||
{
|
||||
|
|
|
@ -65,10 +65,10 @@ uint64_t htonll(uint64_t x);
|
|||
void sockaddr_clear(struct sockaddr_in *addr);
|
||||
|
||||
/* determine network type (moved from pqi/pqinetwork.cc) */
|
||||
bool isValidNet(struct in_addr *addr);
|
||||
bool isLoopbackNet(struct in_addr *addr);
|
||||
bool isPrivateNet(struct in_addr *addr);
|
||||
bool isExternalNet(struct in_addr *addr);
|
||||
bool isValidNet(const struct in_addr *addr);
|
||||
bool isLoopbackNet(const struct in_addr *addr);
|
||||
bool isPrivateNet(const struct in_addr *addr);
|
||||
bool isExternalNet(const struct in_addr *addr);
|
||||
|
||||
/* convert addresses */
|
||||
bool getIPAddressFromString (const char *addr_str, struct in_addr *addr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue