Exemple #1
0
static void shutdown()
{
    std::ofstream bans(BANFILE, std::ios::binary);

    if(!bans.is_open()) return;

    for(netban_vector::iterator it = netbans.begin(); it != netbans.end(); ++it)
    {
        bans.write(reinterpret_cast<char *>(&*it), sizeof(netban));
    }

    bans.close();
}
Exemple #2
0
/* :0MC BMASK 1350157102 #channel b :*!*@*.test.com */
void hybrid::BMask::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
	Channel *c = Channel::Find(params[1]);
	ChannelMode *mode = ModeManager::FindChannelModeByChar(params[2][0]);

	if (c && mode)
	{
		spacesepstream bans(params[3]);
		Anope::string token;
		while (bans.GetToken(token))
			c->SetModeInternal(source, mode, token);
	}
}
Exemple #3
0
void init()
{
    signal_shutdown.connect(boost::bind(&shutdown));

    std::ifstream bans(BANFILE, std::ios::binary);
    if(!bans.is_open()) return;

    std::streampos size;

    size = bans.tellg();
    bans.seekg(0, std::ios::end);
    size = bans.tellg() - size;
    bans.seekg(0, std::ios::beg);

    if(size % sizeof(netban) != 0)
    {
        bans.close();
        std::cerr << "Network ban file (" << BANFILE << ") is corrupted. Removing it" << std::endl;
        remove(BANFILE);

        return;
    }

    for(std::size_t i = 0; i < (size / sizeof(netban)); ++i)
    {
        char buf[sizeof(netban)];
        netban * nb = reinterpret_cast<netban *>(buf);

        bans.read(buf, sizeof(netban));
        nb->null_terminate_reason();

        if (!nb->is_valid()) continue;

        netbans.push_back(*nb);
    }

    if(false && netbans.size())
    {
        const char * p = netbans.size() != 1 ? "s" : "";
        std::cout << "Loaded " << netbans.size() << " network ban" << p << std::endl;
    }

    bans.close();
}