]> git.meshlink.io Git - meshlink/blobdiff - src/net_socket.c
Remove unused logging functionality.
[meshlink] / src / net_socket.c
index ecf2c26ba9a9c8c544458d31f71795bf5bfa4f56..fbafc22bb86cd34dcc9b2e298fc84a7a4cbdfb50 100644 (file)
@@ -41,9 +41,6 @@ int maxtimeout = 900;
 int seconds_till_retry = 5;
 int max_connection_burst = 100;
 
-listen_socket_t listen_socket[MAXSOCKETS];
-int listen_sockets;
-
 /* Setup sockets */
 
 static void configure_tcp(connection_t *c) {
@@ -77,8 +74,8 @@ static void configure_tcp(connection_t *c) {
 static bool bind_to_address(connection_t *c) {
        int s = -1;
 
-       for(int i = 0; i < listen_sockets && listen_socket[i].bindto; i++) {
-               if(listen_socket[i].sa.sa.sa_family != c->address.sa.sa_family)
+       for(int i = 0; i < mesh->listen_sockets && mesh->listen_socket[i].bindto; i++) {
+               if(mesh->listen_socket[i].sa.sa.sa_family != c->address.sa.sa_family)
                        continue;
                if(s >= 0)
                        return false;
@@ -88,7 +85,7 @@ static bool bind_to_address(connection_t *c) {
        if(s < 0)
                return false;
 
-       sockaddr_t sa = listen_socket[s].sa;
+       sockaddr_t sa = mesh->listen_socket[s].sa;
        if(sa.sa.sa_family == AF_INET)
                sa.in.sin_port = 0;
        else if(sa.sa.sa_family == AF_INET6)
@@ -405,18 +402,18 @@ begin:
 
        logger(DEBUG_CONNECTIONS, LOG_INFO, "Trying to connect to %s (%s)", outgoing->name, c->hostname);
 
-       if(!proxytype) {
+       if(!mesh->proxytype) {
                c->socket = socket(c->address.sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
                configure_tcp(c);
-       } else if(proxytype == PROXY_EXEC) {
-               do_outgoing_pipe(c, proxyhost);
+       } else if(mesh->proxytype == PROXY_EXEC) {
+               do_outgoing_pipe(c, mesh->proxyhost);
        } else {
-               proxyai = str2addrinfo(proxyhost, proxyport, SOCK_STREAM);
+               proxyai = str2addrinfo(mesh->proxyhost, mesh->proxyport, SOCK_STREAM);
                if(!proxyai) {
                        free_connection(c);
                        goto begin;
                }
-               logger(DEBUG_CONNECTIONS, LOG_INFO, "Using proxy at %s port %s", proxyhost, proxyport);
+               logger(DEBUG_CONNECTIONS, LOG_INFO, "Using proxy at %s port %s", mesh->proxyhost, mesh->proxyport);
                c->socket = socket(proxyai->ai_family, SOCK_STREAM, IPPROTO_TCP);
                configure_tcp(c);
        }
@@ -431,7 +428,7 @@ begin:
        fcntl(c->socket, F_SETFD, FD_CLOEXEC);
 #endif
 
-       if(proxytype != PROXY_EXEC) {
+       if(mesh->proxytype != PROXY_EXEC) {
 #if defined(SOL_IPV6) && defined(IPV6_V6ONLY)
                int option = 1;
                if(c->address.sa.sa_family == AF_INET6)
@@ -443,9 +440,9 @@ begin:
 
        /* Connect */
 
-       if(!proxytype) {
+       if(!mesh->proxytype) {
                result = connect(c->socket, &c->address.sa, SALEN(c->address.sa));
-       } else if(proxytype == PROXY_EXEC) {
+       } else if(mesh->proxytype == PROXY_EXEC) {
                result = 0;
        } else {
                result = connect(c->socket, proxyai->ai_addr, proxyai->ai_addrlen);
@@ -654,7 +651,7 @@ void try_outgoing_connections(void) {
        /* Make sure there is one outgoing_t in the list for each ConnectTo. */
 
        // TODO: Drop support for ConnectTo since AutoConnect is now always on?
-       for(config_t *cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) {
+       for(config_t *cfg = lookup_config(mesh->config, "ConnectTo"); cfg; cfg = lookup_config_next(mesh->config, cfg)) {
                char *name;
                get_config_string(cfg, &name);