Changeset - be0d5ee4122f
[Not reviewed]
0 2 0
Jan Kaluza - 9 years ago 2016-02-24 14:59:53
jkaluza@redhat.com
Libcommuni: Allow settings port in irc_server config option. When irc_send_pass is set to true, password is treated as a server password
2 files changed with 24 insertions and 5 deletions:
0 comments (0 inline, 0 general)
backends/libcommuni/ircnetworkplugin.cpp
Show inline comments
 
@@ -91,18 +91,37 @@ MyIrcSession *IRCNetworkPlugin::createSession(const std::string &user, const std
 
	session->setUserName(FROM_UTF8(nickname));
 
	session->setNickName(FROM_UTF8(nickname));
 
	session->setRealName(FROM_UTF8(nickname));
 
	session->setHost(FROM_UTF8(hostname));
 
	session->setPort(6667);
 
// 	session->setEncoding("UTF8");
 

	
 
	std::vector<std::string> hostname_parts;
 
	boost::split(hostname_parts, hostname, boost::is_any_of(":/"));
 
	if (hostname_parts.size() == 2 && !hostname_parts[0].empty() && !hostname_parts[1].empty()) { // hostname was splitted
 
		session->setHost(FROM_UTF8(hostname_parts[0])); // real hostname
 
		int port = atoi(hostname_parts[1].c_str()); // user port
 
		if (hostname_parts[1][0] == '+' || port == 6697) { // use SSL
 
			port = (port < 1 || port > 65535) ? 6697 : port; // default to standard SSL port
 
			session->setSecure(true);
 
		} else { // use TCP
 
			port = (port < 1 || port > 65535) ? 6667 : port; // default to standart TCP port
 
		}
 
		session->setPort(port);
 
	} else { // hostname was not splitted: default to old behaviour
 
		session->setHost(FROM_UTF8(hostname));
 
		session->setPort(6667);
 
	}
 

	
 
	if (!password.empty()) {
 
		std::string identify = m_identify;
 
		boost::replace_all(identify, "$password", password);
 
		boost::replace_all(identify, "$name", nickname);
 
		session->setIdentify(identify);
 
		if (CONFIG_BOOL_DEFAULTED(m_config, "service.irc_send_pass", false)) {
 
			session->setPassword(FROM_UTF8(password)); // use IRC PASS
 
		} else {
 
			session->setIdentify(identify); // use identify supplied
 
		}
 
	}
 

	
 
	LOG4CXX_INFO(logger, user << ": Connecting " << hostname << " as " << nickname << ", suffix=" << suffix);
 
	LOG4CXX_INFO(logger, user << ": Connecting " << hostname << " as " << nickname << ", port=" << session->port() << ", suffix=" << suffix);
 

	
 
	session->open();
 

	
tests/tests_output/localhost/vcard/client.dat
Show inline comments
 
@@ -20,8 +20,8 @@ return {
 
		};
 
	};
 
	["attr"] = {
 
		["version"] = "2.0";
 
		["prodid"] = "-//HandGen//NONSGML vGen v1.0//EN";
 
		["version"] = "2.0";
 
		["xmlns"] = "vcard-temp";
 
	};
 
	["name"] = "vCard";
0 comments (0 inline, 0 general)