Compare commits

...

4 Commits

Author SHA1 Message Date
Vladimir Dubrovin
cbab76fe41 do not use static linking for .so
Some checks failed
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Has been cancelled
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Has been cancelled
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Has been cancelled
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Has been cancelled
2026-05-05 18:38:45 +03:00
Vladimir Dubrovin
fb9337c030 Add option for static libraries linking (ssl / pcre2 / pam) 2026-05-05 18:34:58 +03:00
Vladimir Dubrovin
ef9386e29d More accurate flags in linking 2026-05-05 18:13:32 +03:00
Vladimir Dubrovin
334de0658c update datatypes 2026-05-05 15:27:55 +03:00
8 changed files with 388 additions and 169 deletions

View File

@ -46,8 +46,8 @@ endif()
# Options # Options
option(3PROXY_BUILD_SHARED "Build shared libraries for plugins" ON) option(3PROXY_BUILD_SHARED "Build shared libraries for plugins" ON)
option(3PROXY_USE_OPENSSL "Enable OpenSSL/SSLPlugin" ON) option(3PROXY_USE_OPENSSL "Enable TLS/SSL support (requires OpenSSL)" ON)
option(3PROXY_USE_PCRE2 "Enable PCRE2/PCREPlugin" ON) option(3PROXY_USE_PCRE2 "Enable PCRE2 regex filtering" ON)
option(3PROXY_USE_PAM "Enable PAM/PamAuth" ON) option(3PROXY_USE_PAM "Enable PAM/PamAuth" ON)
option(3PROXY_USE_ODBC "Enable ODBC support (Unix only, always ON on Windows)" OFF) option(3PROXY_USE_ODBC "Enable ODBC support (Unix only, always ON on Windows)" OFF)
option(3PROXY_USE_SPLICE "Use Linux splice() for zero-copy (Linux only)" ON) option(3PROXY_USE_SPLICE "Use Linux splice() for zero-copy (Linux only)" ON)
@ -56,6 +56,10 @@ option(3PROXY_USE_WSAPOLL "Use WSAPoll instead of select() (Windows only)" ON)
option(3PROXY_USE_NETFILTER "Enable Linux netfilter support (Linux only)" ON) option(3PROXY_USE_NETFILTER "Enable Linux netfilter support (Linux only)" ON)
option(3PROXY_USE_UNIX_SOCKETS "Enable Unix domain socket support (Unix only)" ON) option(3PROXY_USE_UNIX_SOCKETS "Enable Unix domain socket support (Unix only)" ON)
if(NOT WIN32 AND NOT APPLE)
option(3PROXY_STATIC_LINK "Statically link libraries using -Wl,-Bstatic (Linux/Unix only)" OFF)
endif()
# Binary name prefix for standalone modules and crypt (default: 3proxy_) # Binary name prefix for standalone modules and crypt (default: 3proxy_)
# For crypt: if prefix is empty, "my" is used instead ( mycrypt) # For crypt: if prefix is empty, "my" is used instead ( mycrypt)
set(3PROXY_BINARY_PREFIX "3proxy_" CACHE STRING "Prefix for standalone module and crypt binary names") set(3PROXY_BINARY_PREFIX "3proxy_" CACHE STRING "Prefix for standalone module and crypt binary names")
@ -441,38 +445,19 @@ if(ODBC_FOUND)
endif() endif()
endif() endif()
# OpenSSL linking
if(OpenSSL_FOUND) if(OpenSSL_FOUND)
target_link_libraries(3proxy PRIVATE OpenSSL::SSL OpenSSL::Crypto) if(3PROXY_STATIC_LINK)
# Will be linked statically below (if static libraries are found)
else()
target_link_libraries(3proxy PRIVATE OpenSSL::SSL OpenSSL::Crypto)
endif()
endif() endif()
# PCRE2 linking (try static first on Linux/FreeBSD, fallback to dynamic) # PCRE2 linking
if(PCRE2_FOUND) if(PCRE2_FOUND)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR if(3PROXY_STATIC_LINK)
CMAKE_SYSTEM_NAME MATCHES "FreeBSD|OpenBSD|NetBSD" OR # Will be linked statically below (if static libraries are found)
CMAKE_SYSTEM_NAME STREQUAL "Unix")
# Try static linking for Linux/BSD
find_library(PCRE2_STATIC_LIB
NAMES pcre2-8-static libpcre2-8.a pcre2-8.a
PATHS ${PC_PCRE2_LIBRARY_DIRS}
/usr/lib/x86_64-linux-gnu
/usr/lib
/usr/local/lib
/lib
)
if(PCRE2_STATIC_LIB AND PCRE2_STATIC_LIB MATCHES "\\.a$")
target_link_libraries(3proxy PRIVATE
-Wl,-Bstatic
${PCRE2_STATIC_LIB}
-Wl,-Bdynamic
)
message(STATUS "Using static PCRE2: ${PCRE2_STATIC_LIB}")
elseif(TARGET PCRE2::PCRE2)
target_link_libraries(3proxy PRIVATE PCRE2::PCRE2)
message(STATUS "Using dynamic PCRE2 (PCRE2::PCRE2)")
else()
target_link_libraries(3proxy PRIVATE ${PCRE2_LIBRARIES})
message(STATUS "Using dynamic PCRE2: ${PCRE2_LIBRARIES}")
endif()
elseif(TARGET PCRE2::PCRE2) elseif(TARGET PCRE2::PCRE2)
target_link_libraries(3proxy PRIVATE PCRE2::PCRE2) target_link_libraries(3proxy PRIVATE PCRE2::PCRE2)
else() else()
@ -480,6 +465,48 @@ if(PCRE2_FOUND)
endif() endif()
endif() endif()
# Static linking of OpenSSL and PCRE2 (when option is enabled)
if(3PROXY_STATIC_LINK AND (OpenSSL_FOUND OR PCRE2_FOUND))
set(_saved_cmake_find_library_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(_static_libs "")
if(OpenSSL_FOUND)
find_library(_ssl_static_lib ssl)
find_library(_crypto_static_lib crypto)
if(_ssl_static_lib AND _crypto_static_lib)
list(APPEND _static_libs ${_ssl_static_lib} ${_crypto_static_lib})
endif()
endif()
if(PCRE2_FOUND)
find_library(_pcre2_static_lib NAMES pcre2-8)
if(_pcre2_static_lib)
list(APPEND _static_libs ${_pcre2_static_lib})
endif()
endif()
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_saved_cmake_find_library_suffixes})
if(_static_libs)
target_link_libraries(3proxy PRIVATE -Wl,-Bstatic ${_static_libs} -Wl,-Bdynamic)
message(STATUS "Static linking enabled for OpenSSL/PCRE2")
else()
message(WARNING "3PROXY_STATIC_LINK is ON but static libraries not found, falling back to dynamic")
if(OpenSSL_FOUND)
target_link_libraries(3proxy PRIVATE OpenSSL::SSL OpenSSL::Crypto)
endif()
if(PCRE2_FOUND)
if(TARGET PCRE2::PCRE2)
target_link_libraries(3proxy PRIVATE PCRE2::PCRE2)
else()
target_link_libraries(3proxy PRIVATE ${PCRE2_LIBRARIES})
endif()
endif()
endif()
endif()
if(WIN32) if(WIN32)
target_link_libraries(3proxy PRIVATE ${WINDOWS_LIBS}) target_link_libraries(3proxy PRIVATE ${WINDOWS_LIBS})
if(COMPILER_IS_MSVC AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3proxy.rc) if(COMPILER_IS_MSVC AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3proxy.rc)
@ -505,7 +532,22 @@ if(OpenSSL_FOUND)
endif() endif()
target_link_libraries(3proxy_crypt PRIVATE Threads::Threads) target_link_libraries(3proxy_crypt PRIVATE Threads::Threads)
if(OpenSSL_FOUND) if(OpenSSL_FOUND)
target_link_libraries(3proxy_crypt PRIVATE OpenSSL::SSL OpenSSL::Crypto) if(3PROXY_STATIC_LINK)
set(_saved_cmake_find_library_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
find_library(_ssl_static_lib ssl)
find_library(_crypto_static_lib crypto)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_saved_cmake_find_library_suffixes})
if(_ssl_static_lib AND _crypto_static_lib)
target_link_libraries(3proxy_crypt PRIVATE -Wl,-Bstatic ${_ssl_static_lib} ${_crypto_static_lib} -Wl,-Bdynamic)
message(STATUS "3proxy_crypt: static OpenSSL")
else()
message(WARNING "3PROXY_STATIC_LINK is ON but static OpenSSL not found, using dynamic")
target_link_libraries(3proxy_crypt PRIVATE OpenSSL::SSL OpenSSL::Crypto)
endif()
else()
target_link_libraries(3proxy_crypt PRIVATE OpenSSL::SSL OpenSSL::Crypto)
endif()
endif() endif()
if("${3PROXY_BINARY_PREFIX}" STREQUAL "") if("${3PROXY_BINARY_PREFIX}" STREQUAL "")
set_target_properties(3proxy_crypt PROPERTIES OUTPUT_NAME "mycrypt") set_target_properties(3proxy_crypt PROPERTIES OUTPUT_NAME "mycrypt")
@ -798,6 +840,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS " USE_SPLICE: ${3PROXY_USE_SPLICE}") message(STATUS " USE_SPLICE: ${3PROXY_USE_SPLICE}")
message(STATUS " USE_NETFILTER: ${3PROXY_USE_NETFILTER}") message(STATUS " USE_NETFILTER: ${3PROXY_USE_NETFILTER}")
endif() endif()
if(NOT WIN32 AND NOT APPLE)
message(STATUS " STATIC_LINK: ${3PROXY_STATIC_LINK}")
endif()
if(WIN32) if(WIN32)
message(STATUS " USE_WSAPOLL: ${3PROXY_USE_WSAPOLL}") message(STATUS " USE_WSAPOLL: ${3PROXY_USE_WSAPOLL}")
endif() endif()

