Skip to content
Permalink
Browse files

Allow multiple IP addresses in extforward_ip separated by spaces

  • Loading branch information...
linuxdaemon authored and Adam- committed Jan 4, 2019
1 parent 6fbb7cf commit cf44418e1055376adb1e5d284f2a174b7751f39b
Showing with 5 additions and 4 deletions.
  1. +2 −1 data/modules.example.conf
  2. +1 −1 include/modules/httpd.h
  3. +2 −2 modules/m_httpd.cpp
@@ -223,8 +223,9 @@ module { name = "help" }
* extforward_headers set below, set this to its IP.
* This allows services to obtain the real IP of users by
* reading the forwarded-for HTTP header.
* Multiple IP addresses can be specified separated by a space character.
*/
#extforward_ip = "192.168.0.255"
#extforward_ip = "192.168.0.255 192.168.1.255"

/* The header to look for. These probably work as is. */
extforward_header = "X-Forwarded-For Forwarded-For"
@@ -141,7 +141,7 @@ class HTTPProvider : public ListenSocket, public Service
unsigned short port;
bool ssl;
public:
Anope::string ext_ip;
std::vector<Anope::string> ext_ips;
std::vector<Anope::string> ext_headers;

HTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, bool s) : ListenSocket(i, p, i.find(':') != Anope::string::npos), Service(c, "HTTPProvider", n), ip(i), port(p), ssl(s) { }
@@ -67,7 +67,7 @@ class MyHTTPClient : public HTTPClient
return;
}

if (this->ip == this->provider->ext_ip)
if (std::find(this->provider->ext_ips.begin(), this->provider->ext_ips.end(), this->ip) != this->provider->ext_ips.end())
{
for (unsigned i = 0; i < this->provider->ext_headers.size(); ++i)
{
@@ -435,7 +435,7 @@ class HTTPD : public Module
}


p->ext_ip = ext_ip;
spacesepstream(ext_ip).GetTokens(p->ext_ips);
spacesepstream(ext_header).GetTokens(p->ext_headers);
}

0 comments on commit cf44418

Please sign in to comment.
You can’t perform that action at this time.