86 lines
2.8 KiB
C
86 lines
2.8 KiB
C
#include "../kerep/src/kprint/kprintf.h"
|
|
|
|
// option help definition
|
|
#define HELP_OPT(ALIASES, PARAMS, DESCRIPTION...) \
|
|
FWHI" " ALIASES " " PARAMS FGRY "\n" DESCRIPTION
|
|
|
|
// option parameter help definition
|
|
#define HELP_PRM(PNAME) \
|
|
FWHI"[" FCYN PNAME FWHI"]"
|
|
|
|
// option nullable parameter help definition
|
|
#define HELP_PRMN(PNAME) \
|
|
FWHI"[" FCYN PNAME FWHI"?]"
|
|
|
|
// option parameter1/parameter2 help definition
|
|
#define HELP_PRM2(PNAME1, PNAME2) \
|
|
FWHI"[" FCYN PNAME1 FWHI"/" FCYN PNAME2 FWHI"]"
|
|
|
|
#define HELP_PRM3(PNAME1, PNAME2, PNAME3) \
|
|
FWHI"[" FCYN PNAME1 FWHI"/" FCYN PNAME2 FWHI"/" FCYN PNAME3 FWHI"]"
|
|
|
|
#define HELP_PRM4(PNAME1, PNAME2, PNAME3, PNAME4) \
|
|
FWHI"[" FCYN PNAME1 FWHI"/" FCYN PNAME2 FWHI"/" FCYN PNAME3 FWHI"/" FCYN PNAME4 FWHI"]"
|
|
|
|
const char* help_message = (
|
|
FWHI"Usage: port-tunnel "
|
|
HELP_PRM("protocol_options") " "
|
|
HELP_PRM("input_options") " "
|
|
HELP_PRM("output_options") " "
|
|
HELP_PRMN("other_options") "\n"
|
|
|
|
FWHI" Help syntax:\n"
|
|
" " HELP_PRM("val") FGRY" - some value\n"
|
|
" " HELP_PRMN("val") FGRY" - value or nothing\n"
|
|
" " HELP_PRM2("variant1", "variant2") FGRY" - variant1 or variant2\n"
|
|
|
|
FWHI" Protocol options:\n"
|
|
|
|
HELP_OPT("-p, --protocol",
|
|
HELP_PRM2("tcp","udp"),
|
|
" Set tunnel protocol.\n")
|
|
|
|
FWHI" Input mode options:\n"
|
|
|
|
HELP_OPT("-l, --listen",
|
|
HELP_PRM("ip") ":" HELP_PRM("port"),
|
|
" Listen for incomming packets at the address (if provided) and the port\n")
|
|
|
|
HELP_OPT("-c, --connect",
|
|
HELP_PRM("ip") ":" HELP_PRM("port") " "
|
|
HELP_PRM2(
|
|
"-s " HELP_PRM("ip") ":" HELP_PRM("port"),
|
|
"-b " HELP_PRM("ip") ":" HELP_PRM("port")
|
|
),
|
|
" Connect to a listening instance of port-tunnel.\n")
|
|
|
|
FWHI" Output mode options:\n"
|
|
|
|
HELP_OPT("-s, --send-to",
|
|
HELP_PRM("ip") ":" HELP_PRM("port"),
|
|
" Redirect packets from tunnel to "FCYN"ip:port"FWHI".\n"
|
|
" Use this flag if you need to create tunnel to an existing socket bound at "FCYN"ip:port"FWHI".\n")
|
|
|
|
HELP_OPT("-b, --bind-to",
|
|
HELP_PRM("ip") ":" HELP_PRM("port"),
|
|
" Bind new socket to "FCYN"ip:port"FWHI" and redirect packets from tunnel to it.\n"
|
|
" Use this flag if you want to connect something to "FCYN"ip:port"FWHI".\n")
|
|
|
|
FWHI" Other options:\n"
|
|
|
|
HELP_OPT("-h, --help, /?", "",
|
|
" Show this message.\n")
|
|
|
|
HELP_OPT("-d, --decrypt",
|
|
HELP_PRM("key"),
|
|
" Decrypt incoming packets with a key.\n")
|
|
|
|
HELP_OPT("-e, --encrypt",
|
|
HELP_PRM("key"),
|
|
" Encrypt outgoing packets with a key.\n")
|
|
|
|
HELP_OPT("-v, --verbosity, --log-level",
|
|
HELP_PRM4("debug", "info", "warning", "error"),
|
|
" Sets log verbocity level (default=info).\n")
|
|
);
|