Ejemplo n.º 1
0
		virtual int OnKill(userrec* source, userrec* dest, const std::string &reason)
		{
			long dest_level = 0,source_level = 0;

			// oper killing an oper?
			if (IS_OPER(dest) && IS_OPER(source))
			{
				for (int j =0; j < conf->Enumerate("type"); j++)
				{
					std::string typen = conf->ReadValue("type","name",j);
					if (!strcmp(typen.c_str(),dest->oper))
					{
						dest_level = conf->ReadInteger("type","level",j,true);
						break;
					}
				}
				for (int k =0; k < conf->Enumerate("type"); k++)
				{
					std::string typen = conf->ReadValue("type","name",k);
					if (!strcmp(typen.c_str(),source->oper))
					{
						source_level = conf->ReadInteger("type","level",k,true);
						break;
					}
				}
				if (dest_level > source_level)
				{
					ServerInstance->WriteOpers("Oper %s (level %d) attempted to /kill a higher oper: %s (level %d): Reason: %s",source->nick,source_level,dest->nick,dest_level,reason.c_str());
					dest->WriteServ("NOTICE %s :Oper %s attempted to /kill you!",dest->nick,source->nick);
					source->WriteServ("481 %s :Permission Denied - Oper %s is a higher level than you",source->nick,dest->nick);
					return 1;
				}
			}
			return 0;
		}
Ejemplo n.º 2
0
	virtual void OnRehash(const std::string &parameter)
	{
		// reload our config file on rehash - we must destroy and re-allocate the classes
		// to call the constructor again and re-read our data.
		ConfigReader* Conf = new ConfigReader(ServerInstance);
		std::string filterfile = Conf->ReadValue("filter","file",0);
		// this automatically re-reads the configuration file into the class
		ConfigReader* MyConf = new ConfigReader(ServerInstance, filterfile);
		if ((filterfile == "") || (!MyConf->Verify()))
		{
			// bail if the user forgot to create a config file
			FilterException e;
			throw(e);
		}
		for (filter_t::iterator n = filters.begin(); n != filters.end(); n++)
		{
			DELETE(n->second);
		}
		filters.clear();
		for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
		{
			std::string pattern = MyConf->ReadValue("keyword","pattern",index);
			std::string reason = MyConf->ReadValue("keyword","reason",index);
			std::string do_action = MyConf->ReadValue("keyword","action",index);
			if (do_action == "")
				do_action = "none";
			Filter* x = new Filter;
			x->reason = reason;
			x->action = do_action;
			filters[pattern] = x;
		}
		ServerInstance->Log(DEFAULT,"m_filter: read configuration from "+filterfile);
		DELETE(Conf);
		DELETE(MyConf);
	}
Ejemplo n.º 3
0
		virtual void ReadConfig()
		{
			ConfigReader *MyConf = new ConfigReader(ServerInstance);

			helpop_map.clear();

			for (int i = 0; i < MyConf->Enumerate("helpop"); i++)
			{
				irc::string key = assign(MyConf->ReadValue("helpop", "key", i));
				std::string value = MyConf->ReadValue("helpop", "value", i, true); /* Linefeeds allowed! */

				if (key == "index")
				{
					throw ModuleException("m_helpop: The key 'index' is reserved for internal purposes. Please remove it.");
				}

				helpop_map[key] = value;
			}

			if (helpop_map.find("start") == helpop_map.end())
			{
				// error!
				throw ModuleException("m_helpop: Helpop file is missing important entries. Please check the example conf.");
			}
			else if (helpop_map.find("nohelp") == helpop_map.end())
			{
				// error!
				throw ModuleException("m_helpop: Helpop file is missing important entries. Please check the example conf.");
			}

		}
Ejemplo n.º 4
0
    CmdResult Handle (const std::vector<std::string> &parameters, User *user)
    {
        ConfigReader *Conf = new ConfigReader(ServerInstance);

        for (int index = 0; index < Conf->Enumerate("vhost"); index++)
        {
            std::string mask = Conf->ReadValue("vhost","host",index);
            std::string username = Conf->ReadValue("vhost","user",index);
            std::string pass = Conf->ReadValue("vhost","pass",index);
            std::string hash = Conf->ReadValue("vhost","hash",index);

            if ((!strcmp(parameters[0].c_str(),username.c_str())) && !ServerInstance->PassCompare(user, pass.c_str(), parameters[1].c_str(), hash.c_str()))
            {
                if (!mask.empty())
                {
                    user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
                    user->ChangeDisplayedHost(mask.c_str());
                    delete Conf;
                    return CMD_LOCALONLY;
                }
            }
        }

        user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password.");
        delete Conf;
        return CMD_FAILURE;
    }
