summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/command.c1
-rw-r--r--src/common/session.c4
-rw-r--r--src/common/session.h3
-rw-r--r--src/common/weechat.c5
-rw-r--r--src/common/weeconfig.c12
5 files changed, 21 insertions, 4 deletions
diff --git a/src/common/command.c b/src/common/command.c
index 611c50c1d..9f77b2ccb 100644
--- a/src/common/command.c
+++ b/src/common/command.c
@@ -2865,6 +2865,7 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
server_tmp.password, server_tmp.nick1,
server_tmp.nick2, server_tmp.nick3,
server_tmp.username, server_tmp.realname,
+ server_tmp.hostname,
server_tmp.command, 1, server_tmp.autojoin, 1, NULL,
NULL, NULL, NULL);
if (new_server)
diff --git a/src/common/session.c b/src/common/session.c
index 7defd8f94..5985448ca 100644
--- a/src/common/session.c
+++ b/src/common/session.c
@@ -225,6 +225,7 @@ session_save_servers (FILE *file)
rc = rc && (session_write_str (file, SESSION_SERV_NICK3, ptr_server->nick3));
rc = rc && (session_write_str (file, SESSION_SERV_USERNAME, ptr_server->username));
rc = rc && (session_write_str (file, SESSION_SERV_REALNAME, ptr_server->realname));
+ rc = rc && (session_write_str (file, SESSION_SERV_HOSTNAME, ptr_server->hostname));
rc = rc && (session_write_str (file, SESSION_SERV_COMMAND, ptr_server->command));
rc = rc && (session_write_int (file, SESSION_SERV_COMMAND_DELAY, ptr_server->command_delay));
rc = rc && (session_write_str (file, SESSION_SERV_AUTOJOIN, ptr_server->autojoin));
@@ -858,6 +859,9 @@ session_load_server (FILE *file)
case SESSION_SERV_REALNAME:
rc = rc && (session_read_str (file, &(session_current_server->realname)));
break;
+ case SESSION_SERV_HOSTNAME:
+ rc = rc && (session_read_str (file, &(session_current_server->hostname)));
+ break;
case SESSION_SERV_COMMAND:
rc = rc && (session_read_str (file, &(session_current_server->command)));
break;
diff --git a/src/common/session.h b/src/common/session.h
index 9a6e70d27..9062bbb7a 100644
--- a/src/common/session.h
+++ b/src/common/session.h
@@ -88,7 +88,8 @@ enum t_session_server
SESSION_SERV_LAG_NEXT_CHECK,
SESSION_SERV_CHARSET_DECODE_ISO,
SESSION_SERV_CHARSET_DECODE_UTF,
- SESSION_SERV_CHARSET_ENCODE
+ SESSION_SERV_CHARSET_ENCODE,
+ SESSION_SERV_HOSTNAME
};
enum t_session_channel
diff --git a/src/common/weechat.c b/src/common/weechat.c
index cea92ad48..6c9392c9e 100644
--- a/src/common/weechat.c
+++ b/src/common/weechat.c
@@ -687,8 +687,9 @@ weechat_parse_args (int argc, char *argv[])
server_tmp.ipv6, server_tmp.ssl,
server_tmp.password, server_tmp.nick1,
server_tmp.nick2, server_tmp.nick3,
- NULL, NULL, NULL, 0, server_tmp.autojoin, 1, NULL,
- NULL, NULL, NULL))
+ NULL, NULL, NULL, NULL, 0,
+ server_tmp.autojoin, 1, NULL, NULL,
+ NULL, NULL))
fprintf (stderr, _("%s unable to create server ('%s'), ignored\n"),
WEECHAT_WARNING, argv[i]);
server_destroy (&server_tmp);
diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c
index e44c5b12e..d346f4a28 100644
--- a/src/common/weeconfig.c
+++ b/src/common/weeconfig.c
@@ -947,6 +947,10 @@ t_config_option weechat_options_server[] =
N_("real name to use on IRC server"),
OPTION_TYPE_STRING, 0, 0, 0,
"", NULL, NULL, &(cfg_server.realname), NULL },
+ { "server_hostname", N_("custom hostname/IP for server"),
+ N_("custom hostname/IP for server (optional, if empty local hostname is used)"),
+ OPTION_TYPE_STRING, 0, 0, 0,
+ "", NULL, NULL, &(cfg_server.hostname), NULL },
{ "server_command", N_("command(s) to run when connected to server"),
N_("command(s) to run when connected to server (many commands should be "
"separated by ';', use '\\;' for a semicolon)"),
@@ -1447,6 +1451,8 @@ config_get_server_option_ptr (t_irc_server *server, char *option_name)
return (void *)(&server->username);
if (ascii_strcasecmp (option_name, "server_realname") == 0)
return (void *)(&server->realname);
+ if (ascii_strcasecmp (option_name, "server_hostname") == 0)
+ return (void *)(&server->hostname);
if (ascii_strcasecmp (option_name, "server_command") == 0)
return (void *)(&server->command);
if (ascii_strcasecmp (option_name, "server_command_delay") == 0)
@@ -1687,7 +1693,8 @@ config_allocate_server (char *filename, int line_number)
cfg_server.port, cfg_server.ipv6, cfg_server.ssl,
cfg_server.password, cfg_server.nick1, cfg_server.nick2,
cfg_server.nick3, cfg_server.username, cfg_server.realname,
- cfg_server.command, cfg_server.command_delay, cfg_server.autojoin,
+ cfg_server.hostname, cfg_server.command,
+ cfg_server.command_delay, cfg_server.autojoin,
cfg_server.autorejoin, cfg_server.notify_levels,
cfg_server.charset_decode_iso, cfg_server.charset_decode_utf,
cfg_server.charset_encode))
@@ -2223,6 +2230,7 @@ config_create_default ()
fprintf (file, "server_realname = \"WeeChat default realname\"\n");
}
+ fprintf (file, "server_hostname = \"\"\n");
fprintf (file, "server_command = \"\"\n");
fprintf (file, "server_command_delay = 0\n");
fprintf (file, "server_autojoin = \"\"\n");
@@ -2409,6 +2417,8 @@ config_write (char *config_name)
fprintf (file, "server_nick3 = \"%s\"\n", ptr_server->nick3);
fprintf (file, "server_username = \"%s\"\n", ptr_server->username);
fprintf (file, "server_realname = \"%s\"\n", ptr_server->realname);
+ fprintf (file, "server_hostname = \"%s\"\n",
+ (ptr_server->hostname) ? ptr_server->hostname : "");
fprintf (file, "server_command = \"%s\"\n",
(ptr_server->command) ? ptr_server->command : "");
fprintf (file, "server_command_delay = %d\n", ptr_server->command_delay);