yaoweibin / nginx_tcp_proxy_module

add the feature of tcp proxy with nginx, with health check and status monitor
http://yaoweibin.github.com/nginx_tcp_proxy_module
1.64k stars 365 forks source link

make build error with nginx 1.14.2 #167

Open mingzhj opened 5 years ago

mingzhj commented 5 years ago

nginx_tcp_proxy_module

版本号:./configure --add-module=nginx_tcp_proxy_module-master --with-pcre=pcre-8.42 --with-openssl=openssl-1.0.2q --with-zlib=zlib-1.2.11 --with-poll_module --prefix=/opt/bohui/nginx-1.14.2/run

nginx_tcp_proxy_module-master/ngx_tcp_core_module.c

nginx_tcp_proxy_module-master/ngx_tcp_core_module.c: In function ‘ngx_tcp_core_listen’: nginx_tcp_proxy_module-master/ngx_tcp_core_module.c:487:9: error: cannot convert to a pointer type if (ngx_memcmp(ls[i].sockaddr + off, u.sockaddr + off, len) != 0) { ^ nginx_tcp_proxy_module-master/ngx_tcp_core_module.c:507:5: error: incompatible type for argument 2 of ‘memcpy’ ngx_memcpy(ls->sockaddr, u.sockaddr, u.socklen); ^ In file included from src/os/unix/ngx_linux_config.h:27:0, from src/core/ngx_config.h:26, from nginx_tcp_proxy_module-master/ngx_tcp_core_module.c:2: /usr/include/string.h:42:14: note: expected ‘const void restrict’ but argument is of type ‘ngx_sockaddr_t’ extern void memcpy (void restrict dest, const void restrict src, ^ make[1]: *** [objs/addon/nginx_tcp_proxy_module-master/ngx_tcp_core_module.o] Error 1 make[1]: Leaving directory `/opt/bohui/nginx-1.14.2'

lev-gc commented 5 years ago

Read the README. You should execute this command first:

patch -p1 < /path/to/nginx_tcp_proxy_module/tcp.patch
dsugisawa-mixi commented 5 years ago

have a try, use the command

cd ../nginx_tcp_proxy_module
patch -p1 < my.patch 
cd nginx-1.14.2
patch -p1 < /path/to/nginx_tcp_proxy_module/tcp_1_8.patch

my.patch

diff --git a/ngx_tcp_core_module.c b/ngx_tcp_core_module.c
index 9e3110d..f1388ba 100644
--- a/ngx_tcp_core_module.c
+++ b/ngx_tcp_core_module.c
@@ -5,6 +5,9 @@
 #include <ngx_tcp.h>
 #include <nginx.h>

+#ifndef NGX_CONF_MULTI
+#define NGX_CONF_MULTI 0
+#endif

 static void *ngx_tcp_core_create_main_conf(ngx_conf_t *cf);
 static void *ngx_tcp_core_create_srv_conf(ngx_conf_t *cf);
@@ -481,7 +484,7 @@ ngx_tcp_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
                 break;
         }

-        if (ngx_memcmp(ls[i].sockaddr + off, u.sockaddr + off, len) != 0) {
+        if (ngx_memcmp(ls[i].sockaddr + off, ((char*)&u.sockaddr) + off, len) != 0) {
             continue;
         }

@@ -501,7 +504,7 @@ ngx_tcp_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)

     ngx_memzero(ls, sizeof(ngx_tcp_listen_t));

-    ngx_memcpy(ls->sockaddr, u.sockaddr, u.socklen);
+    ngx_memcpy(ls->sockaddr, &u.sockaddr, u.socklen);

     ls->socklen = u.socklen;
     ls->wildcard = u.wildcard;
yaoweibin commented 5 years ago

Try the latest branch, thanks @dsugisawa-mixi