#include "donar_server.h" void create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, int* ports, int ports_count) { tor_os_create (tos, "onion_services.pub", "onion_services.txt", ports_count); tor_os_read (tos); int err = 0; err = tor_ctl_connect (tctl, "127.0.0.1", "9051"); if (err < 0) { fprintf(stderr, "Unable to open Tor Socket\n"); exit(EXIT_FAILURE); } err = tor_ctl_add_onion (tctl, tos, ports); if (err != 0) { fprintf(stderr, "Unable to create Onion Services (error: %d)\n", err); exit(EXIT_FAILURE); } } void destroy_resources(struct tor_os_str* tos, struct tor_ctl* tctl) { tor_ctl_close (tctl); tor_os_free (tos); } void donar_server() { struct tor_os_str tos; struct tor_ctl tctl = {}; int ports[10] = { 7500, 7501, 7502, 7503, 7504, 7505, 7506, 7507, 7508, 7509}; create_onion_services (&tos, &tctl, ports, 10); printf("Onion services created\n"); destroy_resources (&tos, &tctl); }