bip bip I am coding

This commit is contained in:
Quentin 2021-01-25 17:19:32 +01:00
parent 5eee43c9db
commit b6806395ad
2 changed files with 9 additions and 7 deletions

View file

@ -560,6 +560,6 @@ int main(int argc, char** argv) {
return 0; return 0;
usage: usage:
fprintf(stderr, "Usage: %s [-h <host>] [-p <port>] [-l] [-r] [-t <udp|tor>] [-c <count>] [-i <ms>] [-s <bytes>]\n", argv[0]); fprintf(stderr, "Usage: %s [-h <host>] [-p <port>] [-l] [-r] [-t <udp|tcp|tor>] [-c <count>] [-i <ms>] [-s <bytes>]\n", argv[0]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View file

@ -94,8 +94,7 @@ int main(int argc, char** argv) {
int tcp_serv_sock = 0, err, opt; int tcp_serv_sock = 0, err, opt;
struct evt_core_ctx evts = {0}; struct evt_core_ctx evts = {0};
uint16_t ports[] = {7500}; uint16_t port = 7500;
int ports_count = sizeof(ports[0]) / sizeof(ports);
struct tor_os_str tos; struct tor_os_str tos;
struct tor_ctl tctl; struct tor_ctl tctl;
enum TOR_ONION_FLAGS tof = TOR_ONION_FLAG_NONE; enum TOR_ONION_FLAGS tof = TOR_ONION_FLAG_NONE;
@ -103,11 +102,14 @@ int main(int argc, char** argv) {
struct torecho_ctx tctx = {0}; struct torecho_ctx tctx = {0};
tctx.mp.payload_size = 1500; tctx.mp.payload_size = 1500;
while ((opt = getopt(argc, argv, "ns:mt")) != -1) { while ((opt = getopt(argc, argv, "ns:mtp:")) != -1) {
switch(opt) { switch(opt) {
case 't': case 't':
tctx.is_tor = 1; tctx.is_tor = 1;
break; break;
case 'p':
port = atoi(optarg);
break;
case 'n': case 'n':
tof |= TOR_ONION_FLAG_NON_ANONYMOUS; tof |= TOR_ONION_FLAG_NON_ANONYMOUS;
break; break;
@ -151,12 +153,12 @@ int main(int argc, char** argv) {
if (tctx.is_tor) { if (tctx.is_tor) {
// 2. Create or load onion services // 2. Create or load onion services
te_create_onion_services (&tos, &tctl, ports, ports_count, tof); te_create_onion_services (&tos, &tctl, &port, 1, tof);
printf("--- Onion services created\n"); printf("--- Onion services created\n");
} }
// 3. Create TCP server // 3. Create TCP server
sprintf(url, "%d", ports[0]); sprintf(url, "%d", port);
tcp_serv_sock = create_tcp_server ("0.0.0.0", url); tcp_serv_sock = create_tcp_server ("0.0.0.0", url);
err = listen(tcp_serv_sock, SOMAXCONN); err = listen(tcp_serv_sock, SOMAXCONN);
@ -166,7 +168,7 @@ int main(int argc, char** argv) {
fdinfo.url = url; fdinfo.url = url;
fdinfo.fd = tcp_serv_sock; fdinfo.fd = tcp_serv_sock;
sprintf(url, "tcp:co:127.0.0.1:%d", ports[0]); sprintf(url, "tcp:co:127.0.0.1:%d", port);
fdinfo.cat->name = "tcp-co"; fdinfo.cat->name = "tcp-co";
evt_core_add_fd(&evts, &fdinfo); evt_core_add_fd(&evts, &fdinfo);
printf("--- TCP server is listening\n"); printf("--- TCP server is listening\n");