Copyright, help text, whitespace cleanups
This commit is contained in:
parent
2856dab477
commit
ba2fb719b9
@ -976,7 +976,7 @@ static void colon(char * buf)
|
|||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_VI_SETOPTS
|
#if ENABLE_FEATURE_VI_SETOPTS
|
||||||
argp = args;
|
argp = args;
|
||||||
while (*argp) {
|
while (*argp) {
|
||||||
if (strncasecmp(argp, "no", 2) == 0)
|
if (strncasecmp(argp, "no", 2) == 0)
|
||||||
i = 2; // ":set noautoindent"
|
i = 2; // ":set noautoindent"
|
||||||
setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT);
|
setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT);
|
||||||
|
@ -3326,9 +3326,27 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
|
|||||||
"1\n"
|
"1\n"
|
||||||
|
|
||||||
#define tcpsvd_trivial_usage \
|
#define tcpsvd_trivial_usage \
|
||||||
"TODO"
|
"[-hpEvv] [-c n] [-C n:msg] [-b n] [-u user] [-l name] ip port prog..."
|
||||||
|
/* with not-implemented options: */
|
||||||
|
/* "[-hpEvv] [-c n] [-C n:msg] [-b n] [-u user] [-l name] [-i dir|-x cdb] [ -t sec] ip port prog..." */
|
||||||
#define tcpsvd_full_usage \
|
#define tcpsvd_full_usage \
|
||||||
"TODO"
|
"tcpsvd creates TCP/IP socket, binds it to host:port\n" \
|
||||||
|
"and listens on in for incoming connections. For each connection\n" \
|
||||||
|
"it runs prog" \
|
||||||
|
"\n" \
|
||||||
|
"\nip IP to listen on. '0' = 'all'" \
|
||||||
|
"\nport Port to listen on" \
|
||||||
|
"\nprog [arg] Program to run for each connection" \
|
||||||
|
"\n-l name Local hostname (else looks up local hostname in DNS)" \
|
||||||
|
"\n-u user[:group] Change to user/group after bind" \
|
||||||
|
"\n-c n Handle up to n connections simultaneously" \
|
||||||
|
"\n-C n[:msg] Allow only up to n connections from the same IP" \
|
||||||
|
"\n New connections from this IP address are closed" \
|
||||||
|
"\n immediately. 'msg' is written to the peer before close" \
|
||||||
|
"\n-h Look up peer's hostname in DNS" \
|
||||||
|
"\n-b n Allow a backlog of approximately n TCP SYNs" \
|
||||||
|
"\n-E Do not set up TCP-related environment variables" \
|
||||||
|
"\n-v Verbose"
|
||||||
|
|
||||||
#define tftp_trivial_usage \
|
#define tftp_trivial_usage \
|
||||||
"[OPTION]... HOST [PORT]"
|
"[OPTION]... HOST [PORT]"
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
/*
|
/* Based on ipsvd utilities written by Gerrit Pape <pape@smarden.org>
|
||||||
# /usr/bin/tcpsvd -v 0 1234 true
|
* which are released into public domain by the author.
|
||||||
tcpsvd: info: pid 24916 from 127.0.0.1
|
* Homepage: http://smarden.sunsite.dk/ipsvd/
|
||||||
tcpsvd: info: start 24916 localhost:127.0.0.1 ::127.0.0.1:47905
|
*
|
||||||
tcpsvd: info: pid 24918 from 127.0.0.1
|
* Copyright (C) 2007 by Denis Vlasenko.
|
||||||
tcpsvd: info: start 24918 localhost:127.0.0.1 ::127.0.0.1:47906
|
*
|
||||||
# ./busybox tcpsvd -v 0 1234 true
|
* Licensed under GPLv2, see file LICENSE in this tarball for details.
|
||||||
tcpsvd: info: pid 24924 from 127.0.0.1
|
*/
|
||||||
tcpsvd: info: start 24924 localhost:1234:127.0.0.1:1234 ::127.0.0.1:47908
|
|
||||||
tcpsvd: info: pid 24926 from 127.0.0.1
|
/* Based on ipsvd ipsvd-0.12.1. This tcpsvd accepts all options
|
||||||
tcpsvd: info: start 24926 localhost:1234:127.0.0.1:1234 ::127.0.0.1:47909
|
* which are supported by one from ipsvd-0.12.1, but not all are
|
||||||
*/
|
* functional. See help text at the end of this file for details.
|
||||||
|
*
|
||||||
|
* Code inside "#ifdef SSLSVD" is for sslsvd and is currently unused.
|
||||||
|
* Code inside #if 0" is parts of original tcpsvd which are not implemented
|
||||||
|
* for busyboxed version.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "busybox.h"
|
#include "busybox.h"
|
||||||
#include "ipsvd_perhost.h"
|
#include "ipsvd_perhost.h"
|
||||||
@ -297,15 +302,15 @@ int tcpsvd_main(int argc, char **argv)
|
|||||||
if (!max_per_host)
|
if (!max_per_host)
|
||||||
remote_ip = xmalloc_sockaddr2dotted_noport(&sock_adr.sa, sizeof(sock_adr));
|
remote_ip = xmalloc_sockaddr2dotted_noport(&sock_adr.sa, sizeof(sock_adr));
|
||||||
/* else it is already done */
|
/* else it is already done */
|
||||||
|
|
||||||
remote_port = get_nport(&sock_adr.sa);
|
remote_port = get_nport(&sock_adr.sa);
|
||||||
remote_port = ntohs(remote_port);
|
remote_port = ntohs(remote_port);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
printf("%s: info: pid %d from %s\n", applet_name, pid, remote_ip);
|
printf("%s: info: pid %d from %s\n", applet_name, pid, remote_ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_addresses && (option_mask32 & OPT_h)) {
|
if (need_addresses && (option_mask32 & OPT_h)) {
|
||||||
remote_hostname = xmalloc_sockaddr2host(&sock_adr.sa, sizeof(sock_adr));
|
remote_hostname = xmalloc_sockaddr2host(&sock_adr.sa, sizeof(sock_adr));
|
||||||
if (!remote_hostname) {
|
if (!remote_hostname) {
|
||||||
@ -313,7 +318,7 @@ int tcpsvd_main(int argc, char **argv)
|
|||||||
remote_hostname = (char*)"";
|
remote_hostname = (char*)"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sockadr_size = sizeof(sock_adr);
|
sockadr_size = sizeof(sock_adr);
|
||||||
/* Errors ignored (I'm not paranoid enough to imagine kernel
|
/* Errors ignored (I'm not paranoid enough to imagine kernel
|
||||||
* which doesn't know local ip) */
|
* which doesn't know local ip) */
|
||||||
@ -329,7 +334,7 @@ int tcpsvd_main(int argc, char **argv)
|
|||||||
bb_error_msg_and_die("cannot look up local hostname for %s", local_ip);
|
bb_error_msg_and_die("cannot look up local hostname for %s", local_ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(option_mask32 & OPT_E)) {
|
if (!(option_mask32 & OPT_E)) {
|
||||||
/* setup ucspi env */
|
/* setup ucspi env */
|
||||||
xsetenv("PROTO", "TCP");
|
xsetenv("PROTO", "TCP");
|
||||||
@ -346,7 +351,7 @@ int tcpsvd_main(int argc, char **argv)
|
|||||||
if (cur_per_host > 0)
|
if (cur_per_host > 0)
|
||||||
xsetenv("TCPCONCURRENCY", utoa(cur_per_host));
|
xsetenv("TCPCONCURRENCY", utoa(cur_per_host));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (instructs) {
|
if (instructs) {
|
||||||
ac = ipsvd_check(iscdb, &inst, &match, (char*)instructs,
|
ac = ipsvd_check(iscdb, &inst, &match, (char*)instructs,
|
||||||
@ -356,11 +361,11 @@ int tcpsvd_main(int argc, char **argv)
|
|||||||
} else
|
} else
|
||||||
ac = IPSVD_DEFAULT;
|
ac = IPSVD_DEFAULT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (max_per_host && verbose)
|
if (max_per_host && verbose)
|
||||||
printf("%s: info: concurrency %u %s %u/%u\n",
|
printf("%s: info: concurrency %u %s %u/%u\n",
|
||||||
applet_name, pid, remote_ip, cur_per_host, max_per_host);
|
applet_name, pid, remote_ip, cur_per_host, max_per_host);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("%s: info: start %u %s:%s :%s:%s:%u\n",
|
printf("%s: info: start %u %s:%s :%s:%s:%u\n",
|
||||||
applet_name, pid,
|
applet_name, pid,
|
||||||
@ -445,6 +450,8 @@ host
|
|||||||
host either is a hostname, or a dotted-decimal IP address,
|
host either is a hostname, or a dotted-decimal IP address,
|
||||||
or 0. If host is 0, tcpsvd accepts connections to any local
|
or 0. If host is 0, tcpsvd accepts connections to any local
|
||||||
IP address.
|
IP address.
|
||||||
|
* busybox accepts IPv6 addresses and host:port pairs too
|
||||||
|
In this case second parameter is ignored
|
||||||
port
|
port
|
||||||
tcpsvd accepts connections to host:port. port may be a name
|
tcpsvd accepts connections to host:port. port may be a name
|
||||||
from /etc/services or a number.
|
from /etc/services or a number.
|
||||||
@ -453,14 +460,16 @@ prog
|
|||||||
tcpsvd normally runs prog, with file descriptor 0 reading from
|
tcpsvd normally runs prog, with file descriptor 0 reading from
|
||||||
the network, and file descriptor 1 writing to the network.
|
the network, and file descriptor 1 writing to the network.
|
||||||
By default it also sets up TCP-related environment variables,
|
By default it also sets up TCP-related environment variables,
|
||||||
see tcp-environ(5)
|
see tcp-environ(5)
|
||||||
-i dir
|
-i dir
|
||||||
read instructions for handling new connections from the instructions
|
read instructions for handling new connections from the instructions
|
||||||
directory dir. See ipsvd-instruct(5) for details.
|
directory dir. See ipsvd-instruct(5) for details.
|
||||||
|
* ignored by busyboxed version
|
||||||
-x cdb
|
-x cdb
|
||||||
read instructions for handling new connections from the constant database
|
read instructions for handling new connections from the constant database
|
||||||
cdb. The constant database normally is created from an instructions
|
cdb. The constant database normally is created from an instructions
|
||||||
directory by running ipsvd-cdb(8).
|
directory by running ipsvd-cdb(8).
|
||||||
|
* ignored by busyboxed version
|
||||||
-t sec
|
-t sec
|
||||||
timeout. This option only takes effect if the -i option is given.
|
timeout. This option only takes effect if the -i option is given.
|
||||||
While checking the instructions directory, check the time of last access
|
While checking the instructions directory, check the time of last access
|
||||||
@ -468,47 +477,50 @@ prog
|
|||||||
and remove the file if it wasn't accessed within the last sec seconds;
|
and remove the file if it wasn't accessed within the last sec seconds;
|
||||||
tcpsvd does not discard or remove a file if the user's write permission
|
tcpsvd does not discard or remove a file if the user's write permission
|
||||||
is not set, for those files the timeout is disabled. Default is 0,
|
is not set, for those files the timeout is disabled. Default is 0,
|
||||||
which means that the timeout is disabled.
|
which means that the timeout is disabled.
|
||||||
|
* ignored by busyboxed version
|
||||||
-l name
|
-l name
|
||||||
local hostname. Do not look up the local hostname in DNS, but use name
|
local hostname. Do not look up the local hostname in DNS, but use name
|
||||||
as hostname. This option must be set if tcpsvd listens on port 53
|
as hostname. This option must be set if tcpsvd listens on port 53
|
||||||
to avoid loops.
|
to avoid loops.
|
||||||
-u user[:group]
|
-u user[:group]
|
||||||
drop permissions. Switch user ID to user's UID, and group ID to user's
|
drop permissions. Switch user ID to user's UID, and group ID to user's
|
||||||
primary GID after creating and binding to the socket. If user is followed
|
primary GID after creating and binding to the socket. If user is followed
|
||||||
by a colon and a group name, the group ID is switched to the GID of group
|
by a colon and a group name, the group ID is switched to the GID of group
|
||||||
instead. All supplementary groups are removed.
|
instead. All supplementary groups are removed.
|
||||||
-c n
|
-c n
|
||||||
concurrency. Handle up to n connections simultaneously. Default is 30.
|
concurrency. Handle up to n connections simultaneously. Default is 30.
|
||||||
If there are n connections active, tcpsvd defers acceptance of a new
|
If there are n connections active, tcpsvd defers acceptance of a new
|
||||||
connection until an active connection is closed.
|
connection until an active connection is closed.
|
||||||
-C n[:msg]
|
-C n[:msg]
|
||||||
per host concurrency. Allow only up to n connections from the same IP
|
per host concurrency. Allow only up to n connections from the same IP
|
||||||
address simultaneously. If there are n active connections from one IP
|
address simultaneously. If there are n active connections from one IP
|
||||||
address, new incoming connections from this IP address are closed
|
address, new incoming connections from this IP address are closed
|
||||||
immediately. If n is followed by :msg, the message msg is written
|
immediately. If n is followed by :msg, the message msg is written
|
||||||
to the client if possible, before closing the connection. By default
|
to the client if possible, before closing the connection. By default
|
||||||
msg is empty. See ipsvd-instruct(5) for supported escape sequences in msg.
|
msg is empty. See ipsvd-instruct(5) for supported escape sequences in msg.
|
||||||
|
|
||||||
For each accepted connection, the current per host concurrency is
|
For each accepted connection, the current per host concurrency is
|
||||||
available through the environment variable TCPCONCURRENCY. n and msg
|
available through the environment variable TCPCONCURRENCY. n and msg
|
||||||
can be overwritten by ipsvd(7) instructions, see ipsvd-instruct(5).
|
can be overwritten by ipsvd(7) instructions, see ipsvd-instruct(5).
|
||||||
By default tcpsvd doesn't keep track of connections.
|
By default tcpsvd doesn't keep track of connections.
|
||||||
-h
|
-h
|
||||||
Look up the client's hostname in DNS.
|
Look up the client's hostname in DNS.
|
||||||
-p
|
-p
|
||||||
paranoid. After looking up the client's hostname in DNS, look up the IP
|
paranoid. After looking up the client's hostname in DNS, look up the IP
|
||||||
addresses in DNS for that hostname, and forget about the hostname
|
addresses in DNS for that hostname, and forget about the hostname
|
||||||
if none of the addresses match the client's IP address. You should
|
if none of the addresses match the client's IP address. You should
|
||||||
set this option if you use hostname based instructions. The -p option
|
set this option if you use hostname based instructions. The -p option
|
||||||
implies the -h option.
|
implies the -h option.
|
||||||
|
* ignored by busyboxed version
|
||||||
-b n
|
-b n
|
||||||
backlog. Allow a backlog of approximately n TCP SYNs. On some systems n
|
backlog. Allow a backlog of approximately n TCP SYNs. On some systems n
|
||||||
is silently limited. Default is 20.
|
is silently limited. Default is 20.
|
||||||
-E
|
-E
|
||||||
no special environment. Do not set up TCP-related environment variables.
|
no special environment. Do not set up TCP-related environment variables.
|
||||||
-v
|
-v
|
||||||
verbose. Print verbose messsages to standard output.
|
verbose. Print verbose messsages to standard output.
|
||||||
-vv
|
-vv
|
||||||
more verbose. Print more verbose messages to standard output.
|
more verbose. Print more verbose messages to standard output.
|
||||||
|
* no difference between -v and -vv in busyboxed version
|
||||||
*/
|
*/
|
||||||
|
@ -23,14 +23,14 @@ int dumpleases_main(int argc, char *argv[])
|
|||||||
OPT_r = 0x2, // -r
|
OPT_r = 0x2, // -r
|
||||||
OPT_f = 0x4, // -f
|
OPT_f = 0x4, // -f
|
||||||
};
|
};
|
||||||
#if ENABLE_GETOPT_LONG
|
#if ENABLE_GETOPT_LONG
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
{ "absolute", no_argument, 0, 'a' },
|
{ "absolute", no_argument, 0, 'a' },
|
||||||
{ "remaining", no_argument, 0, 'r' },
|
{ "remaining", no_argument, 0, 'r' },
|
||||||
{ "file", required_argument, 0, 'f' },
|
{ "file", required_argument, 0, 'f' },
|
||||||
{ NULL, 0, 0, 0 }
|
{ NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
applet_long_options = options;
|
applet_long_options = options;
|
||||||
#endif
|
#endif
|
||||||
opt_complementary = "=0:?:a--r:r--a";
|
opt_complementary = "=0:?:a--r:r--a";
|
||||||
|
Loading…
Reference in New Issue
Block a user