mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 09:06:21 +01:00
Combine SockAddr::localhost() and isLocalHost()
This commit is contained in:
parent
b03cc0e07d
commit
1d10bf7d5e
@ -238,7 +238,7 @@ namespace mongo {
|
||||
|
||||
bool allowed( const char * rq , vector<string>& headers, const SockAddr &from ){
|
||||
|
||||
if ( from.localhost() )
|
||||
if ( from.isLocalHost() )
|
||||
return true;
|
||||
|
||||
Client::GodScope gs;
|
||||
|
10
util/sock.h
10
util/sock.h
@ -115,14 +115,6 @@ namespace mongo {
|
||||
template <typename T>
|
||||
const T& as() const { return *(const T*)(&sa); }
|
||||
|
||||
bool isLocalHost() const {
|
||||
#if defined(_WIN32)
|
||||
return as<sockaddr_in>().sin_addr.S_un.S_addr == 0x100007f;
|
||||
#else
|
||||
return as<sockaddr_in>().sin_addr.s_addr == 0x100007f;
|
||||
#endif
|
||||
}
|
||||
|
||||
string toString(bool includePort=true) const{
|
||||
stringstream out;
|
||||
out << inet_ntoa(as<sockaddr_in>().sin_addr);
|
||||
@ -139,7 +131,7 @@ namespace mongo {
|
||||
return as<sockaddr_in>().sin_port;
|
||||
}
|
||||
|
||||
bool localhost() const { return inet_addr( "127.0.0.1" ) == as<sockaddr_in>().sin_addr.s_addr; }
|
||||
bool isLocalHost() const { return inet_addr( "127.0.0.1" ) == as<sockaddr_in>().sin_addr.s_addr; }
|
||||
|
||||
bool operator==(const SockAddr& r) const {
|
||||
return as<sockaddr_in>().sin_addr.s_addr == r.as<sockaddr_in>().sin_addr.s_addr &&
|
||||
|
Loading…
Reference in New Issue
Block a user