#include #include #include #include #include #include "algo_skel.h" #include "donar_client.h" #include "donar_server.h" int main(int argc, char** argv) { printf("~ Donar ~\n"); int opt, is_server, is_client; char *host, *port, *onion_file; host = NULL; port = NULL; onion_file = NULL; is_server = 0; is_client = 0; while ((opt = getopt(argc, argv, "csh:p:o:")) != -1) { switch(opt) { case 's': is_server = 1; break; case 'h': host = strdup(optarg); break; case 'p': port = strdup(optarg); break; case 'o': onion_file = strdup(optarg); break; case 'c': is_client = 1; break; default: fprintf(stderr, "Usage: %s [-c -p -o | -s -h -p ]\n", argv[0]); exit(EXIT_FAILURE); } } if (!(is_server ^ is_client)) { fprintf(stderr, "You need to choose between client and server\n"); exit(EXIT_FAILURE); } struct algo_skel as; algo_naive (&as); if (is_server) { struct donar_server_ctx ctx; if (host == NULL || port == NULL) { fprintf(stderr, "You need to set a host -h and a port -p\n"); exit(EXIT_FAILURE); } printf("params: %s:%s\n", host, port); donar_server(&ctx, &as, host, port); } else if (is_client) { struct donar_client_ctx ctx; if (port == NULL || onion_file == NULL) { fprintf(stderr, "You need to set an onion_file -o and a port -p\n"); exit(EXIT_FAILURE); } donar_client(&ctx, &as, onion_file, port); } free(onion_file); free(port); free(host); return 0; }