Skip to content

Commit

Permalink
Fix IP application detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Gibus21250 committed Oct 13, 2024
1 parent c7035c2 commit cfa0a84
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,23 @@ void *main_client_monitoring(void* args)

int verify_ips(const client *cl)
{
char cmd[128];
char buffer[1024];
char buffer[128];
FILE *fp;

for (int i = 0; i < cl->countIp; ++i) {

snprintf(buffer, sizeof(buffer), "ip a | grep -w %s", cl->ipPortInfo[i].ipStr);

snprintf(cmd, sizeof(cmd), "ip a | grep -w %s", cl->ipPortInfo->ipStr);

fp = popen(cmd, "r");
if (fp == NULL) {
return MONITOR_CHECK_IP_ERROR;
}
fp = popen(buffer, "r");
if (fp == NULL) {
return MONITOR_CHECK_IP_ERROR;
}

if (fgets(buffer, sizeof(buffer), fp) != NULL) {
if (fgets(buffer, sizeof(buffer), fp) != NULL) {
pclose(fp);
return MONITOR_IP_ALREADY_USED;
}
pclose(fp);
return MONITOR_IP_ALREADY_USED;
}

pclose(fp);

}
return OK;
Expand Down

0 comments on commit cfa0a84

Please sign in to comment.