Browse Source

reworked supernode help text (#605)

pull/609/head
Logan oos Even 4 years ago
committed by GitHub
parent
commit
39a71513f4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      include/n2n.h
  2. 172
      src/sn.c

1
include/n2n.h

@ -31,6 +31,7 @@
tunctl -u UID -t tunX tunctl -u UID -t tunX
*/ */
#define N2N_HAVE_DAEMON /* needs to be defined before it gets undefined */
/* #define N2N_CAN_NAME_IFACE */ /* #define N2N_CAN_NAME_IFACE */

172
src/sn.c

@ -174,58 +174,111 @@ static int load_allowed_sn_community (n2n_sn_t *sss, char *path) {
/* *************************************************** */ /* *************************************************** */
/** Help message to print if the command line arguments are not valid. */ /** Help message to print if the command line arguments are not valid. */
static void help () { static void help (int level) {
printf("\n");
print_n2n_version(); print_n2n_version();
printf("supernode <config file> (see supernode.conf)\n" if(level == 0) /* short help */ {
"or\n"
); printf(" basic usage: supernode <config file> (see supernode.conf)\n"
printf("supernode "); "\n"
printf("-p <local port> "); " or supernode "
printf("-c <path> "); " -p <local port> "
printf("-l <supernode:port> "); "\n "
"\n -h shows a quick reference including all available options"
#if defined(N2N_HAVE_DAEMON) "\n --help gives a detailed parameter description"
printf("[-f] "); "\n man files for n2n, edge, and superndode contain in-depth information"
"\n\n");
} else if(level == 1) /* quick reference */ {
printf(" general usage: supernode <config file> (see supernode.conf)\n"
"\n"
" or supernode "
" -p <local port>"
"\n "
"[-F <federation name>] "
"\n options for under- "
"[-l <supernode host:port>] "
"\n lying connection "
#ifdef SN_MANUAL_MAC
"[-m <mac address>] "
#endif #endif
printf("[-F <federation_name>] "); "\n\n overlay network "
#if 0 "[-c <community list file>] "
printf("[-m <mac_address>] "); "\n configuration "
"[-a <net ip>-<net ip>/<cidr suffix>] "
"\n\n local options "
#if defined(N2N_HAVE_DAEMON)
"[-f] "
#endif #endif
"[-t <management port>] "
"[-v] "
#ifndef WIN32 #ifndef WIN32
printf("[-u <uid> -g <gid>] "); "\n "
#endif /* ifndef WIN32 */ "[-u <numerical user id>]"
printf("[-t <mgmt port>] "); "[-g <numerical group id>]"
printf("[-a <net-net/bit>] "); #endif
printf("[-v] "); "\n\n meaning of the "
printf("\n\n");
printf("-p <port> | Set UDP main listen port to <port>\n");
printf("-c <path> | File containing the allowed communities.\n");
printf("-l <sn host:port> | Name/IP of a known supernode:port.\n");
#if defined(N2N_HAVE_DAEMON) #if defined(N2N_HAVE_DAEMON)
printf("-f | Run in foreground.\n"); "[-f] do not fork but run in foreground"
#endif /* #if defined(N2N_HAVE_DAEMON) */ #endif
printf("-F <fed_name> | Name of the supernodes federation (otherwise use '%s' by default)\n", (char *)FEDERATION_NAME); "\n flag options "
#if 0 "[-v] make more verbose, repeat as required"
printf("-m <mac_addr> | Fix MAC address for the supernode (otherwise it may be random)\n" "\n "
" | eg. -m 01:02:03:04:05:06\n");
#endif /* #if 0 */ "\n -h shows this quick reference including all available options"
#ifndef WIN32 "\n --help gives a detailed parameter description"
printf("-u <UID> | User ID (numeric) to use when privileges are dropped.\n"); "\n man files for n2n, edge, and superndode contain in-depth information"
printf("-g <GID> | Group ID (numeric) to use when privileges are dropped.\n"); "\n\n");
#endif /* ifndef WIN32 */
printf("-t <port> | Management UDP Port (for multiple supernodes on a machine).\n"); } else /* long help */ {
printf("-a <net-net/bit> | Subnet range for auto ip address service, e.g.\n");
printf(" | -a 192.168.0.0-192.168.255.0/24, defaults to 10.128.255.0-10.255.255.0/24\n"); printf(" general usage: supernode <config file> (see supernode.conf)\n"
printf("-v | Increase verbosity. Can be used multiple times.\n"); "\n"
printf("-h | This help message.\n"); " or supernode -p <local port>\n"
" [further optional command line parameters]\n\n"
);
printf (" OPTIONS FOR THE UNDERLYING NETWORK CONNECTION\n");
printf (" ---------------------------------------------\n\n");
printf(" -p <local port> | fixed local UDP port\n");
printf(" -F <fed name> | name of the supernode's federation, defaults to\n"
" | '%s'\n", (char *)FEDERATION_NAME);
printf(" -l <host:port> | ip address or name, and port of known supernode\n");
#ifdef SN_MANUAL_MAC
printf(" -m <mac> | fixed MAC address for the supernode, e.g.\n"
" | '-m 10:20:30:40:50:60', random otherwise\n");
#endif
printf ("\n");
printf (" TAP DEVICE AND OVERLAY NETWORK CONFIGURATION\n");
printf (" --------------------------------------------\n\n");
printf(" -c <path> | file containing the allowed communities\n");
printf(" -a <net-net/n> | subnet range for auto ip address service, e.g.\n"
" | '-a 192.168.0.0-192.168.255.0/24', defaults\n"
" | to '10.128.255.0-10.255.255.0/24'\n");
printf ("\n"); printf ("\n");
printf (" LOCAL OPTIONS\n");
printf (" -------------\n\n");
#if defined(N2N_HAVE_DAEMON)
printf(" -f | do not fork and run as a daemon, rather run in foreground\n");
#endif
printf(" -t <port> | management UDP port, for multiple supernodes on a machine\n");
printf(" -v | make more verbose, repeat as required\n");
#ifndef WIN32
printf(" -u <UID> | numeric user ID to use when privileges are dropped\n");
printf(" -g <GID> | numeric group ID to use when privileges are dropped\n");
#endif
printf("\n -h shows a quick reference including all available options"
"\n --help gives this detailed parameter description"
"\n man files for n2n, edge, and superndode contain in-depth information"
"\n\n");
}
exit(1); exit(0);
} }
/* *************************************************** */ /* *************************************************** */
static int setOption (int optkey, char *_optarg, n2n_sn_t *sss) { static int setOption (int optkey, char *_optarg, n2n_sn_t *sss) {
@ -344,7 +397,6 @@ static int setOption (int optkey, char *_optarg, n2n_sn_t *sss) {
break; break;
} }
#ifndef WIN32 #ifndef WIN32
case 'u': /* unprivileged uid */ case 'u': /* unprivileged uid */
sss->userid = atoi(_optarg); sss->userid = atoi(_optarg);
@ -354,7 +406,6 @@ static int setOption (int optkey, char *_optarg, n2n_sn_t *sss) {
sss->groupid = atoi(_optarg); sss->groupid = atoi(_optarg);
break; break;
#endif #endif
case 'F': { /* federation name */ case 'F': { /* federation name */
snprintf(sss->federation->community, N2N_COMMUNITY_SIZE - 1 ,"*%s", _optarg); snprintf(sss->federation->community, N2N_COMMUNITY_SIZE - 1 ,"*%s", _optarg);
@ -362,24 +413,26 @@ static int setOption (int optkey, char *_optarg, n2n_sn_t *sss) {
break; break;
} }
#ifdef SN_MANUAL_MAC
#if 0
case 'm': {/* MAC address */ case 'm': {/* MAC address */
str2mac(sss->mac_addr,_optarg); str2mac(sss->mac_addr,_optarg);
break; break;
} }
#endif /* #if 0 */ #endif
case 'c': /* community file */ case 'c': /* community file */
load_allowed_sn_community(sss, _optarg); load_allowed_sn_community(sss, _optarg);
break; break;
#if defined(N2N_HAVE_DAEMON)
case 'f': /* foreground */ case 'f': /* foreground */
sss->daemon = 0; sss->daemon = 0;
break; break;
#endif
case 'h': /* quick reference */
help(1);
break;
case 'h': /* help */ case '@': /* long help */
help(); help(2);
break; break;
case 'v': /* verbose */ case 'v': /* verbose */
@ -399,11 +452,13 @@ static int setOption (int optkey, char *_optarg, n2n_sn_t *sss) {
static const struct option long_options[] = { static const struct option long_options[] = {
{"communities", required_argument, NULL, 'c'}, {"communities", required_argument, NULL, 'c'},
#if defined(N2N_HAVE_DAEMON)
{"foreground", no_argument, NULL, 'f'}, {"foreground", no_argument, NULL, 'f'},
#endif
{"local-port", required_argument, NULL, 'p'}, {"local-port", required_argument, NULL, 'p'},
{"mgmt-port", required_argument, NULL, 't'}, {"mgmt-port", required_argument, NULL, 't'},
{"autoip", required_argument, NULL, 'a'}, {"autoip", required_argument, NULL, 'a'},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, '@'}, /* special character '@' to identify long help case */
{"verbose", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
@ -415,7 +470,18 @@ static int loadFromCLI (int argc, char * const argv[], n2n_sn_t *sss) {
u_char c; u_char c;
while((c = getopt_long(argc, argv, "fp:l:u:g:t:a:c:F:m:vh", while((c = getopt_long(argc, argv,
"p:l:t:a:c:F:vh"
#ifdef SN_MANUAL_MAC
"m:"
#endif
#if defined(N2N_HAVE_DAEMON)
"f"
#endif
#ifndef WIN32
"u:g:"
#endif
,
long_options, NULL)) != '?') { long_options, NULL)) != '?') {
if(c == 255) { if(c == 255) {
break; break;
@ -609,7 +675,7 @@ int main (int argc, char * const argv[]) {
#endif #endif
if(rc < 0) { if(rc < 0) {
help(); help(0); /* short help */
} }
#if defined(N2N_HAVE_DAEMON) #if defined(N2N_HAVE_DAEMON)

Loading…
Cancel
Save