-
-
Save SISheogorath/c3e2a6cd08ffd51897a7dcea422f1a43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* InspIRCd -- Internet Relay Chat Daemon | |
* | |
* Copyright (C) 2016 Christoph (Sheogorath) Kern <sheogorath@shivering-isles.com> | |
* | |
* This file is part of InspIRCd. InspIRCd is free software: you can | |
* redistribute it and/or modify it under the terms of the GNU General Public | |
* License as published by the Free Software Foundation, version 2. | |
* | |
* This program is distributed in the hope that it will be useful, but WITHOUT | |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
* details. | |
* | |
* You should have received a copy of the GNU General Public License | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
*/ | |
#include "inspircd.h" | |
#include "httpd.h" | |
#include "protocol.h" | |
/* $ModDesc: Provides rehash over HTTP via m_httpd.so IMPORTANT: Don't use this module for regular setups */ | |
class ModuleHttpRehash : public Module | |
{ | |
public: | |
void init() | |
{ | |
Implementation eventlist[] = { I_OnEvent }; | |
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); | |
} | |
void OnEvent(Event& event) | |
{ | |
std::stringstream data(""); | |
if (event.id == "httpd_url") | |
{ | |
ServerInstance->Logs->Log("m_http_rehash", DEBUG,"Handling httpd event"); | |
HTTPRequest* http = (HTTPRequest*)&event; | |
if ((http->GetURI() == "/rehash") || (http->GetURI() == "/rehash/")) | |
{ | |
FOREACH_MOD(I_OnPreRehash,OnPreRehash(ServerInstance->FakeClient, "")); | |
if (!ServerInstance->ConfigThread) | |
{ | |
HTTPDocumentResponse response(this, *http, &data, 201); | |
ServerInstance->RehashUsersAndChans(); | |
FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect()); | |
ServerInstance->ConfigThread = new ConfigReaderThread(ServerInstance->FakeClient->uuid); | |
ServerInstance->Threads->Start(ServerInstance->ConfigThread); | |
} else | |
HTTPDocumentResponse response(this, *http, &data, 409); | |
} | |
} | |
} | |
virtual Version GetVersion() | |
{ | |
return Version("Provides rehash over HTTP via m_httpd.so", VF_VENDOR); | |
} | |
}; | |
MODULE_INIT(ModuleHttpRehash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment