Browse code

Implement unix domain socket command 'list'.

Dario Rodriguez authored on 02/01/2024 19:41:47
Showing 1 changed files
... ...
@@ -3315,6 +3315,19 @@ fprintf(stderr,"Storing client id because of command from client \"%s\" (%i).\n"
3315 3315
                 client->remoteid[sizeof(client->remoteid)-1]='\0';
3316 3316
                 /* send end-of-results */
3317 3317
                 re_socketout(re, nclient, "\n");
3318
+        } else if(strcmp(line,"list")==0) {
3319
+                /* list ids */
3320
+#if 0
3321
+fprintf(stderr,"Listing ids because of command from client \"%s\" (%i).\n",line,nclient);
3322
+#endif
3323
+                re_socketout(re, nclient, "%s\n",re->comms.id);
3324
+                for(i=0;i<re->comms.sizeclients;i++) {
3325
+                        if(re->comms.clients[i]==NULL || re->comms.clients[i]->fd==-1 || re->comms.clients[i]->remoteid[0]=='\0')
3326
+                                continue;
3327
+                        re_socketout(re, nclient, "%s\n",re->comms.clients[i]->remoteid);
3328
+                }
3329
+                /* send end-of-results */
3330
+                re_socketout(re, nclient, "\n");
3318 3331
         } else if(line[0]=='\0' ) {
3319 3332
                 ; /* ignore the end-of-message (should only receive them on forwarding clients) */
3320 3333
         } else {