mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-11 11:39:02 -04:00
Fixed all that, back to the crash we had before (yay?)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8583 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
8f0f9654f8
commit
9b3f282196
@ -338,8 +338,6 @@ void DNS::Rehash()
|
||||
this->ip6munge = true;
|
||||
}
|
||||
|
||||
printf("dns server: %s\n", ServerInstance->Config->DNSServer);
|
||||
|
||||
this->socketfamily = AF_INET;
|
||||
#ifdef IPV6
|
||||
if (strchr(ServerInstance->Config->DNSServer,':'))
|
||||
|
@ -23,6 +23,7 @@ typedef std::map<std::string,std::string> HeaderMap;
|
||||
|
||||
const char* HTTP_CLIENT_RESPONSE = "HTTPCLIENT_RESPONSE";
|
||||
const char* HTTP_CLIENT_REQUEST = "HTTPCLIENT_REQUEST";
|
||||
const char* HTTP_CLIENT_ERROR = "HTTPCLIENT_ERROR";
|
||||
|
||||
/** This class represents an outgoing HTTP request
|
||||
*/
|
||||
@ -67,6 +68,26 @@ class HTTPClientRequest : public Request
|
||||
}
|
||||
};
|
||||
|
||||
class HTTPClientError : public Request
|
||||
{
|
||||
protected:
|
||||
friend class HTTPSocket;
|
||||
std::string url;
|
||||
int response;
|
||||
std::string responsestr;
|
||||
HeaderMap Headers;
|
||||
public:
|
||||
HTTPClientError(Module* src, Module* target, const std::string &url, int response)
|
||||
: Request(src, target, HTTP_CLIENT_ERROR), url(url), response(response)
|
||||
{
|
||||
}
|
||||
|
||||
const std::string &GetURL()
|
||||
{
|
||||
return url;
|
||||
}
|
||||
};
|
||||
|
||||
class HTTPClientResponse : public Request
|
||||
{
|
||||
protected:
|
||||
|
@ -70,8 +70,7 @@ class HTTPResolver : public Resolver
|
||||
void OnError(ResolverError e, const string &errmsg)
|
||||
{
|
||||
ServerInstance->Log(DEBUG,"HTTPResolver::OnError");
|
||||
/*if (ServerInstance->SocketCull.find(socket) == ServerInstance->SocketCull.end())
|
||||
ServerInstance->SocketCull[socket] = socket;*/
|
||||
socket->OnClose();
|
||||
}
|
||||
};
|
||||
|
||||
@ -150,13 +149,17 @@ bool HTTPSocket::DoRequest(HTTPClientRequest *req)
|
||||
this->port = url.port;
|
||||
strlcpy(this->host, url.domain.c_str(), MAXBUF);
|
||||
|
||||
/*
|
||||
bool cached;
|
||||
HTTPResolver* r = new HTTPResolver(this, Server, url.domain, cached, (Module*)Mod);
|
||||
Instance->AddResolver(r, cached);
|
||||
return true;
|
||||
*/
|
||||
Connect(url.domain);
|
||||
in6_addr s6;
|
||||
in_addr s4;
|
||||
/* Doesnt look like an ipv4 or an ipv6 address */
|
||||
if ((inet_pton(AF_INET6, url.domain.c_str(), &s6) < 1) && (inet_pton(AF_INET, url.domain.c_str(), &s4) < 1))
|
||||
{
|
||||
bool cached;
|
||||
HTTPResolver* r = new HTTPResolver(this, Server, url.domain, cached, (Module*)Mod);
|
||||
Instance->AddResolver(r, cached);
|
||||
}
|
||||
else
|
||||
Connect(url.domain);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -334,8 +337,14 @@ void HTTPSocket::OnClose()
|
||||
{
|
||||
Instance->Log(DEBUG,"HTTPSocket::OnClose");
|
||||
if (data.empty())
|
||||
return; // notification that request failed?
|
||||
{
|
||||
HTTPClientError* err = new HTTPClientError((Module*)Mod, req.GetSource(), req.GetURL(), 0);
|
||||
err->Send();
|
||||
delete err;
|
||||
return;
|
||||
}
|
||||
|
||||
Instance->Log(DEBUG,"Set data and send");
|
||||
response->data = data;
|
||||
response->Send();
|
||||
delete response;
|
||||
|
@ -42,9 +42,9 @@ class ModuleRemoteInclude : public Module
|
||||
|
||||
char* OnRequest(Request* req)
|
||||
{
|
||||
HTTPClientResponse* resp = (HTTPClientResponse*)req;
|
||||
if(!strcmp(resp->GetId(), HTTP_CLIENT_RESPONSE))
|
||||
if (!strcmp(req->GetId(), HTTP_CLIENT_RESPONSE))
|
||||
{
|
||||
HTTPClientResponse* resp = (HTTPClientResponse*)req;
|
||||
ServerInstance->Log(DEBUG, "Got http file for %s", resp->GetURL().c_str());
|
||||
|
||||
std::map<std::string, std::stringstream*>::iterator n = assoc.find(resp->GetURL());
|
||||
@ -64,7 +64,18 @@ class ModuleRemoteInclude : public Module
|
||||
*/
|
||||
assoc.erase(n);
|
||||
}
|
||||
else if (!strcmp(req->GetId(), HTTP_CLIENT_ERROR))
|
||||
{
|
||||
HTTPClientError* resp = (HTTPClientError*)req;
|
||||
|
||||
ServerInstance->Log(DEBUG, "Got http error when accessing %s", resp->GetURL().c_str());
|
||||
ServerInstance->Config->Complete(resp->GetURL(), true);
|
||||
|
||||
std::map<std::string, std::stringstream*>::iterator n = assoc.find(resp->GetURL());
|
||||
|
||||
if (n != assoc.end())
|
||||
assoc.erase(n);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user