From c80f0cd504fb60962224e1a12b8f3c99bacfce70 Mon Sep 17 00:00:00 2001 From: MurphyMarkW Date: Mon, 23 Mar 2015 12:14:02 -0500 Subject: [PATCH 1/2] Removed IPv6 support for now. Need to have user specify IP protocol version. Right now it causes problems w/ UDT when attempting to determine the version on the fly. --- src/nydus/nydus.c | 2 +- src/nydus/tcp.c | 10 +++++++--- src/nydus/udt.c | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/nydus/nydus.c b/src/nydus/nydus.c index 30508e3..dbaeb69 100644 --- a/src/nydus/nydus.c +++ b/src/nydus/nydus.c @@ -13,7 +13,7 @@ volatile const char * udt_source_port = "9000"; volatile const char * tcp_target_host = "localhost"; volatile const char * tcp_target_port = "9090"; -volatile const char * udt_target_host = "0.0.0.0"; +volatile const char * udt_target_host = "localhost"; volatile const char * udt_target_port = "9090"; diff --git a/src/nydus/tcp.c b/src/nydus/tcp.c index 446c8df..574f089 100644 --- a/src/nydus/tcp.c +++ b/src/nydus/tcp.c @@ -27,7 +27,7 @@ static void * tcp_handler(void * canal) { // Look up the destination information. memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6 + hints.ai_family = AF_INET; // Allow IPv4 (IPv6 soon) hints.ai_socktype = SOCK_STREAM; // Request TCP socket hints.ai_flags = AI_PASSIVE; // Whatever interface for now. hints.ai_protocol = 0; @@ -60,7 +60,7 @@ static void * tcp_handler(void * canal) { // Connect to the other side. if(udt.connect(sock, curr->ai_addr, curr->ai_addrlen)) { syslog(LOG_WARNING, fmt("Failed to connect to target server.")); - syslog(LOG_WARNING, fmt("UDT SOCKET ERROR GOES HERE")); + syslog(LOG_WARNING, fmt("UDT error code: %u"), udt.getlasterror_code()); close(sock); continue; } @@ -72,6 +72,8 @@ static void * tcp_handler(void * canal) { syslog(LOG_ERR, fmt("Could not build a socket.")); goto cleanup; } + + syslog(LOG_INFO, fmt("UDT connection established.")); // Create a new canal data structure. struct canal * target = (struct canal *)malloc(sizeof(struct canal)); @@ -90,8 +92,10 @@ static void * tcp_handler(void * canal) { freeaddrinfo(info); // NOTE this doesn't set NULL and not idempotent info = NULL; + syslog(LOG_INFO, fmt("Closing UDT connection.")); udt.close(sock); + syslog(LOG_INFO, fmt("Closing TCP connection.")); close(((struct canal *)canal)->source_sock); free(canal); @@ -159,7 +163,7 @@ void * tcp_proxy(void * canal) { // Look up the server information. memset(&hint, 0, sizeof(struct addrinfo)); - hint.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6 + hint.ai_family = AF_INET; // Allow IPv4 (IPv6 soon) hint.ai_socktype = SOCK_STREAM; // Request TCP socket hint.ai_flags = AI_PASSIVE; // Whatever interface for now. hint.ai_protocol = 0; diff --git a/src/nydus/udt.c b/src/nydus/udt.c index 443c1df..9ec38ae 100644 --- a/src/nydus/udt.c +++ b/src/nydus/udt.c @@ -27,7 +27,7 @@ static void * udt_handler(void * canal) { // Look up the destination information. memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6 + hints.ai_family = AF_INET; // Allow IPv4 (IPv6 soon) hints.ai_socktype = SOCK_STREAM; // Request TCP socket hints.ai_flags = AI_PASSIVE; // Whatever interface for now. hints.ai_protocol = 0; @@ -72,6 +72,8 @@ static void * udt_handler(void * canal) { syslog(LOG_ERR, fmt("Could not build a socket.")); goto cleanup; } + + syslog(LOG_INFO, fmt("TCP connection established.")); // Create a new canal data structure. struct canal * target = (struct canal *)malloc(sizeof(struct canal)); @@ -90,8 +92,10 @@ static void * udt_handler(void * canal) { freeaddrinfo(info); // NOTE this doesn't set NULL and not idempotent info = NULL; + syslog(LOG_INFO, fmt("Closing TCP connection.")); close(sock); + syslog(LOG_INFO, fmt("Closing UDT connection.")); udt.close(((struct canal *)canal)->source_sock); free(canal); @@ -159,7 +163,7 @@ void * udt_proxy (void * canal) { // Look up the server information. memset(&hint, 0, sizeof(struct addrinfo)); - hint.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6 + hint.ai_family = AF_UNSPEC; // Allow IPv4 (IPv6 soon) hint.ai_socktype = SOCK_STREAM; // Request UDT socket hint.ai_flags = AI_PASSIVE; // Whatever interface for now. hint.ai_protocol = 0; From 014d0f44ee70e73f01fc0088e056454fe10e754b Mon Sep 17 00:00:00 2001 From: MurphyMarkW Date: Mon, 23 Mar 2015 12:16:25 -0500 Subject: [PATCH 2/2] Missed an AF_UNSPEC in last commit. --- src/nydus/udt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nydus/udt.c b/src/nydus/udt.c index 9ec38ae..19f21ba 100644 --- a/src/nydus/udt.c +++ b/src/nydus/udt.c @@ -163,7 +163,7 @@ void * udt_proxy (void * canal) { // Look up the server information. memset(&hint, 0, sizeof(struct addrinfo)); - hint.ai_family = AF_UNSPEC; // Allow IPv4 (IPv6 soon) + hint.ai_family = AF_INET; // Allow IPv4 (IPv6 soon) hint.ai_socktype = SOCK_STREAM; // Request UDT socket hint.ai_flags = AI_PASSIVE; // Whatever interface for now. hint.ai_protocol = 0;