summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--libs/nixio/Makefile9
-rw-r--r--libs/nixio/lua/nixio/util.lua38
-rw-r--r--libs/nixio/src/nixio.c3
-rw-r--r--libs/nixio/src/nixio.h3
4 files changed, 34 insertions, 19 deletions
diff --git a/libs/nixio/Makefile b/libs/nixio/Makefile
index c65822f08..2a7552daf 100644
--- a/libs/nixio/Makefile
+++ b/libs/nixio/Makefile
@@ -22,7 +22,7 @@ endif
NIXIO_OBJ = src/nixio.o src/socket.o src/sockopt.o src/bind.o src/address.o \
src/poll.o src/io.o src/file.o src/splice.o src/process.o src/syslog.o \
src/bit.o src/binary.o src/fs.o src/user.o \
- src/tls-crypto.o src/tls-context.o src/tls-socket.o
+ $(if $(NIXIO_TLS),src/tls-crypto.o src/tls-context.o src/tls-socket.o,)
ifeq ($(NIXIO_TLS),axtls)
TLS_CFLAGS = -IaxTLS/ssl -IaxTLS/crypto -IaxTLS/config -include src/axtls-compat.h
@@ -41,6 +41,10 @@ ifeq ($(NIXIO_TLS),cyassl)
NIXIO_OBJ += src/cyassl-compat.o
endif
+ifeq ($(NIXIO_TLS),)
+ NIXIO_CFLAGS += -DNO_TLS
+endif
+
ifeq ($(OS),SunOS)
NIXIO_LDFLAGS += -lsocket -lnsl -lsendfile
@@ -64,6 +68,7 @@ endif
%.o: %.c
$(COMPILE) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) -c -o $@ $<
+ifneq ($(NIXIO_TLS),)
src/tls-crypto.o: $(TLS_DEPENDS) src/tls-crypto.c
$(COMPILE) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) $(TLS_CFLAGS) -c -o $@ src/tls-crypto.c
@@ -77,7 +82,7 @@ src/axtls-compat.o: src/libaxtls.a src/axtls-compat.c
$(COMPILE) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) $(TLS_CFLAGS) -c -o $@ src/axtls-compat.c
mkdir -p dist
cp -pR axtls-root/* dist/
-
+endif
compile: $(NIXIO_OBJ)
$(LINK) $(SHLIB_FLAGS) $(NIXIO_LDFLAGS) -o src/$(NIXIO_SO) $(NIXIO_OBJ) $(NIXIO_LDFLAGS_POST)
diff --git a/libs/nixio/lua/nixio/util.lua b/libs/nixio/lua/nixio/util.lua
index 409004882..63d2f6214 100644
--- a/libs/nixio/lua/nixio/util.lua
+++ b/libs/nixio/lua/nixio/util.lua
@@ -237,30 +237,34 @@ function meta.copyz(self, fd, size)
return self:copy(fd, size)
end
-function tls_socket.close(self)
- return self.socket:close()
-end
+if tls_socket then
+ function tls_socket.close(self)
+ return self.socket:close()
+ end
-function tls_socket.getsockname(self)
- return self.socket:getsockname()
-end
+ function tls_socket.getsockname(self)
+ return self.socket:getsockname()
+ end
-function tls_socket.getpeername(self)
- return self.socket:getpeername()
-end
+ function tls_socket.getpeername(self)
+ return self.socket:getpeername()
+ end
-function tls_socket.getsockopt(self, ...)
- return self.socket:getsockopt(...)
-end
-tls_socket.getopt = tls_socket.getsockopt
+ function tls_socket.getsockopt(self, ...)
+ return self.socket:getsockopt(...)
+ end
+ tls_socket.getopt = tls_socket.getsockopt
-function tls_socket.setsockopt(self, ...)
- return self.socket:setsockopt(...)
+ function tls_socket.setsockopt(self, ...)
+ return self.socket:setsockopt(...)
+ end
+ tls_socket.setopt = tls_socket.setsockopt
end
-tls_socket.setopt = tls_socket.setsockopt
for k, v in pairs(meta) do
file[k] = v
socket[k] = v
- tls_socket[k] = v
+ if tls_socket then
+ tls_socket[k] = v
+ end
end
diff --git a/libs/nixio/src/nixio.c b/libs/nixio/src/nixio.c
index 3086b978b..f6e8e184c 100644
--- a/libs/nixio/src/nixio.c
+++ b/libs/nixio/src/nixio.c
@@ -142,9 +142,12 @@ NIXIO_API int luaopen_nixio(lua_State *L) {
nixio_open_bin(L);
nixio_open_fs(L);
nixio_open_user(L);
+
+#ifndef NO_TLS
nixio_open_tls_crypto(L);
nixio_open_tls_context(L);
nixio_open_tls_socket(L);
+#endif
/* module version */
lua_pushinteger(L, VERSION);
diff --git a/libs/nixio/src/nixio.h b/libs/nixio/src/nixio.h
index ff75cfd98..2be197f13 100644
--- a/libs/nixio/src/nixio.h
+++ b/libs/nixio/src/nixio.h
@@ -120,9 +120,12 @@ void nixio_open_bit(lua_State *L);
void nixio_open_bin(lua_State *L);
void nixio_open_fs(lua_State *L);
void nixio_open_user(lua_State *L);
+
+#ifndef NO_TLS
void nixio_open_tls_crypto(lua_State *L);
void nixio_open_tls_context(lua_State *L);
void nixio_open_tls_socket(lua_State *L);
+#endif
/* Method functions */