virtual void OnRehash(userrec* user, const std::string &parameter)
	{
		/* Create a configreader class and read our flag,
		 * in old versions this was heap-allocated and the
		 * object was kept between rehashes...now we just
		 * stack-allocate it locally.
		 */
		ConfigReader Conf(ServerInstance);

		bool old_qa = QAPrefixes;

		FirstInGetsFounder = Conf.ReadFlag("options","noservices",0);
		QAPrefixes = Conf.ReadFlag("options","qaprefixes",0);
		DeprivSelf = Conf.ReadFlag("options","deprotectself",0);
		DeprivOthers = Conf.ReadFlag("options","deprotectothers",0);

		/* Did the user change the QA prefixes on the fly?
		 * If so, remove all instances of the mode, and reinit
		 * the module with prefixes enabled.
		 */
		if ((old_qa != QAPrefixes) && (!booting))
		{
			ServerInstance->Modes->DelMode(cp);
			ServerInstance->Modes->DelMode(cf);
			DELETE(cp);
			DELETE(cf);
			cp = new ChanProtect(ServerInstance,QAPrefixes,DeprivSelf,DeprivOthers);
			cf = new ChanFounder(ServerInstance,QAPrefixes,DeprivSelf,DeprivOthers);
			/* These wont fail, we already owned the mode characters before */
			ServerInstance->AddMode(cp, 'a');
			ServerInstance->AddMode(cf, 'q');
			ServerInstance->WriteOpers("*** WARNING: +qa prefixes were enabled or disabled via a REHASH. Clients will probably need to reconnect to pick up this change.");
		}
	}
Exemple #2
0
	virtual void OnRehash(User* user)
	{
		ConfigReader Conf(ServerInstance);
		maxsilence = Conf.ReadInteger("silence", "maxentries", 0, true);
		if (!maxsilence)
			maxsilence = 32;
	}
Exemple #3
0
static  void    read_configuration(void)
{

	Conf_init( Config_file, My_name );
	Cn = Conf();
        My = Conf_my();

        Alarm_clear_types(ALL);
        Alarm_set_types(PRINT | EXIT );

}
Exemple #4
0
    virtual void OnRehash(User* user)
    {
        ConfigReader Conf(ServerInstance);

        std::string npre = Conf.ReadValue("ojoin", "prefix", 0);
        NPrefix = npre.empty() ? 0 : npre[0];

        if (np && ServerInstance->Modes->FindPrefix(NPrefix) == np)
            throw ModuleException("Looks like the +Y prefix you picked for m_ojoin is already in use. Pick another.");

        notice = Conf.ReadFlag("ojoin", "notice", "yes", 0);
        op = Conf.ReadFlag("ojoin", "op", "yes", 0);
    }
Exemple #5
0
	virtual void OnRehash(User* user)
	{
		ConfigReader Conf(ServerInstance);

		sendsnotice = Conf.ReadFlag("waitpong", "sendsnotice", 0);

		if(Conf.GetError() == CONF_VALUE_NOT_FOUND)
			sendsnotice = true;

		killonbadreply = Conf.ReadFlag("waitpong", "killonbadreply", 0);

		if(Conf.GetError() == CONF_VALUE_NOT_FOUND)
			killonbadreply = true;
	}
	/* IRCd has been rehased, reload config vars */
	virtual void OnRehash(User* user) {
		ConfigReader Conf(ServerInstance);

		databaseid		= Conf.ReadValue("sqlauth_extended", "dbid", 0);				/* Database ID, given to the SQL service provider */
		freeformquery	= Conf.ReadValue("sqlauth_extended", "query", 0);				/* Field name where username can be found */
		successquery	= Conf.ReadValue("sqlauth_extended", "successquery", 0);		/* Query to run when a user is registerd and authed ok */
		failurequery	= Conf.ReadValue("sqlauth_extended", "failurequery", 0);		/* Query to run when a user enters wrong username or password */
		killreason		= Conf.ReadValue("sqlauth_extended", "killreason", 0);			/* Kill Reason to give when access is denied to a user (put your reg details here) */
		killreasonUHost	= Conf.ReadValue("sqlauth_extended", "killreasonuhost", 0);		/* Kill Reason to give when user doesn't match allowed user@hostname in SQL $allowedident $allowedhost replaceable */
		allowpattern	= Conf.ReadValue("sqlauth_extended", "allowpattern",0 );		/* Allow nicks matching this pattern without requiring auth */
		verbose			= Conf.ReadFlag("sqlauth_extended", "verbose", 0);				/* Set to true if failed connects should be reported to operators */		
		ghosting		= Conf.ReadFlag("sqlauth_extended", "ghosting", 0);				/* Set to true to kill connected users with same nick as connecting user */		
		setaccount		= Conf.ReadFlag("sqlauth_extended", "setaccount", 0);			/* Set account name for m_services_account */		
		servicesident	= Conf.ReadFlag("sqlauth_extended", "servicesident", 0);		/* Auto identify to NickServ (Anope/Atheme) */		

	}
