rework my measlat command
This commit is contained in:
parent
1e1111159e
commit
5c2ac2a1f6
2 changed files with 23 additions and 20 deletions
|
@ -455,12 +455,15 @@ void spawn_tcp_server(struct evt_core_ctx* evts, uint16_t port) {
|
|||
printf("--- TCP server is listening\n");
|
||||
}
|
||||
|
||||
void measlat_create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_t port, enum TOR_ONION_FLAGS tof) {
|
||||
tor_os_create (tos, "onion_services.pub", "onion_services.txt", 1);
|
||||
void measlat_create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_t port, char* tor_port, enum TOR_ONION_FLAGS tof) {
|
||||
char fnpub[64] = {0}, fnpriv[64] = {0};
|
||||
sprintf(fnpub, "os_%u.pub", port);
|
||||
sprintf(fnpriv, "os_%u.priv", port);
|
||||
tor_os_create (tos, fnpub, fnpriv, 1);
|
||||
tor_os_read (tos);
|
||||
|
||||
int err = 0;
|
||||
err = tor_ctl_connect (tctl, "127.0.0.1", "9051");
|
||||
err = tor_ctl_connect (tctl, "127.0.0.1", tor_port);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "Unable to open Tor Socket\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -473,9 +476,9 @@ void measlat_create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl,
|
|||
printf("--- Onion services created\n");
|
||||
}
|
||||
|
||||
void spawn_onion_server(struct evt_core_ctx* evts, uint16_t port, struct tor_os_str* tos, struct tor_ctl* tctl, struct measlat_ctx* mctx) {
|
||||
spawn_tcp_server(evts, port);
|
||||
measlat_create_onion_services (tos, tctl, port, mctx->tor_flags);
|
||||
void spawn_onion_server(struct evt_core_ctx* evts, struct measlat_ctx* mctx, struct tor_os_str* tos, struct tor_ctl* tctl) {
|
||||
spawn_tcp_server(evts, atoi(mctx->port));
|
||||
measlat_create_onion_services (tos, tctl, atoi(mctx->port), mctx->tor_port, mctx->tor_flags);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
@ -552,7 +555,7 @@ int main(int argc, char** argv) {
|
|||
if (mctx.role == MEASLAT_SERVER) {
|
||||
if (streq(mctx.transport, "udp")) spawn_udp_server (&evts);
|
||||
else if (streq(mctx.transport, "tcp")) spawn_tcp_server(&evts, atoi(mctx.port));
|
||||
else if (streq(mctx.transport, "tor")) spawn_onion_server (&evts, atoi(mctx.port), &tos, &tctl, &mctx);
|
||||
else if (streq(mctx.transport, "tor")) spawn_onion_server (&evts, &mctx, &tos, &tctl);
|
||||
}
|
||||
else if (mctx.role == MEASLAT_CLIENT) {
|
||||
if (streq(mctx.transport, "udp")) spawn_udp_client(&evts);
|
||||
|
|
|
@ -85,7 +85,7 @@ int main(int argc, char** argv) {
|
|||
.flags = EPOLLIN | EPOLLET,
|
||||
.socklist = NULL
|
||||
};
|
||||
evt_core_init(&evts, uctx.verbose <= 0 ? 0 : uc tx.verbose - 1);
|
||||
evt_core_init(&evts, uctx.verbose <= 0 ? 0 : uctx.verbose - 1);
|
||||
evt_core_add_cat(&evts, &udp_read);
|
||||
|
||||
// 3. Register UDP socket
|
||||
|
|
Loading…
Reference in a new issue