+ FILE *f = fopen(tinc_conf, "w");
+ if(!f) {
+ fprintf(stderr, "Could not create file %s: %s\n", tinc_conf, strerror(errno));
+ return 1;
+ }
+
+ fprintf(f, "Name = %s\n", name);
+ fclose(f);
+
+ fclose(stdin);
+ if(!rsa_keygen(2048) || !ecdsa_keygen())
+ return false;
+
+ return true;
+
+}
+
+static int cmd_generate_keys(int argc, char *argv[]) {
+ return !(rsa_keygen(argc > 1 ? atoi(argv[1]) : 2048) && ecdsa_keygen());
+}
+
+static int cmd_generate_rsa_keys(int argc, char *argv[]) {
+ return !rsa_keygen(argc > 1 ? atoi(argv[1]) : 2048);
+}
+
+static int cmd_generate_ecdsa_keys(int argc, char *argv[]) {
+ return !ecdsa_keygen();
+}
+
+static int cmd_help(int argc, char *argv[]) {
+ usage(false);
+ return 0;
+}
+
+static int cmd_version(int argc, char *argv[]) {
+ version();
+ return 0;
+}
+
+static const struct {
+ const char *command;
+ int (*function)(int argc, char *argv[]);
+} commands[] = {
+ {"start", cmd_start},
+ {"stop", cmd_stop},
+ {"restart", cmd_restart},
+ {"reload", cmd_reload},
+ {"dump", cmd_dump},
+ {"purge", cmd_purge},
+ {"debug", cmd_debug},
+ {"retry", cmd_retry},
+ {"connect", cmd_connect},
+ {"disconnect", cmd_disconnect},
+ {"top", cmd_top},
+ {"pcap", cmd_pcap},
+ {"log", cmd_log},
+ {"pid", cmd_pid},
+ {"config", cmd_config},
+ {"init", cmd_init},
+ {"generate-keys", cmd_generate_keys},
+ {"generate-rsa-keys", cmd_generate_rsa_keys},
+ {"generate-ecdsa-keys", cmd_generate_ecdsa_keys},
+ {"help", cmd_help},
+ {"version", cmd_version},
+ {NULL, NULL},
+};
+
+int main(int argc, char *argv[]) {
+ program_name = argv[0];
+
+ if(!parse_options(argc, argv))
+ return 1;
+
+ make_names();
+
+ if(show_version) {
+ version();