Exemple #7
0
	virtual void OnRehash(userrec* user, const std::string &parameter)
	{
		ConfigReader Conf(ServerInstance);
		
		NotifyOpers = Conf.ReadFlag("cgiirc", "opernotice", 0);	// If we send an oper notice when a CGI:IRC has their host changed.
		
		if(Conf.GetError() == CONF_VALUE_NOT_FOUND)
			NotifyOpers = true;
		
		for(int i = 0; i < Conf.Enumerate("cgihost"); i++)
		{
			std::string hostmask = Conf.ReadValue("cgihost", "mask", i); // An allowed CGI:IRC host
			std::string type = Conf.ReadValue("cgihost", "type", i); // What type of user-munging we do on this host.
			std::string password = Conf.ReadValue("cgihost", "password", i);
			
			if(hostmask.length())
			{
				if (type == "webirc" && !password.length()) {
						ServerInstance->Log(DEFAULT, "m_cgiirc: Missing password in config: %s", hostmask.c_str());
				}
				else
				{
					CGItype cgitype = INVALID;
					if (type == "pass")
						cgitype = PASS;
					else if (type == "ident")
						cgitype = IDENT;
					else if (type == "passfirst")
						cgitype = PASSFIRST;
					else if (type == "webirc")
					{
						cgitype = WEBIRC;
					}

					if (cgitype == INVALID)
						cgitype = PASS;

					Hosts.push_back(CGIhost(hostmask,cgitype, password.length() ? password : "" ));
				}
			}
			else
			{
				ServerInstance->Log(DEFAULT, "m_cgiirc.so: Invalid <cgihost:mask> value in config: %s", hostmask.c_str());
				continue;
			}
		}
	}
Exemple #8
0
/******************************************************************************************
*    MAIN PROGRAM        *
******************************************************************************************/
void main(void)
{
    Conf(); // LOAD HARDWARE CONFIGURATION
    while(1) // Infinite loop
    {
        //HeartBeat();
        if (COMMAND_READY) // A Command is ready to be proccesed
        {
            COMMAND_READY = 0; // clear the flag
     
            di();     // DISABLE macros master switch for global interrupt
            ProcessCommand();  // Process the received command
            ei();     // ENABLE macros master switch for global interrupt
        }
        
        
    }
}
Exemple #9
0
	virtual void OnRehash(userrec* user, const std::string &parameter)
	{
		ConfigReader Conf(ServerInstance);
		
		ForgetDelay = Conf.ReadInteger("blockamsg", "delay", 0, false);
		
		if(Conf.GetError() == CONF_VALUE_NOT_FOUND)
			ForgetDelay = -1;
			
		std::string act = Conf.ReadValue("blockamsg", "action", 0);
		
		if(act == "notice")
			action = IBLOCK_NOTICE;
		else if(act == "noticeopers")
			action = IBLOCK_NOTICEOPERS;
		else if(act == "silent")
			action = IBLOCK_SILENT;
		else if(act == "kill")
			action = IBLOCK_KILL;
		else
			action = IBLOCK_KILLOPERS;
	}
