Browse Source

Packaging and parameter parsing fixes

pull/35/head
Luca Deri 6 years ago
parent
commit
d299d558ac
  1. 33
      edge.c
  2. 0
      packages/debian/Makefile.in
  3. 3
      packages/debian/configure
  4. 1
      packages/debian/configure.in
  5. 12
      packages/etc/n2n/edge.conf
  6. 15
      sn.c

33
edge.c

@ -110,6 +110,9 @@ static int scan_address(char * ip_addr, size_t addr_size,
static void help() {
print_n2n_version();
printf("edge <config file> (see edge.conf)\n"
"or\n"
);
printf("edge "
#if defined(N2N_CAN_NAME_IFACE)
"-d <tun device> "
@ -551,10 +554,12 @@ int main(int argc, char* argv[]) {
int keep_on_running = 1;
int rc;
int i;
n2n_edge_t eee; /* single instance for this program */
edge_conf_t ec;
if(argc == 1)
help();
ec.local_port = 0 /* any port */;
ec.mgmt_port = N2N_EDGE_MGMT_PORT; /* 5644 by default */
snprintf(ec.tuntap_dev_name, sizeof(ec.tuntap_dev_name), "edge0");
@ -570,14 +575,12 @@ int main(int argc, char* argv[]) {
ec.groupid = 0; /* root is the only guaranteed ID */
#endif
if(-1 == edge_init(&eee))
{
if(-1 == edge_init(&eee)) {
traceEvent(TRACE_ERROR, "Failed in edge_init");
exit(1);
}
if(getenv("N2N_KEY"))
{
if(getenv("N2N_KEY")) {
ec.encrypt_key = strdup(getenv("N2N_KEY"));
}
@ -596,19 +599,12 @@ int main(int argc, char* argv[]) {
#endif
rc = loadFromCLI(argc, argv, &ec, &eee);
if(rc < 0)
return(-1);
#ifndef WIN32
if(eee.daemon) {
useSyslog = 1; /* traceEvent output now goes to syslog. */
daemonize();
}
#endif /* #ifndef WIN32 */
if((rc < 0) || (eee.sn_num == 0))
help();
traceEvent(TRACE_NORMAL, "Starting n2n edge %s %s", n2n_sw_version, n2n_sw_buildDate);
for (i=0; i< N2N_EDGE_NUM_SUPERNODES; ++i)
for (i=0; i<eee.sn_num; ++i)
traceEvent(TRACE_NORMAL, "supernode %u => %s\n", i, (eee.sn_ip_array[i]));
supernode2addr(&(eee.supernode), eee.sn_ip_array[eee.sn_idx]);
@ -624,6 +620,13 @@ int main(int argc, char* argv[]) {
help();
}
#ifndef WIN32
if(eee.daemon) {
useSyslog = 1; /* traceEvent output now goes to syslog. */
daemonize();
}
#endif /* #ifndef WIN32 */
if((NULL == ec.encrypt_key) && (0 == strlen(eee.keyschedule)))
{
traceEvent(TRACE_WARNING, "Encryption is disabled in edge.");

0
packages/debian/Makefile → packages/debian/Makefile.in

3
packages/debian/configure

@ -1728,6 +1728,8 @@ ac_config_files="$ac_config_files ../etc/systemd/system/edge.service"
ac_config_files="$ac_config_files ../etc/systemd/system/supernode.service"
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
@ -2439,6 +2441,7 @@ do
"debian/rules") CONFIG_FILES="$CONFIG_FILES debian/rules" ;;
"../etc/systemd/system/edge.service") CONFIG_FILES="$CONFIG_FILES ../etc/systemd/system/edge.service" ;;
"../etc/systemd/system/supernode.service") CONFIG_FILES="$CONFIG_FILES ../etc/systemd/system/supernode.service" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac

1
packages/debian/configure.in

@ -41,4 +41,5 @@ AC_CONFIG_FILES(debian/control)
AC_CONFIG_FILES(debian/rules)
AC_CONFIG_FILES(../etc/systemd/system/edge.service)
AC_CONFIG_FILES(../etc/systemd/system/supernode.service)
AC_CONFIG_FILES(Makefile)
AC_OUTPUT

12
packages/etc/n2n/edge.conf

@ -7,17 +7,17 @@
# -d|--tun-device
# Specifies the name of the TUN interface.
#
# -d=n2n0
-d=n2n0
#
# -c|--community
# Specifies the n2n community name the edge belongs to.
#
# -c=mynetwork
-c=mynetwork
#
# -k
# Sets the encryption key (ASCII). The environment variable N2N_KEY=<key> can also be used.
#
# -k=mypassword
-k=mypassword
#
# -m
# Specified the MAC address for the TAP interface (random otherwise).
@ -27,15 +27,15 @@
# -a
# Sets the interface address. For DHCP use '-r -a dhcp:0.0.0.0'.
#
# -a=1.2.3.4
-a=1.2.3.4
#
# -p
# Sets the local UDP port to a fixed port.
#
# -p=50001
-p=50001
#
# -l|--supernode-list
# Specifies the supernode IP and port.
#
# -l=7.8.9.0:7777
-l=7.8.9.0:7777
#

15
sn.c

@ -26,9 +26,7 @@
#define N2N_SN_MGMT_PORT 5645
struct sn_stats
{
struct sn_stats {
size_t errors; /* Number of errors encountered. */
size_t reg_super; /* Number of REGISTER_SUPER requests received. */
size_t reg_super_nak; /* Number of REGISTER_SUPER requests declined. */
@ -40,8 +38,7 @@ struct sn_stats
typedef struct sn_stats sn_stats_t;
struct n2n_sn
{
struct n2n_sn {
time_t start_time; /* Used to measure uptime. */
sn_stats_t stats;
int daemon; /* If non-zero then daemonise. */
@ -606,7 +603,6 @@ static int process_udp( n2n_sn_t * sss,
}
return 0;
}
@ -617,6 +613,9 @@ static void help()
{
print_n2n_version();
printf("supernode <config file> (see supernode.conf)\n"
"or\n"
);
printf("supernode ");
printf("-l <lport> ");
printf("[-f] ");
@ -794,6 +793,9 @@ int main( int argc, char * const argv[] )
int rc;
n2n_sn_t sss;
if(argc == 1)
help();
init_sn(&sss);
#ifndef WIN32
@ -940,4 +942,3 @@ static int run_loop( n2n_sn_t * sss )
return 0;
}

Loading…
Cancel
Save