View File

@ -10,10 +10,12 @@ CRYPT_PREFIX ?= $(PREFIX)
MANDIR ?= /usr/share/man MANDIR ?= /usr/share/man
CC ?= cc CC ?= cc
CFLAGS := -c -O3 -fno-strict-aliasing -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_UN $(CFLAGS) CFLAGS ?= -O3 -flto
CFLAGS += -c -fno-strict-aliasing -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_UN
COUT = -o COUT = -o
LN ?= ${CC} LN ?= ${CC}
LDFLAGS += -g -flto -pthread -fno-strict-aliasing LDFLAGS ?= -flto
LDFLAGS += -pthread -fno-strict-aliasing
# -lpthreads may be reuiured on some platforms instead of -pthreads # -lpthreads may be reuiured on some platforms instead of -pthreads
# -ldl or -lld may be required for some platforms # -ldl or -lld may be required for some platforms
DCFLAGS ?= -fPIC DCFLAGS ?= -fPIC

View File

@ -9,11 +9,13 @@ PREFIX ?= 3proxy_
CRYPT_PREFIX ?= $(PREFIX) CRYPT_PREFIX ?= $(PREFIX)
CC ?= gcc CC ?= gcc
CFLAGS := -g -fPIC -O3 -fno-strict-aliasing -c -pthread -DWITHSPLICE -D_GNU_SOURCE -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER -D WITH_UN $(CFLAGS) CFLAGS ?= -O3 -flto
CFLAGS += -fPIC -fno-strict-aliasing -c -pthread -DWITHSPLICE -D_GNU_SOURCE -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER -D WITH_UN
COUT = -o COUT = -o
LN ?= ${CC} LN ?= ${CC}
DCFLAGS ?= DCFLAGS ?=
LDFLAGS := -fPIC -O3 -fno-strict-aliasing -pthread $(LDFLAGS) LDFLAGS ?= -flto
LDFLAGS += -fPIC -O3 -fno-strict-aliasing -pthread
DLFLAGS ?= -shared DLFLAGS ?= -shared
DLSUFFICS = .ld.so DLSUFFICS = .ld.so
# -lpthreads may be reuqired on some platforms instead of -pthreads # -lpthreads may be reuqired on some platforms instead of -pthreads
@ -37,7 +39,7 @@ LIBS ?= -ldl
PLUGINS ?= StringsPlugin TrafficPlugin TransparentPlugin FilePlugin PLUGINS ?= StringsPlugin TrafficPlugin TransparentPlugin FilePlugin
OPENSSL_CHECK = $(shell echo "\#include <openssl/ssl.h>\\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testssl.o - 2>/dev/null && $(CC) $(LDFLAGS) -otestssl testssl.o -lcrypto -lssl 2>/dev/null && rm testssl testssl.o && echo true||echo false) OPENSSL_CHECK = $(shell echo "\#include <openssl/ssl.h>\\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testssl.o - 2>/dev/null && $(CC) $(LDFLAGS) -otestssl testssl.o -lcrypto -lssl 2>/dev/null && rm testssl testssl.o && echo true||echo false)
ifeq ($(OPENSSL_CHECK), true) ifeq ($(OPENSSL_CHECK), true)
LIBS += -l crypto -l ssl LIBS += -Wl,-Bstatic -l crypto -l ssl -Wl,-Bdynamic
CFLAGS += -DWITH_SSL CFLAGS += -DWITH_SSL
SSL_OBJS = ssllib$(OBJSUFFICS) ssl$(OBJSUFFICS) SSL_OBJS = ssllib$(OBJSUFFICS) ssl$(OBJSUFFICS)
endif endif

View File

@ -12,10 +12,12 @@ MANDIR ?= /usr/share/man
CC ?= gcc CC ?= gcc
# you may need -L/usr/pkg/lib for older NetBSD versions # you may need -L/usr/pkg/lib for older NetBSD versions
CFLAGS := -g -O2 -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_UN $(CFLAGS) CFLAGS ?= -O3 -flto
CFLAGS += -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_UN
COUT = -o COUT = -o
LN ?= $(CC) LN ?= $(CC)
LDFLAGS ?= -O2 -fno-strict-aliasing -pthread LDFLAGS ?= -flto
LDFLAGS += -pthread -fno-strict-aliasing
# -lpthreads may be reuqired on some platforms instead of -pthreads # -lpthreads may be reuqired on some platforms instead of -pthreads
# -ldl or -lld may be required for some platforms # -ldl or -lld may be required for some platforms
DCFLAGS ?= -fPIC DCFLAGS ?= -fPIC

View File

@ -8,13 +8,15 @@
BUILDDIR = ../bin/ BUILDDIR = ../bin/
CC ?= gcc CC ?= gcc
CFLAGS := -O2 -s -c -mthreads -DWITH_WSAPOLL $(CFLAGS) CFLAGS ?= -O3 -flto -fno-strict-aliasing
CFLAGS += -c -mthreads -DWITH_WSAPOLL
COUT = -o COUT = -o
LN ?= $(CC) LN ?= $(CC)
LDFLAGS := -O2 -s -mthreads $(LDFLAGS) LDFLAGS ?= -flto -fno-strict-aliasing
LDFLAGS += -mthreads
DLFLAGS ?= -shared DLFLAGS ?= -shared
DLSUFFICS = .dll DLSUFFICS = .dll
LIBS := -lws2_32 -lodbc32 -ladvapi32 -luser32 $(LIBS) LIBS += -lws2_32 -lodbc32 -ladvapi32 -luser32
LIBSPREFIX = -l LIBSPREFIX = -l
LIBSSUFFIX = LIBSSUFFIX =
LNOUT = -o LNOUT = -o

View File

@ -96,7 +96,7 @@ static void pr_wdays(struct node *node, CBFUNC cbf, void*cb){
static void pr_time(struct node *node, CBFUNC cbf, void*cb){ static void pr_time(struct node *node, CBFUNC cbf, void*cb){
char buf[16]; char buf[16];
int t = *(int *)node; int t = *(int *)node;
(*cbf)(cb, buf, sprintf(buf, "%02d:%02d:%02d", (t/3600)%24, (t/60)%60, t%60)); (*cbf)(cb, buf, sprintf(buf, "%02d:%02d:%02d", (t/3600)%24, (t/60)%60, t%60));
} }
@ -132,6 +132,12 @@ static void pr_string(struct node *node, CBFUNC cbf, void*cb){
else (*cbf)(cb, "(NULL)", 6); else (*cbf)(cb, "(NULL)", 6);
} }
static void pr_password(struct node *node, CBFUNC cbf, void*cb){
if(node->value && *(unsigned char *)node->value){
(*cbf)(cb, "********", 8);
}
}
static void pr_rotation(struct node *node, CBFUNC cbf, void*cb){ static void pr_rotation(struct node *node, CBFUNC cbf, void*cb){
char * lstrings[] = { char * lstrings[] = {
"N", "C", "H", "D", "W", "M", "Y", "N" "N", "C", "H", "D", "W", "M", "Y", "N"
@ -156,7 +162,7 @@ static void pr_operations(struct node *node, CBFUNC cbf, void*cb){
if(operation & HTTP){ if(operation & HTTP){
if((operation & HTTP) == HTTP) if((operation & HTTP) == HTTP)
(*cbf)(cb, buf, sprintf(buf, "HTTP")); (*cbf)(cb, buf, sprintf(buf, "HTTP"));
else else
(*cbf)(cb, buf, sprintf(buf, "%s%s%s%s%s%s%s%s%s", (*cbf)(cb, buf, sprintf(buf, "%s%s%s%s%s%s%s%s%s",
(operation & HTTP_GET)? "HTTP_GET" : "", (operation & HTTP_GET)? "HTTP_GET" : "",
((operation & HTTP_GET) && (operation & (HTTP_PUT|HTTP_POST|HTTP_HEAD|HTTP_OTHER)))? "," : "", ((operation & HTTP_GET) && (operation & (HTTP_PUT|HTTP_POST|HTTP_HEAD|HTTP_OTHER)))? "," : "",
@ -239,6 +245,18 @@ static void pr_userlist(struct node *node, CBFUNC cbf, void*cb){
} }
} }
static void pr_hostname(struct node *node, CBFUNC cbf, void*cb){
struct hostname *hl = (struct hostname *)node->value;
if(!hl) {
(*cbf)(cb, "*", 1);
return;
}
for(; hl; hl = hl->next){
(*cbf)(cb, (char *)hl->name, (int)strlen((char *)hl->name));
if(hl->next)(*cbf)(cb, ",", 1);
}
}
int printiple(char *buf, struct iplist* ipl){ int printiple(char *buf, struct iplist* ipl){
int addrlen = (ipl->family == AF_INET6)?16:4, i; int addrlen = (ipl->family == AF_INET6)?16:4, i;
i = myinet_ntop(ipl->family, &ipl->ip_from, buf, addrlen); i = myinet_ntop(ipl->family, &ipl->ip_from, buf, addrlen);
@ -315,18 +333,32 @@ static void * ef_pwlist_type(struct node * node){
return "NT"; return "NT";
case LM: case LM:
return "LM"; return "LM";
case UN:
return "UN";
default: default:
return "UNKNOWN"; return "UNKNOWN";
} }
} }
static void * ef_hostname_next(struct node * node){
return ((struct hostname *)node->value) -> next;
}
static void * ef_hostname_name(struct node * node){
return ((struct hostname *)node->value) -> name;
}
static void * ef_hostname_matchtype(struct node * node){
return &((struct hostname *)node->value) -> matchtype;
}
static void * ef_chain_next(struct node * node){ static void * ef_chain_next(struct node * node){
return ((struct chain *)node->value) -> next; return ((struct chain *)node->value) -> next;
} }
static void * ef_chain_type(struct node * node){ static void * ef_chain_type(struct node * node){
int i; int i;
for(i=0; redirs[i].name; i++){ for(i=0; redirs[i].name; i++){
if(((struct chain *)node->value) -> type == redirs[i].redir) return redirs[i].name; if(((struct chain *)node->value) -> type == redirs[i].redir) return redirs[i].name;
} }
@ -349,6 +381,18 @@ static void * ef_chain_password(struct node * node){
return ((struct chain *)node->value) -> extpass; return ((struct chain *)node->value) -> extpass;
} }
static void * ef_chain_secure(struct node * node){
return &((struct chain *)node->value) -> secure;
}
static void * ef_chain_exthost(struct node * node){
return ((struct chain *)node->value) -> exthost;
}
static void * ef_chain_cidr(struct node * node){
return &((struct chain *)node->value) -> cidr;
}
static void * ef_ace_next(struct node * node){ static void * ef_ace_next(struct node * node){
return ((struct ace *)node->value) -> next; return ((struct ace *)node->value) -> next;
} }
@ -379,6 +423,9 @@ static void * ef_ace_dst(struct node * node){
return ((struct ace *)node->value) -> dst; return ((struct ace *)node->value) -> dst;
} }
static void * ef_ace_dstnames(struct node * node){
return ((struct ace *)node->value) -> dstnames;
}
static void * ef_ace_ports(struct node * node){ static void * ef_ace_ports(struct node * node){
return ((struct ace *)node->value) -> ports; return ((struct ace *)node->value) -> ports;
@ -396,6 +443,13 @@ static void * ef_ace_period(struct node * node){
return ((struct ace *)node->value) -> periods; return ((struct ace *)node->value) -> periods;
} }
static void * ef_ace_weight(struct node * node){
return &((struct ace *)node->value) -> weight;
}
static void * ef_ace_nolog(struct node * node){
return &((struct ace *)node->value) -> nolog;
}
static void * ef_bandlimit_next(struct node * node){ static void * ef_bandlimit_next(struct node * node){
return ((struct bandlim *)node->value) -> next; return ((struct bandlim *)node->value) -> next;
@ -489,6 +543,14 @@ static void * ef_server_childcount(struct node * node){
return &((struct srvparam *)node->value) -> childcount; return &((struct srvparam *)node->value) -> childcount;
} }
static void * ef_server_maxchild(struct node * node){
return &((struct srvparam *)node->value) -> maxchild;
}
static void * ef_server_backlog(struct node * node){
return &((struct srvparam *)node->value) -> backlog;
}
static void * ef_server_log(struct node * node){ static void * ef_server_log(struct node * node){
if(((struct srvparam *)node->value) -> logfunc == lognone) return "none"; if(((struct srvparam *)node->value) -> logfunc == lognone) return "none";
#ifndef NORADIUS #ifndef NORADIUS
@ -545,6 +607,14 @@ static void * ef_server_extsa6(struct node * node){
} }
#endif #endif
static void * ef_server_intNat(struct node * node){
return &((struct srvparam *)node->value) -> intNat;
}
static void * ef_server_extNat(struct node * node){
return &((struct srvparam *)node->value) -> extNat;
}
static void * ef_server_acl(struct node * node){ static void * ef_server_acl(struct node * node){
return ((struct srvparam *)node->value) -> acl; return ((struct srvparam *)node->value) -> acl;
} }
@ -553,6 +623,54 @@ static void * ef_server_singlepacket(struct node * node){
return &((struct srvparam *)node->value) -> singlepacket; return &((struct srvparam *)node->value) -> singlepacket;
} }
static void * ef_server_needuser(struct node * node){
return &((struct srvparam *)node->value) -> needuser;
}
static void * ef_server_transparent(struct node * node){
return &((struct srvparam *)node->value) -> transparent;
}
static void * ef_server_anonymous(struct node * node){
return &((struct srvparam *)node->value) -> anonymous;
}
static void * ef_server_requirecert(struct node * node){
return &((struct srvparam *)node->value) -> requirecert;
}
static void * ef_server_haproxy(struct node * node){
return &((struct srvparam *)node->value) -> haproxy;
}
static void * ef_server_authcachetype(struct node * node){
return &((struct srvparam *)node->value) -> authcachetype;
}
static void * ef_server_authcachetime(struct node * node){
return &((struct srvparam *)node->value) -> authcachetime;
}
static void * ef_server_gracetraf(struct node * node){
return &((struct srvparam *)node->value) -> gracetraf;
}
static void * ef_server_gracenum(struct node * node){
return &((struct srvparam *)node->value) -> gracenum;
}
static void * ef_server_gracedelay(struct node * node){
return &((struct srvparam *)node->value) -> gracedelay;
}
static void * ef_server_logdumpsrv(struct node * node){
return &((struct srvparam *)node->value) -> logdumpsrv;
}
static void * ef_server_logdumpcli(struct node * node){
return &((struct srvparam *)node->value) -> logdumpcli;
}
static void * ef_server_starttime(struct node * node){ static void * ef_server_starttime(struct node * node){
return &((struct srvparam *)node->value) -> time_start; return &((struct srvparam *)node->value) -> time_start;
} }
@ -570,12 +688,12 @@ static void * ef_client_type(struct node * node){
static void * ef_client_operation(struct node * node){ static void * ef_client_operation(struct node * node){
if(!((struct clientparam *)node->value) -> operation) return NULL; if(!((struct clientparam *)node->value) -> operation) return NULL;
return &((struct clientparam *)node->value) -> operation; return &((struct clientparam *)node->value) -> operation;
} }
static void * ef_client_redirected(struct node * node){ static void * ef_client_redirected(struct node * node){
return &((struct clientparam *)node->value) -> redirected; return &((struct clientparam *)node->value) -> redirected;
} }
static void * ef_client_hostname(struct node * node){ static void * ef_client_hostname(struct node * node){
@ -614,6 +732,26 @@ static void * ef_client_pwtype(struct node * node){
return &((struct clientparam *)node->value) -> pwtype; return &((struct clientparam *)node->value) -> pwtype;
} }
static void * ef_client_redirtype(struct node * node){
int i;
for(i=0; redirs[i].name; i++){
if(((struct clientparam *)node->value) -> redirtype == redirs[i].redir) return redirs[i].name;
}
return "";
}
static void * ef_client_weight(struct node * node){
return &((struct clientparam *)node->value) -> weight;
}
static void * ef_client_nolog(struct node * node){
return &((struct clientparam *)node->value) -> nolog;
}
static void * ef_client_transparent(struct node * node){
return &((struct clientparam *)node->value) -> transparent;
}
static void * ef_client_threadid(struct node * node){ static void * ef_client_threadid(struct node * node){
return &((struct clientparam *)node->value) -> threadid; return &((struct clientparam *)node->value) -> threadid;
} }
@ -647,154 +785,179 @@ static void * ef_period_next(struct node * node){
} }
static struct property prop_portlist[] = { static struct property prop_portlist[] = {
{prop_portlist + 1, "start", ef_portlist_start, TYPE_PORT, "port range start"}, {"start", ef_portlist_start, TYPE_PORT, "port range start"},
{prop_portlist + 2, "end", ef_portlist_end, TYPE_PORT, "port range end"}, {"end", ef_portlist_end, TYPE_PORT, "port range end"},
{NULL, "next", ef_portlist_next, TYPE_PORTLIST, "next"} {"next", ef_portlist_next, TYPE_PORTLIST, "next"}
}; };
static struct property prop_userlist[] = { static struct property prop_userlist[] = {
{prop_userlist+1, "user", ef_userlist_user, TYPE_STRING, "user name"}, {"user", ef_userlist_user, TYPE_STRING, "user name"},
{NULL, "next", ef_userlist_next, TYPE_USERLIST, "next"} {"next", ef_userlist_next, TYPE_USERLIST, "next"}
};
static struct property prop_hostname[] = {
{"name", ef_hostname_name, TYPE_STRING, "hostname pattern"},
{"matchtype", ef_hostname_matchtype, TYPE_INTEGER, "match type"},
{"next", ef_hostname_next, TYPE_HOSTNAME, "next"}
}; };
static struct property prop_pwlist[] = { static struct property prop_pwlist[] = {
{prop_pwlist + 1, "user", ef_pwlist_user, TYPE_STRING, "user name"}, {"user", ef_pwlist_user, TYPE_STRING, "user name"},
{prop_pwlist + 2, "password", ef_pwlist_password, TYPE_STRING, "password string"}, {"password", ef_pwlist_password, TYPE_PASSWORD, "password string"},
{prop_pwlist + 3, "type", ef_pwlist_type, TYPE_STRING, "password type"}, {"type", ef_pwlist_type, TYPE_STRING, "password type"},
{NULL, "next", ef_pwlist_next, TYPE_PWLIST, "next"} {"next", ef_pwlist_next, TYPE_PWLIST, "next"}
}; };
static struct property prop_chain[] = { static struct property prop_chain[] = {
{prop_chain + 1, "addr", ef_chain_addr, TYPE_SA, "parent address"}, {"addr", ef_chain_addr, TYPE_SA, "parent address"},
{prop_chain + 2, "type", ef_chain_type, TYPE_STRING, "parent type"}, {"type", ef_chain_type, TYPE_STRING, "parent type"},
{prop_chain + 3, "weight", ef_chain_weight, TYPE_SHORT, "parent weight 0-1000"}, {"weight", ef_chain_weight, TYPE_SHORT, "parent weight 0-1000"},
{prop_chain + 4, "user", ef_chain_user, TYPE_STRING, "parent login"}, {"user", ef_chain_user, TYPE_STRING, "parent login"},
{prop_chain + 5, "password", ef_chain_password, TYPE_STRING, "parent password"}, {"password", ef_chain_password, TYPE_PASSWORD, "parent password"},
{NULL, "next", ef_chain_next, TYPE_CHAIN, "next"} {"secure", ef_chain_secure, TYPE_INTEGER, "secure mode"},
{"exthost", ef_chain_exthost, TYPE_STRING, "external hostname"},
{"cidr", ef_chain_cidr, TYPE_SHORT, "CIDR"},
{"next", ef_chain_next, TYPE_CHAIN, "next"}
}; };
static struct property prop_period[] = { static struct property prop_period[] = {
{prop_period + 1, "fromtime", ef_period_fromtime, TYPE_TIME, "from time" }, {"fromtime", ef_period_fromtime, TYPE_TIME, "from time" },
{prop_period + 2, "totime", ef_period_totime, TYPE_TIME, "to time" }, {"totime", ef_period_totime, TYPE_TIME, "to time" },
{NULL, "next", ef_period_next, TYPE_PERIOD, "next"} {"next", ef_period_next, TYPE_PERIOD, "next"}
}; };
static struct property prop_ace[] = { static struct property prop_ace[] = {
{prop_ace + 1, "type", ef_ace_type, TYPE_STRING, "ace action"}, {"type", ef_ace_type, TYPE_STRING, "ace action"},
{prop_ace + 2, "operations", ef_ace_operations, TYPE_OPERATIONS, "request type"}, {"operations", ef_ace_operations, TYPE_OPERATIONS, "request type"},
{prop_ace + 3, "users", ef_ace_users, TYPE_USERLIST, "list of users"}, {"users", ef_ace_users, TYPE_USERLIST, "list of users"},
{prop_ace + 4, "src", ef_ace_src, TYPE_IPLIST, "list of source ips"}, {"src", ef_ace_src, TYPE_IPLIST, "list of source ips"},
{prop_ace + 5, "dst", ef_ace_dst, TYPE_IPLIST, "list of destination ips"}, {"dst", ef_ace_dst, TYPE_IPLIST, "list of destination ips"},
{prop_ace + 6, "ports", ef_ace_ports, TYPE_PORTLIST, "list of destination ports"}, {"dstnames", ef_ace_dstnames, TYPE_HOSTNAME, "list of destination hostnames"},
{prop_ace + 7, "chain", ef_ace_chain, TYPE_CHAIN, "redirect to parent(s)"}, {"ports", ef_ace_ports, TYPE_PORTLIST, "list of destination ports"},
{prop_ace + 8, "wdays", ef_ace_weekdays, TYPE_WEEKDAYS, "days of week"}, {"chain", ef_ace_chain, TYPE_CHAIN, "redirect to parent(s)"},
{prop_ace + 9, "periods", ef_ace_period, TYPE_PERIOD, "time of the day"}, {"wdays", ef_ace_weekdays, TYPE_WEEKDAYS, "days of week"},
{NULL, "next", ef_ace_next, TYPE_ACE, "next"} {"periods", ef_ace_period, TYPE_PERIOD, "time of the day"},
{"weight", ef_ace_weight, TYPE_INTEGER, "ace weight"},
{"nolog", ef_ace_nolog, TYPE_INTEGER, "do not log"},
{"next", ef_ace_next, TYPE_ACE, "next"}
}; };
static struct property prop_bandlimit[] = { static struct property prop_bandlimit[] = {
{prop_bandlimit + 1, "ace", ef_bandlimit_ace, TYPE_ACE, "acl to apply"}, {"ace", ef_bandlimit_ace, TYPE_ACE, "acl to apply"},
{prop_bandlimit + 2, "rate", ef_bandlimit_rate, TYPE_UNSIGNED, "max allowed bandwidth"}, {"rate", ef_bandlimit_rate, TYPE_UNSIGNED, "max allowed bandwidth"},
{NULL, "next", ef_bandlimit_next, TYPE_BANDLIMIT, "next"} {"next", ef_bandlimit_next, TYPE_BANDLIMIT, "next"}
}; };
static struct property prop_trafcounter[] = { static struct property prop_trafcounter[] = {
{prop_trafcounter + 1, "disabled", ef_trafcounter_disabled, TYPE_INTEGER, "counter status"}, {"disabled", ef_trafcounter_disabled, TYPE_INTEGER, "counter status"},
{prop_trafcounter + 2, "ace", ef_trafcounter_ace, TYPE_ACE, "traffic to count"}, {"ace", ef_trafcounter_ace, TYPE_ACE, "traffic to count"},
{prop_trafcounter + 3, "number", ef_trafcounter_number, TYPE_UNSIGNED, "counter number"}, {"number", ef_trafcounter_number, TYPE_UNSIGNED, "counter number"},
{prop_trafcounter + 4, "type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"}, {"type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"},
{"traffic", ef_trafcounter_traffic64, TYPE_UNSIGNED64, "counter value"},
{"limit", ef_trafcounter_limit64, TYPE_UNSIGNED64, "counter limit"},
{prop_trafcounter + 5, "traffic", ef_trafcounter_traffic64, TYPE_UNSIGNED64, "counter value"}, {"cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"},
{prop_trafcounter + 6, "limit", ef_trafcounter_limit64, TYPE_UNSIGNED64, "counter limit"}, {"updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"},
{prop_trafcounter + 7, "cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"}, {"comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"},
{prop_trafcounter + 8, "updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"}, {"next", ef_trafcounter_next, TYPE_TRAFCOUNTER, "next"}
{prop_trafcounter + 9, "comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"},
{NULL, "next", ef_trafcounter_next, TYPE_TRAFCOUNTER}
}; };
/*
*/
static struct property prop_server[] = { static struct property prop_server[] = {
{prop_server + 1, "servicetype", ef_server_type, TYPE_STRING, "type of the service/client"}, {"servicetype", ef_server_type, TYPE_STRING, "type of the service/client"},
{prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"}, {"target", ef_server_target, TYPE_STRING, "portmapper target ip"},
{prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"}, {"targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
{prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"}, {"starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
{prop_server + 5, "auth", ef_server_auth, TYPE_STRING, "service authentication type"}, {"auth", ef_server_auth, TYPE_STRING, "service authentication type"},
{prop_server + 6, "acl", ef_server_acl, TYPE_ACE, "access control list"}, {"acl", ef_server_acl, TYPE_ACE, "access control list"},
{prop_server + 7, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"}, {"singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
{prop_server + 8, "log", ef_server_log, TYPE_STRING, "type of logging"}, {"log", ef_server_log, TYPE_STRING, "type of logging"},
{prop_server + 9, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"}, {"logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
{prop_server + 10, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"}, {"logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
{prop_server + 11, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"}, {"nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
{prop_server + 12, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"}, {"replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
{prop_server + 13, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"}, {"childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
{prop_server + 14, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"}, {"maxchild", ef_server_maxchild, TYPE_INTEGER, "max concurrent connections"},
{prop_server + 15, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"}, {"backlog", ef_server_backlog, TYPE_INTEGER, "listen backlog"},
{"needuser", ef_server_needuser, TYPE_INTEGER, "require user authentication"},
{"transparent", ef_server_transparent, TYPE_INTEGER, "transparent proxy"},
{"anonymous", ef_server_anonymous, TYPE_INTEGER, "anonymous mode"},
{"requirecert", ef_server_requirecert, TYPE_INTEGER, "require client certificate"},
{"haproxy", ef_server_haproxy, TYPE_INTEGER, "HAProxy protocol"},
{"authcachetype", ef_server_authcachetype, TYPE_UNSIGNED, "authentication cache type"},
{"authcachetime", ef_server_authcachetime, TYPE_UNSIGNED, "authentication cache time"},
{"gracetraf", ef_server_gracetraf, TYPE_INTEGER, "grace traffic"},
{"gracenum", ef_server_gracenum, TYPE_INTEGER, "grace number"},
{"gracedelay", ef_server_gracedelay, TYPE_INTEGER, "grace delay"},
{"logdumpsrv", ef_server_logdumpsrv, TYPE_UNSIGNED, "log dump server traffic"},
{"logdumpcli", ef_server_logdumpcli, TYPE_UNSIGNED, "log dump client traffic"},
{"intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
{"extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
{"intnat", ef_server_intNat, TYPE_SA, "internal NAT address"},
{"extnat", ef_server_extNat, TYPE_SA, "external NAT address"},
#ifndef NOIPV6 #ifndef NOIPV6
{prop_server + 16, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"}, {"extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
#else
{prop_server + 16, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
#endif #endif
{NULL, "next", ef_server_next, TYPE_SERVER, "next"} {"child", ef_server_child, TYPE_CLIENT, "connected clients"},
{"next", ef_server_next, TYPE_SERVER, "next"}
}; };
static struct property prop_client[] = { static struct property prop_client[] = {
{prop_client + 1, "servicetype", ef_client_type, TYPE_STRING, "type of the client"}, {"servicetype", ef_client_type, TYPE_STRING, "type of the client"},
{prop_client + 2, "threadid", ef_client_threadid, TYPE_UNSIGNED64, "process thread id"}, {"threadid", ef_client_threadid, TYPE_UNSIGNED64, "process thread id"},
{prop_client + 3, "starttime", ef_client_starttime, TYPE_DATETIME, "client started seconds"}, {"starttime", ef_client_starttime, TYPE_DATETIME, "client started seconds"},
{prop_client + 4, "starttime_msec", ef_client_starttime_msec, TYPE_UNSIGNED, "client started milliseconds"}, {"starttime_msec", ef_client_starttime_msec, TYPE_UNSIGNED, "client started milliseconds"},
{prop_client + 5, "redirected", ef_client_redirected, TYPE_INTEGER, "number of redirections"}, {"redirected", ef_client_redirected, TYPE_INTEGER, "number of redirections"},
{prop_client + 6, "operation", ef_client_operation, TYPE_OPERATIONS, "action requested by client"}, {"operation", ef_client_operation, TYPE_OPERATIONS, "action requested by client"},
{prop_client + 7, "hostname", ef_client_hostname, TYPE_STRING, "name of the requested host"}, {"hostname", ef_client_hostname, TYPE_STRING, "name of the requested host"},
{prop_client + 8, "extusername", ef_client_extusername, TYPE_STRING, "username for requested host"}, {"extusername", ef_client_extusername, TYPE_STRING, "username for requested host"},
{prop_client + 9, "extpassword", ef_client_extpassword, TYPE_STRING, "password for requested host"}, {"extpassword", ef_client_extpassword, TYPE_PASSWORD, "password for requested host"},
{prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"}, {"username", ef_client_username, TYPE_STRING, "client username"},
{prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"}, {"password", ef_client_password, TYPE_PASSWORD, "client password"},
{prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"}, {"clisa", ef_client_clisa, TYPE_SA, "client sa"},
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_SA, "target server sa"}, {"srvsa", ef_client_srvsa, TYPE_SA, "target server sa"},
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_SA, "requested server sa"}, {"reqsa", ef_client_reqsa, TYPE_SA, "requested server sa"},
{prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"}, {"bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
{prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"}, {"bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
{prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"}, {"maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
{prop_client + 18, "maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"}, {"maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"},
{prop_client + 19, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"}, {"pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"},
{prop_client + 20, "clisock", ef_client_clisock, TYPE_INTEGER, "client socket"}, {"redirtype", ef_client_redirtype, TYPE_STRING, "redirection type"},
{prop_client + 21, "remsock", ef_client_remsock, TYPE_INTEGER, "remote socket"}, {"weight", ef_client_weight, TYPE_INTEGER, "weight"},
{NULL, "next", ef_client_next, TYPE_CLIENT, "next"} {"nolog", ef_client_nolog, TYPE_INTEGER, "do not log"},
{"transparent", ef_client_transparent, TYPE_INTEGER, "transparent proxy"},
{"clisock", ef_client_clisock, TYPE_INTEGER, "client socket"},
{"remsock", ef_client_remsock, TYPE_INTEGER, "remote socket"},
{"next", ef_client_next, TYPE_CLIENT, "next"}
}; };
struct datatype datatypes[64] = { struct datatype datatypes[64] = {
{"integer", NULL, pr_integer, NULL}, {"integer", NULL, pr_integer, NULL, 0},
{"short", NULL, pr_short, NULL}, {"short", NULL, pr_short, NULL, 0},
{"char", NULL, pr_char, NULL}, {"char", NULL, pr_char, NULL, 0},
{"unsigned", NULL, pr_unsigned, NULL}, {"unsigned", NULL, pr_unsigned, NULL, 0},
{"unsigned64", NULL, pr_unsigned64, NULL}, {"unsigned64", NULL, pr_unsigned64, NULL, 0},
{"traffic", NULL, pr_traffic, NULL}, {"traffic", NULL, pr_traffic, NULL, 0},
{"port", NULL, pr_port, NULL}, {"port", NULL, pr_port, NULL, 0},
{"ip", NULL, pr_ip, NULL}, {"ip", NULL, pr_ip, NULL, 0},
{"sa", NULL, pr_sa, NULL}, {"sa", NULL, pr_sa, NULL, 0},
{"cidr", NULL, pr_cidr, NULL}, {"cidr", NULL, pr_cidr, NULL, 0},
{"string", NULL, pr_string, NULL}, {"string", NULL, pr_string, NULL, 0},
{"datetime", NULL, pr_datetime, NULL}, {"datetime", NULL, pr_datetime, NULL, 0},
{"operations", NULL, pr_operations, NULL}, {"operations", NULL, pr_operations, NULL, 0},
{"rotation", NULL, pr_rotation, NULL}, {"rotation", NULL, pr_rotation, NULL, 0},
{"portlist", ef_portlist_next, pr_portlist, prop_portlist}, {"portlist", ef_portlist_next, pr_portlist, prop_portlist, sizeof(prop_portlist)/sizeof(struct property)},
{"iplist", ef_iplist_next, pr_iplist, NULL}, {"iplist", ef_iplist_next, pr_iplist, NULL, 0},
{"userlist", ef_userlist_next, pr_userlist, prop_userlist}, {"userlist", ef_userlist_next, pr_userlist, prop_userlist, sizeof(prop_userlist)/sizeof(struct property)},
{"pwlist", ef_pwlist_next, NULL, prop_pwlist}, {"pwlist", ef_pwlist_next, NULL, prop_pwlist, sizeof(prop_pwlist)/sizeof(struct property)},
{"chain", ef_chain_next, NULL, prop_chain}, {"chain", ef_chain_next, NULL, prop_chain, sizeof(prop_chain)/sizeof(struct property)},
{"ace", ef_ace_next, NULL, prop_ace}, {"ace", ef_ace_next, NULL, prop_ace, sizeof(prop_ace)/sizeof(struct property)},
{"bandlimit", ef_bandlimit_next, NULL, prop_bandlimit}, {"bandlimit", ef_bandlimit_next, NULL, prop_bandlimit, sizeof(prop_bandlimit)/sizeof(struct property)},
{"trafcounter", ef_trafcounter_next, NULL, prop_trafcounter}, {"trafcounter", ef_trafcounter_next, NULL, prop_trafcounter, sizeof(prop_trafcounter)/sizeof(struct property)},
{"client", ef_client_next, NULL, prop_client}, {"client", ef_client_next, NULL, prop_client, sizeof(prop_client)/sizeof(struct property)},
{"weekdays", NULL, pr_wdays, NULL}, {"weekdays", NULL, pr_wdays, NULL, 0},
{"time", NULL, pr_time, NULL}, {"time", NULL, pr_time, NULL, 0},
{"period", ef_period_next, NULL, prop_period}, {"period", ef_period_next, NULL, prop_period, sizeof(prop_period)/sizeof(struct property)},
{"server", ef_server_next, NULL, prop_server} {"server", ef_server_next, NULL, prop_server, sizeof(prop_server)/sizeof(struct property)},
{"password", NULL, pr_password, NULL, 0},
{"hostname", ef_hostname_next, pr_hostname, prop_hostname, sizeof(prop_hostname)/sizeof(struct property)}
}; };

View File

@ -719,7 +719,6 @@ struct extparam {
}; };
struct property { struct property {
struct property * next;
char * name; char * name;
EXTENDFUNC e_f; EXTENDFUNC e_f;
int type; int type;
@ -731,6 +730,7 @@ struct datatype {
EXTENDFUNC i_f; EXTENDFUNC i_f;
PRINTFUNC p_f; PRINTFUNC p_f;
struct property * properties; struct property * properties;
unsigned properties_count;
}; };
struct node { struct node {
@ -900,7 +900,9 @@ typedef enum {
TYPE_WEEKDAYS, TYPE_WEEKDAYS,
TYPE_TIME, TYPE_TIME,
TYPE_PERIOD, TYPE_PERIOD,
TYPE_SERVER TYPE_SERVER,
TYPE_PASSWORD,
TYPE_HOSTNAME
}DATA_TYPE; }DATA_TYPE;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -134,7 +134,7 @@ static void printstr(struct printparam* pp, char* str){
static void printval(void *value, int type, int level, struct printparam* pp){ static void printval(void *value, int type, int level, struct printparam* pp){
struct node pn, cn; struct node pn, cn;
struct property *p; struct property *p;
int i; int i, pi;
pn.iteration = NULL; pn.iteration = NULL;
pn.parent = NULL; pn.parent = NULL;
@ -142,7 +142,8 @@ static void printval(void *value, int type, int level, struct printparam* pp){
pn.value = value; pn.value = value;
printstr(pp, "<item>"); printstr(pp, "<item>");
for(p = datatypes[type].properties; p; ) { for(pi = 0; pi < (int)datatypes[type].properties_count; ) {
p = datatypes[type].properties + pi;
cn.iteration = NULL; cn.iteration = NULL;
cn.parent = &pn; cn.parent = &pn;
cn.type = p->type; cn.type = p->type;
@ -171,7 +172,7 @@ static void printval(void *value, int type, int level, struct printparam* pp){
if(!strcmp(p->name, "next")){ if(!strcmp(p->name, "next")){
/* printstr(pp, "<!-- -------------------- -->\n"); */ /* printstr(pp, "<!-- -------------------- -->\n"); */
printstr(pp, "</item>\n<item>"); printstr(pp, "</item>\n<item>");
p = datatypes[type].properties; pi = 0;
pn.value = value = cn.value; pn.value = value = cn.value;
continue; continue;
} }
@ -182,7 +183,7 @@ static void printval(void *value, int type, int level, struct printparam* pp){
} }
} }
} }
p=p->next; pi++;
} }
printstr(pp, "</item>"); printstr(pp, "</item>");
} }