Ejemplo n.º 5
0
	ModuleRandQuote(InspIRCd* Me)
		: Module(Me)
	{
		
		conf = new ConfigReader(ServerInstance);
		// Sort the Randomizer thingie..
		srand(time(NULL));

		q_file = conf->ReadValue("randquote","file",0);
		prefix = conf->ReadValue("randquote","prefix",0);
		suffix = conf->ReadValue("randquote","suffix",0);

		mycommand = NULL;

		if (q_file.empty())
		{
			RandquoteException e("m_randquote: Quotefile not specified - Please check your config.");
			throw(e);
		}

		quotes = new FileReader(ServerInstance, q_file);
		if(!quotes->Exists())
		{
			RandquoteException e("m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
			throw(e);
		}
		else
		{
			/* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
			mycommand = new cmd_randquote(ServerInstance);
			ServerInstance->AddCommand(mycommand);
		}
	}
Ejemplo n.º 6
0
	virtual void OnRehash(User* user)
	{
		ConfigReader* conf = new ConfigReader(ServerInstance);
		deaf_bypasschars = conf->ReadValue("deaf", "bypasschars", 0);
		deaf_bypasschars_uline = conf->ReadValue("deaf", "bypasscharsuline", 0);

		delete conf;
	}
Ejemplo n.º 7
0
	void OnReload()
	{
		ConfigReader config;

		this->binddn = config.ReadValue("m_ldap_oper", "binddn", "", 0);
		this->password = config.ReadValue("m_ldap_oper", "password", "", 0);
		this->basedn = config.ReadValue("m_ldap_oper", "basedn", "", 0);
		this->filter = config.ReadValue("m_ldap_oper", "filter", "", 0);
		opertype_attribute = config.ReadValue("m_ldap_oper", "opertype_attribute", "", 0);

		for (std::set<Oper *>::iterator it = my_opers.begin(), it_end = my_opers.end(); it != it_end; ++it)
			delete *it;
		my_opers.clear();
	}
Ejemplo n.º 8
0
	void ReadSettings()
	{
		Conf = new ConfigReader(ServerInstance);
		IdentTimeout = Conf->ReadInteger("ident", "timeout", 0, true);
		PortBind = Conf->ReadValue("ident", "bind", 0);
		if (!IdentTimeout)
			IdentTimeout = 1;
		DELETE(Conf);
	}
Ejemplo n.º 9
0
		virtual void OnRehash(User* user)
		{
			ConfigReader* conf = new ConfigReader(ServerInstance);
			JoinChan = conf->ReadValue("autojoin", "channel", 0);
			Joinchans.clear();
			if (!JoinChan.empty())
				tokenize(JoinChan,Joinchans);
			delete conf;
		}
Ejemplo n.º 10
0
	virtual void OnRehash(User* user)
	{
		/*
		 * reload our config file on rehash - we must destroy and re-allocate the classes
		 * to call the constructor again and re-read our data.
		 */
		ConfigReader* MyConf = new ConfigReader(ServerInstance);
		censors.clear();

		for (int index = 0; index < MyConf->Enumerate("badword"); index++)
		{
			irc::string pattern = (MyConf->ReadValue("badword","text",index)).c_str();
			irc::string replace = (MyConf->ReadValue("badword","replace",index)).c_str();
			censors[pattern] = replace;
		}

		delete MyConf;
	}
Ejemplo n.º 11
0
	void OnReload()
	{
		ConfigReader config;

		this->rewrites.clear();

		for (int i = 0; i < config.Enumerate("rewrite"); ++i)
		{
			Rewrite rw;

			rw.client = config.ReadValue("rewrite", "client", "", i);
			rw.source_message = config.ReadValue("rewrite", "source_message", "", i),
			rw.target_message = config.ReadValue("rewrite", "target_message", "", i);

			if (rw.client.empty() || rw.source_message.empty() || rw.target_message.empty())
				continue;

			this->rewrites.push_back(rw);
		}
	}
Ejemplo n.º 12
0
    virtual void OnRehash(userrec* user, const std::string &parameter)
    {
        ConfigReader* conf = new ConfigReader(ServerInstance);

        operChan = conf->ReadValue("operjoin", "channel", 0);
        operChans.clear();
        if (!operChan.empty())
            tokenize(operChan,operChans);

        DELETE(conf);
    }
Ejemplo n.º 13
0
	virtual void OnRehash(const std::string &parameter)
	{
		DELETE(Conf);
		Conf = new ConfigReader(ServerInstance);
		MySuffix = Conf->ReadValue("host","suffix",0);
		for (hostchanges_t::iterator i = hostchanges.begin(); i != hostchanges.end(); i++)
		{
			DELETE(i->second);
		}
		hostchanges.clear();
		for (int index = 0; index < Conf->Enumerate("hostchange"); index++)
		{
			std::string mask = Conf->ReadValue("hostchange","mask",index);
			std::string action = Conf->ReadValue("hostchange","action",index);
			std::string newhost = Conf->ReadValue("hostchange","value",index);
			Host* x = new Host;
			x->action = action;
			x->newhost = newhost;
			hostchanges[mask] = x;
		}
	}
Ejemplo n.º 14
0
	void LoadOperMOTD()
	{
		ConfigReader* conf = new ConfigReader(ServerInstance);
		std::string filename;
		filename = conf->ReadValue("opermotd","file",0);
		if (opermotd)
		{
			delete opermotd;
			opermotd = NULL;
		}
		opermotd = new FileReader(ServerInstance, filename);
		DELETE(conf);
	}
Ejemplo n.º 15
0
	void ReadConfig()
	{
		ConfigReader* MyConf = new ConfigReader(ServerInstance);
		allowchans.clear();
		for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++)
		{
			std::string txt;
			txt = MyConf->ReadValue("allowchannel", "name", i);
			irc::string channel = txt.c_str();
			allowchans[channel] = 1;
		}
		DELETE(MyConf);
	}
Ejemplo n.º 16
0
		virtual int OnPreCommand(std::string &command, std::vector<std::string>& parameters, User* user, bool validated, const std::string &original_line)
		{
			if (!validated)
				return 0;

			if (command != "OPER")
				return 0;

			std::string *account, currentaccount=user->nick.c_str();
			user->GetExt("accountname", account);

			if (account)
				currentaccount=account->c_str();

			else if (!user->IsModeSet('r') && !account)
			{
				user->WriteServ("491 %s :Invalid oper credentials",user->nick.c_str());
				return 1;
			}

			for (int j = 0; j < Conf->Enumerate("oper"); j++)
			{
				std::string opername = Conf->ReadValue("oper", "name", j);
				if (opername==parameters[0])
				{
					std::string registerednick = Conf->ReadValue("oper", "registerednick", "", j);

					if (registerednick.empty() || InspIRCd::Match(registerednick,currentaccount))
						break;
					else
					{
						user->WriteServ("491 %s :Invalid oper credentials",user->nick.c_str());
						return 1;
					}
				}
			}

			return 0;
		}
Ejemplo n.º 17
0
	void LoadOperMOTD()
	{
		ConfigReader* conf = new ConfigReader(ServerInstance);
		std::string filename;
		filename = conf->ReadValue("opermotd","file",0);
		if (opermotd)
		{
			delete opermotd;
			opermotd = NULL;
		}
		opermotd = new FileReader(ServerInstance, filename);
		onoper = conf->ReadFlag("opermotd","onoper","yes",0);
		delete conf;
	}
Ejemplo n.º 18
0
	void InitConf()
	{
		/* read configuration variables */
		conf = new ConfigReader(ServerInstance);
		/* throttle configuration */
		seconds = conf->ReadInteger("connflood", "seconds", 0, true);
		maxconns = conf->ReadInteger("connflood", "maxconns", 0, true);
		timeout = conf->ReadInteger("connflood", "timeout", 0, true);
		quitmsg = conf->ReadValue("connflood", "quitmsg", 0);

		/* seconds to wait when the server just booted */
		boot_wait = conf->ReadInteger("connflood", "bootwait", 0, true);

		first = ServerInstance->Time();
	}
Ejemplo n.º 19
0
	virtual int OnOperCompare(const std::string &data, const std::string &input, int tagnumber)
	{
		/* First, lets see what hash theyre using on this oper */
		std::string hashtype = Conf->ReadValue("oper", "hash", tagnumber);
		hashymodules::iterator x = hashers.find(hashtype.c_str());

		/* Is this a valid hash name? (case insensitive) */
		if (x != hashers.end())
		{
			/* Reset the hashing module */
			HashResetRequest(this, x->second).Send();
			/* Compare the hash in the config to the generated hash */
			if (!strcasecmp(data.c_str(), HashSumRequest(this, x->second, input.c_str()).Send()))
				return 1;
			/* No match, and must be hashed, forbid */
			else return -1;
		}

		/* Not a hash, fall through to strcmp in core */
		return 0;
	}
Ejemplo n.º 20
0
	virtual void OnRehash(const std::string &param)
	{
		if(param != "ssl")
			return;
	
		Conf = new ConfigReader(ServerInstance);
			
		for(unsigned int i = 0; i < listenports.size(); i++)
		{
			ServerInstance->Config->DelIOHook(listenports[i]);
		}
		
		listenports.clear();
		
		for(int i = 0; i < Conf->Enumerate("bind"); i++)
		{
			// For each <bind> tag
			if(((Conf->ReadValue("bind", "type", i) == "") || (Conf->ReadValue("bind", "type", i) == "clients")) && (Conf->ReadValue("bind", "ssl", i) == "openssl"))
			{
				// Get the port we're meant to be listening on with SSL
				unsigned int port = Conf->ReadInteger("bind", "port", i, true);
				if (ServerInstance->Config->AddIOHook(port, this))
				{
					// We keep a record of which ports we're listening on with SSL
					listenports.push_back(port);
				
					ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Enabling SSL for port %d", port);
				}
				else
				{
					ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: FAILED to enable SSL on port %d, maybe you have another ssl or similar module loaded?", port);
				}
			}
		}
		
		std::string confdir(CONFIG_FILE);
		// +1 so we the path ends with a /
		confdir = confdir.substr(0, confdir.find_last_of('/') + 1);
		
		cafile	= Conf->ReadValue("openssl", "cafile", 0);
		// crlfile	= Conf->ReadValue("openssl", "crlfile", 0);
		certfile	= Conf->ReadValue("openssl", "certfile", 0);
		keyfile	= Conf->ReadValue("openssl", "keyfile", 0);
		dhfile	= Conf->ReadValue("openssl", "dhfile", 0);
		
		// Set all the default values needed.
		if(cafile == "")
			cafile = "ca.pem";
			
		//if(crlfile == "")
		//	crlfile = "crl.pem";
			
		if(certfile == "")
			certfile = "cert.pem";
			
		if(keyfile == "")
			keyfile = "key.pem";
			
		if(dhfile == "")
			dhfile = "dhparams.pem";
			
		// Prepend relative paths with the path to the config directory.	
		if(cafile[0] != '/')
			cafile = confdir + cafile;
		
		//if(crlfile[0] != '/')
		//	crlfile = confdir + crlfile;
			
		if(certfile[0] != '/')
			certfile = confdir + certfile;
			
		if(keyfile[0] != '/')
			keyfile = confdir + keyfile;
			
		if(dhfile[0] != '/')
			dhfile = confdir + dhfile;

		/* Load our keys and certificates*/
		if(!SSL_CTX_use_certificate_chain_file(ctx, certfile.c_str()))
		{
			ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read certificate file %s", certfile.c_str());
		}

		if(!SSL_CTX_use_PrivateKey_file(ctx, keyfile.c_str(), SSL_FILETYPE_PEM))
		{
			ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read key file %s", keyfile.c_str());
		}

		/* Load the CAs we trust*/
		if(!SSL_CTX_load_verify_locations(ctx, cafile.c_str(), 0))
		{
			ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read CA list from ", cafile.c_str());
		}

		FILE* dhpfile = fopen(dhfile.c_str(), "r");
		DH* ret;

		if(dhpfile == NULL)
		{
			ServerInstance->Log(DEFAULT, "m_ssl_openssl.so Couldn't open DH file %s: %s", dhfile.c_str(), strerror(errno));
			throw ModuleException();
		}
		else
		{
			ret = PEM_read_DHparams(dhpfile, NULL, NULL, NULL);
		
			if(SSL_CTX_set_tmp_dh(ctx, ret) < 0)
			{
				ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Couldn't set DH parameters");
			}
		}
		
		fclose(dhpfile);

		DELETE(Conf);
	}
Ejemplo n.º 21
0
	void OnReload()
	{
		ConfigReader config;

		this->HelpChan = config.ReadValue("m_helpchan", "helpchannel", "", 0);
	}