Exemplo n.º 1
0
void test_host(struct parsedfile *config, char *host) {
	struct serverent *path;
	char *hostname, *port;
	char separator;
	unsigned long portno = 0;
	int af;
	int flag;
	struct sockaddr_in addr4;
#ifdef ENABLE_IPV6
	struct sockaddr_in6 addr6;
#endif
	void *hostaddr;
	char buf[60];

	/* See if a port has been specified */
	hostname = strsplit(&separator, &host, ": \t\n");
	if (separator == ':') {
		port = strsplit(NULL, &host, " \t\n");
		if (port)
			portno = strtol(port, NULL, 0);
	}

	/* First resolve the host to an ip */
#ifdef ENABLE_IPV6
	if ((flag = resolve_ip(AF_INET6, hostname, 0, 1, (void *) &addr6)) == -1) {
#endif
		af = AF_INET;
		flag = resolve_ip(AF_INET, hostname, 0, 1, (void *) &addr4);
		hostaddr = (void *) &addr4.sin_addr;
#ifdef ENABLE_IPV6
	} else {
		af = AF_INET6;
		hostaddr = (void *) &addr6.sin6_addr;
	}
#endif
	if (flag == -1) {
		fprintf(stderr, "Error: Cannot resolve %s\n", host);
		return;
	} else {
		inet_ntop(af, hostaddr, buf, 60);
		printf("Finding path for %s...\n", buf);
		if (!(is_local(config, af, hostaddr))) {
			printf("Path is local\n");
		} else {
			pick_server(config, &path, af, hostaddr, portno);
			if (path == &(config->defaultserver)) {
				printf("Path is via default server:\n");
				show_server(config, path, 1);
			} else {
				printf("Host is reached via this path:\n");
				show_server(config, path, 0);
			}
		}
	}

	return;
}
Exemplo n.º 2
0
void show_conf(struct parsedfile *config) {
	struct netent *net;
	struct serverent *server;

	/* Show the local networks */
	printf("=== Local networks (no socks server needed) ===\n");
	net = (config->localnets);
	while (net != NULL) {
		printf("Network: %15s ",
		       inet_ntoa(net->localip));
		printf("NetMask: %15s\n", 
		       inet_ntoa(net->localnet));
		net = net->next;
	}
	printf("\n");

	/* If we have a default server configuration show it */
	printf("=== Default Server Configuration ===\n");
	if ((config->defaultserver).address != NULL) {
		show_server(config, &(config->defaultserver), 1);
	} else {
		printf("No default server specified, this is rarely a "
		       "good idea\n");
	}
	printf("\n");

	/* Now show paths */
	if ((config->paths) != NULL) {
		server = (config->paths);
		while (server != NULL) {
			printf("=== Path (line no %d in configuration file)"
			       " ===\n", server->lineno);
			show_server(config, server, 0);
			printf("\n");
			server = server->next;
		}	
	} 

#ifdef USE_TOR_DNS
    /* Show tordns configuration options */
    printf("=== TorDNS Configuration Options ===\n");
    printf("Tor DNS enabled:        %s\n", 
           config->tordns_enabled ? "yes" : "no");
    printf("Tor DNS deadpool range: %s/", 
           inet_ntoa(config->tordns_deadpool_range->localip));
    printf("%s\n", 
        inet_ntoa(config->tordns_deadpool_range->localnet));
    printf("Tor DNS cache size:     %d\n", config->tordns_cache_size);
    printf("\n");
#endif

    return;
}
Exemplo n.º 3
0
void show_conf(struct parsedfile *config) {
	struct netent *net;
	struct serverent *server;
	char buf[60];

	/* Show the local networks */
	printf("=== Local networks (no socks server needed) ===\n");
	net = (config->localnets);
	while (net != NULL) {
		inet_ntop(net->af, net->localip, buf, 60);
		printf("Network: %40s   ", buf);
		printf("Prefixlen: %5d\n", net->localnet);
		net = net->next;
	}
	printf("\n");

	/* If we have a default server configuration show it */
	printf("=== Default Server Configuration ===\n");
	if ((config->defaultserver).address != NULL) {
		show_server(config, &(config->defaultserver), 1);
	} else {
		printf("No default server specified, this is rarely a "
				 "good idea\n");
	}
	printf("\n");

	/* Now show paths */
	if ((config->paths) != NULL) {
		server = (config->paths);
		while (server != NULL) {
			printf("=== Path (line no %d in configuration file)"
					 " ===\n", server->lineno);
			show_server(config, server, 0);
			printf("\n");
			server = server->next;
		}	
	}

	return;
}
Exemplo n.º 4
0
void test_host(struct parsedfile *config, char *host) { 
	struct in_addr hostaddr;
	struct serverent *path;
   char *hostname, *port;
   char separator;
   unsigned long portno = 0;

   /* See if a port has been specified */
   hostname = strsplit(&separator, &host, ": \t\n");
   if (separator == ':') {
      port = strsplit(NULL, &host, " \t\n");
      if (port) 
         portno = strtol(port, NULL, 0);
   }

	/* First resolve the host to an ip */
	if ((hostaddr.s_addr = resolve_ip(hostname, 0, 1)) == 0) {
		fprintf(stderr, "Error: Cannot resolve %s\n", host);
		return;
	} else {
		printf("Finding path for %s...\n", inet_ntoa(hostaddr));
      if (!(is_local(config, &(hostaddr)))) {
         printf("Path is local\n");
      } else {
         pick_server(config, &path, &hostaddr, portno);
         if (path == &(config->defaultserver)) {
            printf("Path is via default server:\n");
            show_server(config, path, 1);
         } else {
            printf("Host is reached via this path:\n");
            show_server(config, path, 0);
         }
      }
	}

	return;
}