/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
// Accept the connection.
SocketListener::ShibSocket newsock;
- if (!accept(m_socket, newsock))
+ if (!accept(m_socket, newsock)) {
log->crit("failed to accept incoming socket connection");
+ continue;
+ }
// We throw away the result because the children manage themselves...
try {
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
string m_address;
unsigned short m_port;
- vector<string> m_acl;
+ set<string> m_acl;
};
ListenerService* SHIBSP_DLLLOCAL TCPListenerServiceFactory(const DOMElement* const & e)
int j = 0;
for (unsigned int i=0; i < sockacl.length(); i++) {
if (sockacl.at(i)==' ') {
- m_acl.push_back(sockacl.substr(j, i-j));
+ m_acl.insert(sockacl.substr(j, i-j));
j = i+1;
}
}
- m_acl.push_back(sockacl.substr(j, sockacl.length()-j));
+ m_acl.insert(sockacl.substr(j, sockacl.length()-j));
}
}
else
- m_acl.push_back("127.0.0.1");
+ m_acl.insert("127.0.0.1");
}
void TCPListener::setup_tcp_sockaddr(struct sockaddr_in* addr) const
#endif
return log_error();
char* client=inet_ntoa(addr.sin_addr);
- for (vector<string>::const_iterator i=m_acl.begin(); i!=m_acl.end(); i++) {
- if (*i==client)
- return true;
+ if (m_acl.count(client) == 0) {
+ close(s);
+ s=-1;
+ log->error("accept() rejected client at %s", client);
+ return false;
}
- close(s);
- s=-1;
- log->error("accept() rejected client at %s\n",client);
- return false;
+ return true;
}