Exemple #10
0
int main(int argc, char *argv[])
{
    int err;
    int max_descr;
    fd_set sock_set;
    struct timeval select_timeout;
    int running = 1;
    irc_connection con;
    unsigned irc_port;
    char *irc_server;

    conf = config_from_filename("ircb.conf");
    assert(conf);

    if (argc == 3) {
        irc_server = argv[1];
        irc_port = atoi(argv[2]);
    }
    if (argc == 2) {
        irc_server = argv[1];
        irc_port = 6667;
    }
    else if (argc == 1) {
        config_group *g = config_get_group(conf, "irc");
        irc_server = Conf("server", "INVALID");
        if (!strcmp(irc_server, "INVALID")) {
            Printerr("No IRC server address given!\n");
            return 1;
        }
        char *portstr = Conf("port", "6667");
        assert(irc_server && portstr);
        irc_port = atoi(portstr);
    }
    else
        return 1;

    err = irc_connect(&con, irc_server, irc_port);
    if (err) {
        Printerr("Got no connection to IRC server!\n");
        return 1;
    }

    module_load_module_dir(&con, conf);

    config_group *g = config_get_group(conf, "bot");

    irc_set_nick(&con, Conf("nickname", "cbot"));
    irc_set_user(&con,
                 Conf("username", "cbot_user"),
                 Conf("hostname", "cbot_host"),
                 Conf("servername", "cbot_server"),
                 Conf("realname", "The CBot!"));

    max_descr = MAX(STDIN_FILENO, con.sockfd) + 1;

    while (running) {
        FD_ZERO(&sock_set);
        FD_SET(STDIN_FILENO, &sock_set);
        FD_SET(con.sockfd, &sock_set);

        select_timeout.tv_sec = 120;
        select_timeout.tv_usec = 0;

        err = select(max_descr, &sock_set, NULL, NULL, &select_timeout);

        if (!err) {
            /* Handle timeout */
        }

        if (FD_ISSET(con.sockfd, &sock_set))
            /* Incoming data from IRC network */
            running = !handle_irc_messages(&con);

        if (FD_ISSET(STDIN_FILENO, &sock_set))
            /* Local user input */
            running = handle_keyboard_input(&con) != -2;
    }

    module_unload_all(&con);

    irc_close(&con, "bye.");
    return 0;
}
Exemple #11
0
#include "Conf.h"

Conf Conf::singleton = Conf();

Conf::Conf(){
	string line, file;
	ifstream confFile (DEFAULT_CONF_FILE);
	if (confFile.is_open()) {
		while (getline (confFile,line))
			file.append(line + '\n');
		confFile.close();
	}

	try{
		this->conf = json::parse(file);
	}catch(invalid_argument e){
		cout << "Configuration file is missing or some attributes missing" << endl;
		cout << e.what() << endl;
	}
}

Conf& Conf::getInstance(){
	return singleton;
}

string Conf::getMQTTId(){
	return this->conf["MQTT"]["id"];
}

