struct pollfd pollfd = { .fd = fd, .events = POLLIN };
struct timeval tv_start, tv_now;
int got = 0, tmp;
-
+
gettimeofday(&tv_start, NULL);
-
+
while (got < bytes && timeout >= 0) {
if (poll(&pollfd, 1, timeout*1000) <= 0)
DEBUG_RETURN("poll failed: %d (got %d)\n", errno, got);
DEBUG_OUT("getaddrinfo\n");
if (!res)
DEBUG_OUT("getaddrinfo returned empty set\n");
-
+
if (connect(fd, res->ai_addr, res->ai_addrlen))
DEBUG_OUT("failed to connect\n");
struct timeval tv_start, tv_now;
int got = 0, tmp;
char *match;
-
+
gettimeofday(&tv_start, NULL);
-
+
while (got < buflen && timeout >= 0) {
if (poll(&pollfd, 1, timeout*1000) <= 0)
DEBUG_RETURN("poll failed: %d (got %d)\n", errno, got);
fprintf(stderr, " (default localhost 9050)\n");
return 2;
}
-
+
printf("220 Welcome\r\n");
fflush(stdout);
-
+
command:
if ((linelen = readline(0, buf, sizeof(buf), 30)) < 0) {
printf("421 connection timed out\r\n");
printf("500 invalid command\r\n");
fflush(stdout);
goto command;
-
+
helo_continue:
tmp = strtok(buf+5, " ");
if (!tmp) {
fflush(stdout);
return 0;
}
-
+
linelen = readline(fd, buf2, sizeof(buf2), 120);
if (linelen < 0) {
printf("421 could not connect\r\n");
fflush(stdout);
return 0;
}
-
+
strncpy(buf+5, local_onion, sizeof(buf)-5);
linelen = strlen(buf);
*(buf+linelen) = '\r';
*(buf+linelen+1) = '\n';
write(fd, buf, linelen+2);
-
+
close(2); /* get rid of stderr */
/* now "all" we have to do is do a bidirectional copy of fd and stdio */
bidicopy(fd);