-/*
- Generate a public/private RSA keypair, and ask for a file to store
- them in.
-*/
-int keygen(int bits)
-{
- RSA *rsa_key;
- FILE *f;
- config_t const *cfg;
- char *filename;
-
- fprintf(stderr, _("Generating %d bits keys:\n"), bits);
- rsa_key = RSA_generate_key(bits, 0xFFFF, indicator, NULL);
-
- if(!rsa_key)
- {
- fprintf(stderr, _("Error during key generation!"));
- return -1;
- }
- else
- fprintf(stderr, _("Done.\n"));
-
- if(config && (cfg = get_config_val(config, config_name)))
- asprintf(&filename, "%s/hosts/%s", confbase, cfg->data.ptr);
- else
- asprintf(&filename, "%s/rsa_key.priv", confbase);
-
- if((f = ask_and_safe_open(filename, _("public RSA key"), "a")) == NULL)
- return -1;
-
- if(ftell(f))
- fprintf(stderr, _("Appending key to existing contents.\nMake sure only one key is stored in the file.\n"));
-
- PEM_write_RSAPublicKey(f, rsa_key);
- fclose(f);
- free(filename);
-
- asprintf(&filename, "%s/rsa_key.priv", confbase);
- if((f = ask_and_safe_open(filename, _("private RSA key"), "a")) == NULL)
- return -1;
-
- if(ftell(f))
- fprintf(stderr, _("Appending key to existing contents.\nMake sure only one key is stored in the file.\n"));
-
- PEM_write_RSAPrivateKey(f, rsa_key, NULL, NULL, 0, NULL, NULL);
- fclose(f);
- free(filename);
-
- return 0;
+static struct option const long_options[] = {
+ {"config", required_argument, NULL, 'c'},
+ {"net", required_argument, NULL, 'n'},
+ {"help", no_argument, NULL, 1},
+ {"version", no_argument, NULL, 2},
+ {"no-detach", no_argument, NULL, 'D'},
+ {"debug", optional_argument, NULL, 'd'},
+ {"bypass-security", no_argument, NULL, 3},
+ {"option", required_argument, NULL, 'o'},
+ {NULL, 0, NULL, 0}
+};
+
+#ifdef HAVE_MINGW
+static struct WSAData wsa_state;
+CRITICAL_SECTION mutex;
+int main2(int argc, char **argv);
+#endif
+
+static void usage(bool status) {
+ if(status)
+ fprintf(stderr, "Try `tincd --help\' for more information.\n");
+ else {
+ printf("Usage: tincd [option]...\n\n");
+ printf( " -c, --config=DIR Read configuration options from DIR.\n"
+ " -D, --no-detach Don't fork and detach.\n"
+ " -d, --debug[=LEVEL] Increase debug level or set it to LEVEL.\n"
+ " -n, --net=NETNAME Connect to net NETNAME.\n"
+ " --bypass-security Disables meta protocol security, for debugging.\n"
+ " -o, --option[HOST.]KEY=VALUE Set global/host configuration value.\n"
+ " --help Display this help and exit.\n"
+ " --version Output version information and exit.\n\n");
+ printf("Report bugs to bugs@meshlink.io.\n");
+ }