Commit 77350f64 authored by Romain Bignon's avatar Romain Bignon

add option file_transfers/dcc_own_ip in config file

parent c27c6743
......@@ -147,6 +147,12 @@ file_transfers {
# Port range to listen for DCC.
port_range = 1024-65535
# Force minbif to always send DCC requests from a particular IP address.
# This is *NOT* the bind address.
#
# When not set, it tries to guess your public IP address.
# dcc_own_ip = 127.0.0.1
}
# Log function
......
......@@ -88,6 +88,7 @@ Minbif::Minbif()
section = conf.AddSection("file_transfers", "File transfers parameters", MyConfig::OPTIONAL);
section->AddItem(new ConfigItem_bool("enabled", "Enable file transfers", "true"));
section->AddItem(new ConfigItem_bool("dcc", "Send files to IRC user with DCC", "true"));
section->AddItem(new ConfigItem_string("dcc_own_ip", "Force minbif to always send DCC requests from a particular IP address", " "));
section->AddItem(new ConfigItem_intrange("port_range", "Port range to listen on for DCC", 1024, 65535, "1024-65535"));
section = conf.AddSection("logging", "Log information", MyConfig::NORMAL);
......
......@@ -108,11 +108,19 @@ void DCCServer::listen_cb(int sock, void* data)
{
DCCServer* dcc = static_cast<DCCServer*>(data);
struct in_addr addr;
string bind_addr = conf.GetSection("file_transfers")->GetItem("dcc_own_ip")->String();
if (bind_addr == " ")
bind_addr = purple_network_get_my_ip(-1);
dcc->fd = sock;
dcc->listen_data = NULL;
dcc->port = purple_network_get_port_from_fd(sock);
inet_aton(purple_network_get_my_ip(-1), &addr);
if (!inet_aton(bind_addr.c_str(), &addr))
{
b_log[W_ERR] << "Unable to parse this IP address: [" << bind_addr << "]: Unable to send DCC request.";
dcc->deinit();
return;
}
dcc->watcher = purple_input_add(sock, PURPLE_INPUT_READ,
connected, dcc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment