summaryrefslogtreecommitdiff
path: root/sys/src/cmd/aux
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-01-14 19:32:13 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2018-01-14 19:32:13 +0100
commit84e67ffa88e4d07b2e5848d666296a3e41750da6 (patch)
tree44008a5ca76206d6708decc51e5de804c8043420 /sys/src/cmd/aux
parent7b5cf8de2dccafa565a62908d307f2033ee69420 (diff)
listen(8): add -a option to restrict announce address, document tcp17019 and tcp17020
Diffstat (limited to 'sys/src/cmd/aux')
-rw-r--r--sys/src/cmd/aux/listen.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/sys/src/cmd/aux/listen.c b/sys/src/cmd/aux/listen.c
index 5c5b51fcd..0114f949d 100644
--- a/sys/src/cmd/aux/listen.c
+++ b/sys/src/cmd/aux/listen.c
@@ -28,9 +28,9 @@ void newcall(int, char*, char*, Service*);
int findserv(char*, char*, Service*, char*);
int getserv(char*, char*, Service*);
void error(char*);
-void scandir(char*, char*, char*);
+void scandir(char*, char*, char*, char*);
void becomenone(void);
-void listendir(char*, char*, int);
+void listendir(char*, char*, char*, int);
char listenlog[] = "listen";
@@ -40,6 +40,7 @@ int quiet;
int immutable;
char *cpu;
char *proto;
+char *addr;
Announce *announcements;
#define SEC 1000
@@ -48,8 +49,8 @@ char *namespace;
void
usage(void)
{
- error("usage: aux/listen [-q] [-n namespace] [-d servdir] [-t trustdir] [-p maxprocs]"
- " [proto]");
+ error("usage: aux/listen [-iq] [-d srvdir] [-t trustsrvdir] [-n namespace] [-p maxprocs]"
+ " [-a addr] [proto]");
}
/*
@@ -85,6 +86,7 @@ main(int argc, char *argv[])
char *trustdir;
char *servdir;
+ addr = "*";
servdir = 0;
trustdir = 0;
proto = "tcp";
@@ -97,6 +99,9 @@ main(int argc, char *argv[])
error("can't get cputype");
ARGBEGIN{
+ case 'a':
+ addr = EARGF(usage());
+ break;
case 'd':
servdir = EARGF(usage());
break;
@@ -149,8 +154,8 @@ main(int argc, char *argv[])
proto = protodir;
else
proto++;
- listendir(protodir, servdir, 0);
- listendir(protodir, trustdir, 1);
+ listendir(protodir, addr, servdir, 0);
+ listendir(protodir, addr, trustdir, 1);
/* command returns */
exits(0);
@@ -165,7 +170,7 @@ dingdong(void*, char *msg)
}
void
-listendir(char *protodir, char *srvdir, int trusted)
+listendir(char *protodir, char *addr, char *srvdir, int trusted)
{
int ctl, pid, start;
char dir[40], err[128], ds[128];
@@ -191,14 +196,14 @@ listendir(char *protodir, char *srvdir, int trusted)
return;
}
- procsetname("%s %s %s", protodir, srvdir, namespace);
+ procsetname("%s %s %s %s", protodir, addr, srvdir, namespace);
if (!trusted)
becomenone();
notify(dingdong);
pid = getpid();
- scandir(proto, protodir, srvdir);
+ scandir(proto, protodir, addr, srvdir);
for(;;){
/*
* loop through announcements and process trusted services in
@@ -273,7 +278,7 @@ listendir(char *protodir, char *srvdir, int trusted)
}
if(!immutable){
alarm(0);
- scandir(proto, protodir, srvdir);
+ scandir(proto, protodir, addr, srvdir);
}
start = 60 - (time(0)-start);
if(start > 0)
@@ -309,7 +314,7 @@ addannounce(char *str)
}
void
-scandir(char *proto, char *protodir, char *dname)
+scandir(char *proto, char *protodir, char *addr, char *dname)
{
Announce *a, **l;
int fd, i, n, nlen;
@@ -334,7 +339,7 @@ scandir(char *proto, char *protodir, char *dname)
continue;
if(strncmp(nm, proto, nlen) != 0)
continue;
- snprint(ds, sizeof ds, "%s!*!%s", protodir, nm + nlen);
+ snprint(ds, sizeof ds, "%s!%s!%s", protodir, addr, nm + nlen);
addannounce(ds);
}
free(db);