diff --git a/make-linux.mk b/make-linux.mk index c0b28c4d5..5ea0049ce 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -105,10 +105,10 @@ netcon: $(OBJS) ln -sf zerotier-netcon-service zerotier-cli ln -sf zerotier-netcon-service zerotier-idtool -#install-intercept: -# cp libzerotierintercept.so /lib/libzerotierintercept.so -# ln -sf /lib/libzerotierintercept.so /lib/libzerotierintercept -# /usr/bin/install -c netcon/zerotier-intercept /usr/bin +install-intercept: + cp libzerotierintercept.so /lib/libzerotierintercept.so + ln -sf /lib/libzerotierintercept.so /lib/libzerotierintercept + /usr/bin/install -c netcon/zerotier-intercept /usr/bin #uninstall-intercept: # rm -r /lib/libzerotierintercept.so diff --git a/netcon/Intercept.c b/netcon/Intercept.c index 2830c3ac8..ad48b7d4b 100644 --- a/netcon/Intercept.c +++ b/netcon/Intercept.c @@ -138,7 +138,7 @@ static void checkpid() return; if (thispid != getpid()) { - printf("clone/fork detected. re-initializing this instance.\n"); + dwr(MSG_DEBUG, "checkpid(): clone/fork detected. Re-initializing this instance.\n"); set_up_intercept(); fdret_sock = init_service_connection(); thispid = getpid(); @@ -216,12 +216,11 @@ static int send_cmd(int rpc_fd, char *cmd) #endif /* Combine command flag+payload with RPC metadata */ memcpy(&metabuf[IDX_PAYLOAD], cmd, PAYLOAD_SZ); - usleep(1000); + usleep(100000); int n_write = write(rpc_fd, &metabuf, BUF_SZ); if(n_write < 0){ dwr(MSG_DEBUG,"Error writing command to service (CMD = %d)\n", cmd[0]); errno = 0; - return -1; } int ret = ERR_OK; diff --git a/netcon/NetconEthernetTap.cpp b/netcon/NetconEthernetTap.cpp index 609e29230..cb5def326 100644 --- a/netcon/NetconEthernetTap.cpp +++ b/netcon/NetconEthernetTap.cpp @@ -848,6 +848,8 @@ err_t NetconEthernetTap::nc_accept(void *arg, struct tcp_pcb *newpcb, err_t err) dwr(MSG_DEBUG, " nc_accept(): socketpair = {%d, %d}\n", fds[0], fds[1]); int send_fd = tap->_phy.getDescriptor(conn->rpcSock); +dwr(MSG_DEBUG, "nc_accept(): sending %d via %d\n", fds[1], listening_fd); + if(sock_fd_write(listening_fd, fds[1]) < 0){ dwr(MSG_ERROR, " nc_accept(%d): error writing signal byte (listen_fd = %d, perceived_fd = %d)\n", listening_fd, send_fd, fds[1]); return -1; diff --git a/netcon/common.inc.c b/netcon/common.inc.c index 0523f1049..71761b209 100644 --- a/netcon/common.inc.c +++ b/netcon/common.inc.c @@ -39,9 +39,9 @@ #include -#define DEBUG_LEVEL 0 +#define DEBUG_LEVEL 4 -#define MSG_WARNING 0 +#define MSG_WARNING 4 #define MSG_ERROR 1 // Errors #define MSG_INFO 2 // Information which is generally useful to any user #define MSG_DEBUG 3 // Information which is only useful to someone debugging @@ -171,7 +171,7 @@ static ssize_t sock_fd_read(int sock, void *buf, ssize_t bufsize, int *fd) msg.msg_controllen = sizeof(cmsgu.control); size = recvmsg (sock, &msg, 0); if (size < 0) { - perror ("recvmsg"); + dwr(MSG_DEBUG, "sock_fd_read(): recvmsg: Error\n"); return -1; } cmsg = CMSG_FIRSTHDR(&msg); @@ -190,7 +190,7 @@ static ssize_t sock_fd_read(int sock, void *buf, ssize_t bufsize, int *fd) } else { size = read (sock, buf, bufsize); if (size < 0) { - perror("read"); + dwr(MSG_DEBUG, "sock_fd_read(): read: Error\n"); return -1; } }