From 8b73a2a5307b4440f1e196329a9a1f0423e41762 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 24 Apr 2021 16:09:09 +0200 Subject: [PATCH] vty: call telnet_init_dynif() after config file is read In case the config file specifies a vty bind address, we must read it before we start the telnet server. Change-Id: I44561754d4beaad5c74cb66994ca4ef38960ea78 --- src/osmo_client_main.c | 13 +++++++------ src/osmo_server_main.c | 12 ++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/osmo_client_main.c b/src/osmo_client_main.c index 0951115..1ab24c3 100644 --- a/src/osmo_client_main.c +++ b/src/osmo_client_main.c @@ -259,12 +259,6 @@ int main(int argc, char **argv) osmo_tls_init(); - rc = telnet_init_dynif(tall_cli_ctx, NULL, vty_get_bind_addr(), OSMO_VTY_PORT_PCAP_CLIENT); - if (rc < 0) { - LOGP(DCLIENT, LOGL_ERROR, "Failed to bind telnet interface\n"); - exit(1); - } - pcap_client = osmo_pcap_client_alloc(tall_cli_ctx); if (!pcap_client) { LOGP(DCLIENT, LOGL_ERROR, "Failed to allocate osmo_pcap_client.\n"); @@ -289,6 +283,13 @@ int main(int argc, char **argv) exit(1); } + rc = telnet_init_dynif(tall_cli_ctx, NULL, vty_get_bind_addr(), OSMO_VTY_PORT_PCAP_CLIENT); + if (rc < 0) { + LOGP(DCLIENT, LOGL_ERROR, "Failed to bind telnet interface\n"); + exit(1); + } + + /* attempt to connect to the remote */ if (pcap_client->conn.srv_ip && pcap_client->conn.srv_port > 0) osmo_client_connect(&pcap_client->conn); diff --git a/src/osmo_server_main.c b/src/osmo_server_main.c index b5f573c..f198b58 100644 --- a/src/osmo_server_main.c +++ b/src/osmo_server_main.c @@ -271,12 +271,6 @@ int main(int argc, char **argv) osmo_tls_init(); - rc = telnet_init_dynif(tall_srv_ctx, NULL, vty_get_bind_addr(), OSMO_VTY_PORT_PCAP_SERVER); - if (rc < 0) { - LOGP(DCLIENT, LOGL_ERROR, "Failed to bind telnet interface\n"); - exit(1); - } - pcap_server = talloc_zero(tall_srv_ctx, struct osmo_pcap_server); if (!pcap_server) { LOGP(DSERVER, LOGL_ERROR, "Failed to allocate osmo_pcap_server.\n"); @@ -299,6 +293,12 @@ int main(int argc, char **argv) exit(1); } + rc = telnet_init_dynif(tall_srv_ctx, NULL, vty_get_bind_addr(), OSMO_VTY_PORT_PCAP_SERVER); + if (rc < 0) { + LOGP(DCLIENT, LOGL_ERROR, "Failed to bind telnet interface\n"); + exit(1); + } + osmo_tls_server_init(pcap_server); /* attempt to connect to the remote */