fix: store IP on rediscover

This commit is contained in:
Tobias Reisinger 2020-08-20 11:37:21 +02:00
parent 73033354b5
commit 435110e61d
3 changed files with 10 additions and 9 deletions

View file

@ -228,10 +228,11 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
{
if(uuid_compare(known_controllers[i]->uid, discovered_id) == 0)
{
LOGGER_DEBUG("rediscovered a known controller\n");
LOGGER_DEBUG("rediscovered a known controller at %s\n", inet_ntoa(addr.sin_addr));
known_controllers[i]->active = 1;
strncpy(known_controllers[i]->name, discovered_name, discovered_name_len);
strcpy(discovered_controller->ip, inet_ntoa(addr.sin_addr));
known_controllers[i]->name[discovered_name_len] = '\0';
known_controllers[i]->port = discovered_command_port;
known_controllers[i]->relay_count = discovered_relay_count;
@ -251,7 +252,7 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
if(!found_discovered_in_list)
{
LOGGER_DEBUG("discovered a new controller\n");
LOGGER_DEBUG("discovered a new controller at %s\n", inet_ntoa(addr.sin_addr));
controller_t *discovered_controller = malloc(sizeof(controller_t));
discovered_controller->id = 0;