Merge pull request #164 from lazedo/kazoo-create_ei_cnode

[mod_kazoo] use globals hostname to create nodename in create_ei_cnode
This commit is contained in:
Andrey Volk 2019-12-05 00:43:16 +04:00 committed by GitHub
commit 5274dd1f9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 11 deletions

View File

@ -345,10 +345,9 @@ switch_socket_t *create_socket(switch_memory_pool_t *pool) {
}
switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei_cnode_s *ei_cnode) {
char hostname[EI_MAXHOSTNAMELEN + 1] = "";
char hostname[EI_MAXHOSTNAMELEN + 1];
char nodename[MAXNODELEN + 1];
char cnodename[EI_MAXALIVELEN + 1];
//EI_MAX_COOKIE_SIZE+1
char *atsign;
/* copy the erlang interface nodename into something we can modify */
@ -356,17 +355,13 @@ switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei
if ((atsign = strchr(cnodename, '@'))) {
/* we got a qualified node name, don't guess the host/domain */
snprintf(nodename, MAXNODELEN + 1, "%s", kazoo_globals.ei_nodename);
snprintf(nodename, MAXNODELEN + 1, "%s", name);
/* truncate the alivename at the @ */
*atsign = '\0';
*atsign++ = '\0';
strncpy(hostname, atsign, EI_MAXHOSTNAMELEN);
} else {
if (zstr(kazoo_globals.hostname) || !strncasecmp(kazoo_globals.ip, "0.0.0.0", 7) || !strncasecmp(kazoo_globals.ip, "::", 2)) {
memcpy(hostname, switch_core_get_hostname(), EI_MAXHOSTNAMELEN);
} else {
memcpy(hostname, kazoo_globals.hostname, EI_MAXHOSTNAMELEN);
}
snprintf(nodename, MAXNODELEN + 1, "%s@%s", kazoo_globals.ei_nodename, hostname);
strncpy(hostname, kazoo_globals.hostname, EI_MAXHOSTNAMELEN);
snprintf(nodename, MAXNODELEN + 1, "%s@%s", name, hostname);
}
if (kazoo_globals.ei_shortname) {
@ -376,6 +371,8 @@ switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "creating nodename: %s\n", nodename);
/* init the ec stuff */
if (ei_connect_xinit(ei_cnode, hostname, cnodename, nodename, (Erl_IpAddr) ip_addr, kazoo_globals.ei_cookie, 0) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to initialize the erlang interface connection structure\n");