From 43830ce2bff25a9acca4268ffaa3a681ac3afec2 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Wed, 1 Jul 2020 21:47:14 +0200 Subject: Teach connect_any to report the address it connected to in order to improve dbg messages --- minecctl/rcon-commands.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'minecctl/rcon-commands.c') diff --git a/minecctl/rcon-commands.c b/minecctl/rcon-commands.c index be18bba..5e4ea08 100644 --- a/minecctl/rcon-commands.c +++ b/minecctl/rcon-commands.c @@ -99,6 +99,7 @@ static int rcon_login(struct cfg *cfg, struct server *server) char buf[4096]; int32_t rtype; const char *reply; + struct saddr *saddr; int fd = -1; assert_die(cfg && server, "invalid arguments"); @@ -108,11 +109,12 @@ static int rcon_login(struct cfg *cfg, struct server *server) goto error; } - fd = connect_any(&server->scfg.rcons, true); + fd = connect_any(&server->scfg.rcons, &saddr, &error); if (fd < 0) { - error("%s: unable to connect", server->name); + error("%s: unable to connect - %s", server->name, error); goto error; - } + } else + verbose("%s: connected to %s", server->name, saddr->addrstr); if (!server->scfg.rcon_password) server->scfg.rcon_password = ask_password(); @@ -122,8 +124,8 @@ static int rcon_login(struct cfg *cfg, struct server *server) goto error; } - send_msg(fd, buf, sizeof(buf), RCON_PACKET_LOGIN, server->scfg.rcon_password, - &rtype, &reply); + send_msg(fd, buf, sizeof(buf), RCON_PACKET_LOGIN, + server->scfg.rcon_password, &rtype, &reply); explicit_bzero(buf, sizeof(buf)); free_password(&server->scfg.rcon_password); -- cgit v1.2.3