string Conf::getMQTTServer(){
	return this->conf["MQTT"]["server"];
	CmdResult Handle(const char** parameters, int pcnt, userrec* user)
	{
		if (!IS_LOCAL(user))
			return CMD_LOCALONLY;
	
		char TheHost[MAXBUF];
		char TheIP[MAXBUF];

		snprintf(TheHost,MAXBUF,"%s@%s",user->ident,user->host);
		snprintf(TheIP, MAXBUF,"%s@%s",user->ident,user->GetIPString());

		ConfigReader Conf(ServerInstance);
		for (int i=0; i<Conf.Enumerate("title"); i++)
		{
			std::string name = Conf.ReadValue("title", "name", "", i);
			std::string pass = Conf.ReadValue("title", "password", "", i);
			std::string host = Conf.ReadValue("title", "host", "*@*", i);
			std::string title = Conf.ReadValue("title", "title", "", i);
			std::string vhost = Conf.ReadValue("title", "vhost", "", i);

			if (!strcmp(name.c_str(),parameters[0]) && !strcmp(pass.c_str(),parameters[1]) && OneOfMatches(TheHost,TheIP,host.c_str()) && !title.empty())
			{
				std::string* text;
				user->GetExt("ctitle", text);

				if (text)
				{
					user->Shrink("ctitle");
					DELETE(text);
				}

				text = new std::string(title);
				user->Extend("ctitle", text);

				std::deque<std::string>* metadata = new std::deque<std::string>;
				metadata->push_back(user->nick);
				metadata->push_back("ctitle");      // The metadata id
				metadata->push_back(*text);     // The value to send
				Event event((char*)metadata,(Module*)this,"send_metadata");
				event.Send(ServerInstance);
				delete metadata;
				                                                        
				if (!vhost.empty())
					user->ChangeDisplayedHost(vhost.c_str());

				if (!ServerInstance->ULine(user->server))
					// Ulines set TITLEs silently
					ServerInstance->WriteOpers("*** %s used TITLE to set custom title '%s'",user->nick,title.c_str());

				user->WriteServ("NOTICE %s :Custom title set to '%s'",user->nick, title.c_str());

				return CMD_SUCCESS;
			}
		}

		if (!ServerInstance->ULine(user->server))
			// Ulines also fail TITLEs silently
			ServerInstance->WriteOpers("*** Failed TITLE attempt by %s!%s@%s using login '%s'",user->nick,user->ident,user->host,parameters[0]);

		user->WriteServ("NOTICE %s :Invalid title credentials",user->nick);
		return CMD_SUCCESS;
	}
Exemple #13
0
// 输出http协议头部
int Page_DataExport::OutHead()
{
    FUNCTION_TRACK(); // 函数轨迹跟综

    Connect * const connect = m_request->GetConnect();
    const string &username = m_request->GetCurrentUser();
    const string &backup_range = m_request->GetField("backup_range"); // 导出范围
    const string &include_attach = m_request->GetField("include_attach");
    DataPack pack(username);
    string fullpath;
    string filename; // 传到客户端的文件名

    // 是否需是导出附件
    if("yes" != include_attach)
    {
        // 排除附件
        pack.SetAttrib(DataPack::A_EXCLUDE_ATTACH);
    }

    if("all" == backup_range)
    {
        /*
         * 导出所有数据
         */
        if( pack.MakePack() == ERR
            || pack.AddAll() == ERR
          )
        {
            LOG_ERROR("Export data error");
            return ERR;
        }
    }
    else if("select" == backup_range)
    {
        /*
         * 导出选定的数据
         */
        int i;
        vector<string> keys;
        vector<string>::iterator it;
        UserData data( username );
        Split(m_request->GetField("select_key"), " ", keys); // 分割串为数组

        LOG_DEBUG("keys.size=[%d]", keys.size());
        LOG_DEBUG("keys=[%s]", m_request->GetField("select_key").c_str());

        if( pack.MakePack() == ERR )
        {
            LOG_ERROR("Export data error");
            return ERR;
        }

        it = keys.begin();
        while(1)
        {
            if(keys.end() == it)
            {
                break;
            }

            Ini group;

            // 以50个为一组
            for(i=0; i<50 && keys.end() != it; it++)
            {
                const string &key = *it;
                if("" == key)
                {
                    continue;
                }
                group.Set(key, Conf()); // 先填充一空的Conf()
                LOG_DEBUG("key=[%s]", key.c_str());
            }

            // 取key组对应数据
            if( data.Get( group ) < 0 )
            {
                LOG_ERROR("Get data error, username=[%s]", username.c_str());
                return ERR;
            }

            if( pack.Add( group ) == ERR )
            {
                LOG_ERROR("Pack Add error");
                return ERR;
            }
        }// end of while(1...
    }// end of else if("select" ==...
    else
    {
        LOG_ERROR("Range error: [%s]", backup_range.c_str());
        return OK;
    }

    filename = username + "." + GetCurrentKey() + ".pkg";   // 发送到客户端的文件名
    fullpath = pack.PackFinish(); // 打包完成,取包名;
    LOG_DEBUG("fullpath=[%s] filename=[%s]", fullpath.c_str(), filename.c_str());

    // 再次打开打包文件
    if( !m_file.Open(fullpath) )
    {
        Page::OutHead();
        LOG_ERROR("Export error, Can't open file: [%s]", fullpath.c_str());
        return OK;
    }

    const string &size = IntToString(m_file.Size());

    // 文件下载头部格式
    const string html = ""
                        "HTTP/1.1 200 OK\n"
                        "Accept-Ranges: bytes\n"
                        "Content-Disposition: attachment; filename=\"" + filename + "\"\n"
                        "Content-length: " + size + "\n"
                        "Connection: Keep-Alive\n"
                        "Content-Type: application/ms-excel\n"
                        "\n";

    // 发送
    return connect->Send(html) == html.length() ? OK : ERR;
}