listen(8): add -a option to restrict announce address, document tcp17019 and tcp17020
This commit is contained in:
parent
7b5cf8de2d
commit
84e67ffa88
2 changed files with 35 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
|||
.TH LISTEN 8
|
||||
.SH NAME
|
||||
listen, listen1, tcp7, tcp9, tcp19, tcp21, tcp23, tcp25, tcp53, tcp110, tcp113, tcp143, tcp445, tcp513, tcp515, tcp564, tcp565, tcp566, tcp567, tcp993, tcp995, tcp1723, tcp17007, tcp17008, tcp17009, tcp17010, tcp17013 \- listen for calls on a network device
|
||||
listen, listen1, tcp7, tcp9, tcp19, tcp21, tcp23, tcp25, tcp53, tcp110, tcp113, tcp143, tcp445, tcp513, tcp515, tcp564, tcp565, tcp566, tcp567, tcp993, tcp995, tcp1723, tcp17007, tcp17008, tcp17009, tcp17010, tcp17013, tcp17019, tcp17020 \- listen for calls on a network device
|
||||
.SH SYNOPSIS
|
||||
.B aux/listen
|
||||
.RB [ -iq ]
|
||||
|
@ -12,7 +12,9 @@ listen, listen1, tcp7, tcp9, tcp19, tcp21, tcp23, tcp25, tcp53, tcp110, tcp113,
|
|||
.IR namespace ]
|
||||
.RB [ -p
|
||||
.IR maxprocs ]
|
||||
.RI [ net ]
|
||||
.RB [ -a
|
||||
.IR addr ]
|
||||
.RI [ proto ]
|
||||
.PP
|
||||
.B aux/listen1
|
||||
[
|
||||
|
@ -28,11 +30,18 @@ listen, listen1, tcp7, tcp9, tcp19, tcp21, tcp23, tcp25, tcp53, tcp110, tcp113,
|
|||
.I args...
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
.I listen
|
||||
.I Listen
|
||||
listens on a network for inbound calls to local services.
|
||||
.I Net
|
||||
.I Proto
|
||||
is the network protocol on which to listen, by default
|
||||
.BR /net/tcp .
|
||||
.BR tcp .
|
||||
Incoming calls to any address
|
||||
.B *
|
||||
are accepted unless
|
||||
.I addr
|
||||
is specified with the
|
||||
.B -a
|
||||
option.
|
||||
The services available are executable, non-empty files in
|
||||
.I srvdir
|
||||
or
|
||||
|
@ -145,6 +154,10 @@ and
|
|||
.IR cpu (1)
|
||||
using TLS for encryption.
|
||||
.TP
|
||||
.B tcp17020
|
||||
TLS encrypted 9P fileserver (t9fs) for
|
||||
.IR srvtls (4)
|
||||
.TP
|
||||
.B tcp7
|
||||
echo any bytes received (bit mirror)
|
||||
.TP
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue