plugins: add option LWS_WITH_PLUGINS_BUILTIN

Add the ability to just build plugins into the main library.
They are already designed to have a pinhole export for when
they are used as dynamic lib plugins so their namespace
does not conflict.
This commit is contained in:
Andy Green 2021-01-31 05:50:12 +00:00
parent 39cc5aec7c
commit 0e6df74409
20 changed files with 239 additions and 95 deletions

View File

@ -98,7 +98,7 @@ if(LWS_WITH_DISTRO_RECOMMENDED)
set(LWS_WITH_DISKCACHE 1) # selfcontained
set(LWS_WITH_LWSAC 1) # selfcontained
set(LWS_WITH_LEJP_CONF 1) # selfcontained
set(LWS_WITH_PLUGINS 1) # libdl
set(LWS_WITH_PLUGINS_BUILTIN 1) # selfcontained
set(LWS_ROLE_RAW_PROXY 1) # selfcontained
set(LWS_WITH_GENCRYPTO 1) # selfcontained / tls
set(LWS_WITH_JOSE 1) # selfcontained

View File

@ -105,6 +105,7 @@ option(LWS_WITH_CGI "Include CGI (spawn process with network-connected stdin/out
option(LWS_IPV6 "Compile with support for ipv6" OFF)
option(LWS_UNIX_SOCK "Compile with support for UNIX domain socket if OS supports it" ON)
option(LWS_WITH_PLUGINS "Support plugins for protocols and extensions (implies LWS_WITH_PLUGINS_API)" OFF)
option(LWS_WITH_PLUGINS_BUILTIN "Build the plugin protocols directly into lws library" OFF)
option(LWS_WITH_HTTP_PROXY "Support for active HTTP proxying" OFF)
option(LWS_WITH_ZIP_FOPS "Support serving pre-zipped files" OFF)
option(LWS_WITH_SOCKS5 "Allow use of SOCKS5 proxy on client connections" OFF)
@ -857,6 +858,10 @@ if (LWS_HAVE_LIBCAP)
list(APPEND LIB_LIST ${LIBCAP_LIBRARIES} )
endif()
if (LWS_WITH_PLUGINS_BUILTIN)
add_subdirectory(plugins)
endif()
#
# Append the "at end" pieces to the lib list
@ -868,8 +873,8 @@ list(APPEND LIB_LIST ${LIB_LIST_AT_END})
#
include_directories("${PROJECT_SOURCE_DIR}/lib")
add_subdirectory(lib)
add_subdirectory(lib)
if(WIN32 AND NOT CYGWIN)
@ -921,7 +926,9 @@ if (NOT LWS_WITHOUT_TESTAPPS)
add_subdirectory(test-apps)
endif()
if (NOT LWS_WITH_PLUGINS_BUILTIN)
add_subdirectory(plugins)
endif()
add_subdirectory(lwsws)
# Generate the lws_config.h that includes all the public compilation settings.

View File

@ -168,6 +168,7 @@
#cmakedefine LWS_WITH_SPAWN
#cmakedefine LWS_WITH_PEER_LIMITS
#cmakedefine LWS_WITH_PLUGINS
#cmakedefine LWS_WITH_PLUGINS_BUILTIN
#cmakedefine LWS_WITH_POLARSSL
#cmakedefine LWS_WITH_POLL
#cmakedefine LWS_WITH_RANGES

View File

@ -342,4 +342,25 @@ LWS_VISIBLE LWS_EXTERN int
lws_plugins_destroy(struct lws_plugin **pplugin, each_plugin_cb_t each,
void *each_user);
#if defined(LWS_WITH_PLUGINS_BUILTIN)
/* provide exports for builtin plugin protocols */
extern const struct lws_protocols post_demo_protocols[1];
extern const struct lws_protocols lws_raw_proxy_protocols[1];
extern const struct lws_protocols lws_status_protocols[1];
extern const struct lws_protocols lws_mirror_protocols[1];
extern const struct lws_protocols lws_ssh_base_protocols[2];
extern const struct lws_protocols post_demo_protocols[1];
extern const struct lws_protocols dumb_increment_protocols[1];
extern const struct lws_protocols deaddrop_protocols[1];
extern const struct lws_protocols lws_raw_test_protocols[1];
extern const struct lws_protocols lws_sshd_demo_protocols[1];
extern const struct lws_protocols lws_acme_client_protocols[1];
extern const struct lws_protocols client_loopback_test_protocols[1];
extern const struct lws_protocols fulltext_demo_protocols[1];
#endif
///@}

View File

@ -22,9 +22,15 @@
* outside the library easily.
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
#include <string.h>

View File

@ -1,7 +1,7 @@
#
# libwebsockets - small server side websockets and web server implementation
#
# Copyright (C) 2010 - 2020 Andy Green <andy@warmcat.com>
# Copyright (C) 2010 - 2021 Andy Green <andy@warmcat.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
@ -28,91 +28,140 @@ if (DEFINED LIB_LIST_AT_END)
link_libraries(${LIB_LIST_AT_END})
endif()
if (LWS_WITH_PLUGINS AND LWS_WITH_SHARED)
if ((LWS_WITH_PLUGINS AND LWS_WITH_SHARED) OR LWS_WITH_PLUGINS_BUILTIN)
#
# Either build the plugins as separate dynamic libs (LWS_WITH_PLUGINS)
# or build into the main lws library (LWS_WITH_PLUGINS_BUILTIN)
#
macro(create_plugin PLUGIN_NAME PLUGIN_INCLUDE MAIN_SRC S2 S3)
set(PLUGIN_SRCS ${MAIN_SRC})
if (NOT LWS_WITH_PLUGINS_BUILTIN)
set(PLUGIN_SRCS ${MAIN_SRC})
if ("${S2}" STREQUAL "")
else()
list(APPEND PLUGIN_SRCS ${S2})
endif()
if ("${S3}" STREQUAL "")
else()
list(APPEND PLUGIN_SRCS ${S3})
endif()
if ("${S2}" STREQUAL "")
else()
list(APPEND PLUGIN_SRCS ${S2})
endif()
if ("${S3}" STREQUAL "")
else()
list(APPEND PLUGIN_SRCS ${S3})
endif()
if (WIN32)
list(APPEND PLUGIN_SRCS
${WIN32_HELPERS_PATH}/getopt.c
${WIN32_HELPERS_PATH}/getopt_long.c
${WIN32_HELPERS_PATH}/gettimeofday.c
)
if (WIN32)
list(APPEND PLUGIN_SRCS
${WIN32_HELPERS_PATH}/getopt.c
${WIN32_HELPERS_PATH}/getopt_long.c
${WIN32_HELPERS_PATH}/gettimeofday.c
)
list(APPEND PLUGIN_HDR
${WIN32_HELPERS_PATH}/getopt.h
${WIN32_HELPERS_PATH}/gettimeofday.h
)
endif(WIN32)
list(APPEND PLUGIN_HDR
${WIN32_HELPERS_PATH}/getopt.h
${WIN32_HELPERS_PATH}/gettimeofday.h
)
endif(WIN32)
source_group("Headers Private" FILES ${PLUGIN_HDR})
source_group("Sources" FILES ${PLUGIN_SRCS})
add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR})
target_link_libraries(${PLUGIN_NAME} websockets_shared)
add_dependencies(${PLUGIN_NAME} websockets_shared)
source_group("Headers Private" FILES ${PLUGIN_HDR})
source_group("Sources" FILES ${PLUGIN_SRCS})
add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR})
target_link_libraries(${PLUGIN_NAME} websockets_shared)
add_dependencies(${PLUGIN_NAME} websockets_shared)
# doesn't work inside macro :-O
# target_compile_definitions(${PLUGIN_NAME} PRIVATE LWS_BUILDING_SHARED)
target_include_directories(${PLUGIN_NAME} PRIVATE ${PLUGIN_INCLUDE}
${LWS_LIB_BUILD_INC_PATHS})
set_property(TARGET ${PLUGIN_NAME}
PROPERTY COMPILE_DEFINITIONS
INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins"
)
# doesn't work inside macro :-O
# target_compile_definitions(${PLUGIN_NAME} PRIVATE LWS_BUILDING_SHARED)
target_include_directories(${PLUGIN_NAME} PRIVATE ${PLUGIN_INCLUDE}
${LWS_LIB_BUILD_INC_PATHS})
set_property(TARGET ${PLUGIN_NAME}
PROPERTY COMPILE_DEFINITIONS
INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins"
)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
list(APPEND PLUGINS_LIST ${PLUGIN_NAME})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
list(APPEND PLUGINS_LIST ${PLUGIN_NAME})
else()
# let's just build the things into the lib
message("Building in plugin ${PLUGIN_NAME}")
if ("${PLUGIN_INCLUDE}" STREQUAL "")
else()
list(APPEND LWS_LIB_BUILD_INC_PATHS ../plugins/${PLUGIN_INCLUDE})
endif()
if ("${MAIN_SRC}" STREQUAL "")
else()
foreach(A ${MAIN_SRC})
list(APPEND SOURCES ../plugins/${A})
endforeach()
endif()
if ("${S2}" STREQUAL "")
else()
foreach(A ${S2})
list(APPEND SOURCES ../plugins/${A})
endforeach()
endif()
if ("${S3}" STREQUAL "")
else()
foreach(A ${S3})
list(APPEND SOURCES ../plugins/${A})
endforeach()
endif()
endif(NOT LWS_WITH_PLUGINS_BUILTIN)
endmacro()
if (LWS_ROLE_WS)
create_plugin(protocol_dumb_increment ""
"protocol_dumb_increment.c" "" "")
target_compile_definitions(protocol_dumb_increment PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_dumb_increment PRIVATE LWS_BUILDING_SHARED)
endif()
create_plugin(protocol_lws_mirror ""
"protocol_lws_mirror.c" "" "")
target_compile_definitions(protocol_lws_mirror PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_lws_mirror PRIVATE LWS_BUILDING_SHARED)
endif()
create_plugin(protocol_lws_status ""
"protocol_lws_status.c" "" "")
target_compile_definitions(protocol_lws_status PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_lws_status PRIVATE LWS_BUILDING_SHARED)
endif()
if (NOT WIN32)
create_plugin(protocol_lws_raw_test ""
"protocol_lws_raw_test.c" "" "")
target_compile_definitions(protocol_lws_raw_test PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_lws_raw_test PRIVATE LWS_BUILDING_SHARED)
endif()
if (UNIX AND LWS_HAVE_PTHREAD_H)
create_plugin(protocol_deaddrop ""
"deaddrop/protocol_lws_deaddrop.c" "" "")
target_compile_definitions(protocol_deaddrop PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_deaddrop PRIVATE LWS_BUILDING_SHARED)
endif()
endif()
endif()
if (LWS_WITH_SERVER_STATUS)
create_plugin(protocol_lws_server_status ""
"protocol_lws_server_status.c" "" "")
target_compile_definitions(protocol_lws_server_status PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_lws_server_status PRIVATE LWS_BUILDING_SHARED)
endif()
endif()
if (NOT LWS_WITHOUT_CLIENT)
create_plugin(protocol_client_loopback_test ""
"protocol_client_loopback_test.c" "" "")
target_compile_definitions(protocol_client_loopback_test PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_client_loopback_test PRIVATE LWS_BUILDING_SHARED)
endif()
endif()
@ -120,20 +169,26 @@ endif(LWS_ROLE_WS)
create_plugin(protocol_post_demo ""
"protocol_post_demo.c" "" "")
target_compile_definitions(protocol_post_demo PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_post_demo PRIVATE LWS_BUILDING_SHARED)
endif()
if (LWS_ROLE_RAW_PROXY)
create_plugin(protocol_lws_raw_proxy ""
"raw-proxy/protocol_lws_raw_proxy.c" "" "")
target_compile_definitions(protocol_lws_raw_proxy PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_lws_raw_proxy PRIVATE LWS_BUILDING_SHARED)
endif()
endif()
if (LWS_WITH_FTS)
create_plugin(protocol_fulltext_demo ""
"protocol_fulltext_demo.c" "" "")
target_compile_definitions(protocol_fulltext_demo PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_fulltext_demo PRIVATE LWS_BUILDING_SHARED)
endif()
endif()
@ -141,10 +196,14 @@ endif()
if (LWS_WITH_SSL)
create_plugin(protocol_lws_ssh_base "ssh-base/include"
"ssh-base/sshd.c;ssh-base/telnet.c;ssh-base/kex-25519.c" "ssh-base/crypto/chacha.c;ssh-base/crypto/ed25519.c;ssh-base/crypto/fe25519.c;ssh-base/crypto/ge25519.c;ssh-base/crypto/poly1305.c;ssh-base/crypto/sc25519.c;ssh-base/crypto/smult_curve25519_ref.c" "")
target_compile_definitions(protocol_lws_ssh_base PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_lws_ssh_base PRIVATE LWS_BUILDING_SHARED)
endif()
create_plugin(protocol_lws_sshd_demo "ssh-base/include" "protocol_lws_sshd_demo.c" "" "")
target_compile_definitions(protocol_lws_sshd_demo PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_lws_sshd_demo PRIVATE LWS_BUILDING_SHARED)
endif()
include_directories("${PROJECT_SOURCE_DIR}/plugins/ssh-base/include")
endif()
@ -154,15 +213,18 @@ endif()
if (LWS_WITH_ACME)
create_plugin(protocol_lws_acme_client ""
"acme-client/protocol_lws_acme_client.c" "" "")
target_compile_definitions(protocol_lws_acme_client PRIVATE LWS_BUILDING_SHARED)
if (NOT LWS_WITH_PLUGINS_BUILTIN)
target_compile_definitions(protocol_lws_acme_client PRIVATE LWS_BUILDING_SHARED)
endif()
endif()
endif(LWS_WITH_PLUGINS AND LWS_WITH_SHARED)
endif((LWS_WITH_PLUGINS AND LWS_WITH_SHARED) OR LWS_WITH_PLUGINS_BUILTIN)
# plugins
if (LWS_WITH_PLUGINS)
if (LWS_WITH_PLUGINS AND NOT LWS_WITH_PLUGINS_BUILTIN)
install(TARGETS ${PLUGINS_LIST}
PERMISSIONS OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE OWNER_READ GROUP_READ WORLD_READ
DESTINATION share/libwebsockets-test-server/plugins
@ -181,3 +243,6 @@ if (LWS_WITH_SERVER_STATUS)
COMPONENT examples)
endif()
endif()
export_to_parent_intermediate()

View File

@ -34,8 +34,12 @@
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
@ -1629,7 +1633,7 @@ failed:
#if !defined (LWS_PLUGIN_STATIC)
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols lws_acme_client_protocols[] = {
LWS_PLUGIN_PROTOCOL_LWS_ACME_CLIENT
};
@ -1641,8 +1645,8 @@ LWS_VISIBLE const lws_plugin_protocol_t protocol_lws_acme_client = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = lws_acme_client_protocols,
.count_protocols = LWS_ARRAY_SIZE(lws_acme_client_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -23,8 +23,12 @@
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
@ -691,7 +695,7 @@ try_to_reuse:
#if !defined (LWS_PLUGIN_STATIC)
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols deaddrop_protocols[] = {
LWS_PLUGIN_PROTOCOL_DEADDROP
};
@ -703,8 +707,8 @@ LWS_VISIBLE const lws_plugin_protocol_t deaddrop = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = deaddrop_protocols,
.count_protocols = LWS_ARRAY_SIZE(deaddrop_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -18,8 +18,12 @@
* Public Domain.
*/
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#include <string.h>
@ -164,7 +168,7 @@ callback_client_loopback_test(struct lws *wsi, enum lws_callback_reasons reason,
return 0;
}
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols client_loopback_test_protocols[] = {
{
"client-loopback-test",
callback_client_loopback_test,
@ -181,8 +185,8 @@ LWS_VISIBLE const lws_plugin_protocol_t client_loopback_test = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = client_loopback_test_protocols,
.count_protocols = LWS_ARRAY_SIZE(client_loopback_test_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -19,8 +19,12 @@
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
@ -117,7 +121,7 @@ callback_dumb_increment(struct lws *wsi, enum lws_callback_reasons reason,
#if !defined (LWS_PLUGIN_STATIC)
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols dumb_increment_protocols[] = {
LWS_PLUGIN_PROTOCOL_DUMB_INCREMENT
};
@ -129,8 +133,8 @@ LWS_VISIBLE const lws_plugin_protocol_t dumb_increment = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = dumb_increment_protocols,
.count_protocols = LWS_ARRAY_SIZE(dumb_increment_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -19,8 +19,12 @@
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
@ -262,7 +266,7 @@ reply_404:
#if !defined (LWS_PLUGIN_STATIC)
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols fulltext_demo_protocols[] = {
LWS_PLUGIN_PROTOCOL_FULLTEXT_DEMO
};
@ -274,8 +278,8 @@ LWS_VISIBLE const lws_plugin_protocol_t fulltext_demo = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = fulltext_demo_protocols,
.count_protocols = LWS_ARRAY_SIZE(fulltext_demo_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -24,8 +24,12 @@
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
@ -480,7 +484,7 @@ done2:
#if !defined (LWS_PLUGIN_STATIC)
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols lws_mirror_protocols[] = {
LWS_PLUGIN_PROTOCOL_MIRROR
};
@ -492,8 +496,8 @@ LWS_VISIBLE const lws_plugin_protocol_t lws_mirror = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = lws_mirror_protocols,
.count_protocols = LWS_ARRAY_SIZE(lws_mirror_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -66,8 +66,12 @@
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
@ -279,7 +283,7 @@ callback_raw_test(struct lws *wsi, enum lws_callback_reasons reason, void *user,
#if !defined (LWS_PLUGIN_STATIC)
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols lws_raw_test_protocols[] = {
LWS_PLUGIN_PROTOCOL_RAW_TEST
};
@ -291,8 +295,8 @@ LWS_VISIBLE const lws_plugin_protocol_t lws_raw_test = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = lws_raw_test_protocols,
.count_protocols = LWS_ARRAY_SIZE(lws_raw_test_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -19,8 +19,12 @@
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
@ -211,7 +215,7 @@ ssh_ops_get_server_key(struct lws *wsi, uint8_t *buf, size_t len)
if (lseek(vhd->privileged_fd, 0, SEEK_SET) < 0)
return 0;
n = (int)read(vhd->privileged_fd, buf, len);
n = (int)read(vhd->privileged_fd, buf, (unsigned int)len);
if (n < 0) {
lwsl_err("%s: read failed: %d\n", __func__, n);
n = 0;
@ -229,7 +233,7 @@ ssh_ops_set_server_key(struct lws *wsi, uint8_t *buf, size_t len)
lws_get_protocol(wsi));
int n;
n = (int)write(vhd->privileged_fd, buf, len);
n = (int)write(vhd->privileged_fd, buf, (unsigned int)len);
if (n < 0) {
lwsl_err("%s: read failed: %d\n", __func__, errno);
n = 0;
@ -455,7 +459,7 @@ callback_lws_sshd_demo(struct lws *wsi, enum lws_callback_reasons reason,
#if !defined (LWS_PLUGIN_STATIC)
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols lws_sshd_demo_protocols[] = {
LWS_PLUGIN_PROTOCOL_LWS_SSHD_DEMO
};
@ -467,8 +471,8 @@ LWS_VISIBLE const lws_plugin_protocol_t lws_sshd_demo = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = lws_sshd_demo_protocols,
.count_protocols = LWS_ARRAY_SIZE(lws_sshd_demo_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -19,8 +19,12 @@
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
@ -243,7 +247,7 @@ walk_final:
#if !defined (LWS_PLUGIN_STATIC)
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols lws_status_protocols[] = {
LWS_PLUGIN_PROTOCOL_LWS_STATUS
};
@ -255,8 +259,8 @@ LWS_VISIBLE const lws_plugin_protocol_t lws_status = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = lws_status_protocols,
.count_protocols = LWS_ARRAY_SIZE(lws_status_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -19,8 +19,12 @@
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
@ -283,7 +287,7 @@ try_to_reuse:
#if !defined (LWS_PLUGIN_STATIC)
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols post_demo_protocols[] = {
LWS_PLUGIN_PROTOCOL_POST_DEMO
};
@ -295,8 +299,8 @@ LWS_VISIBLE const lws_plugin_protocol_t post_demo = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = post_demo_protocols,
.count_protocols = LWS_ARRAY_SIZE(post_demo_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -23,8 +23,12 @@
*/
#if !defined (LWS_PLUGIN_STATIC)
#if !defined(LWS_DLL)
#define LWS_DLL
#endif
#if !defined(LWS_INTERNAL)
#define LWS_INTERNAL
#endif
#include <libwebsockets.h>
#endif
@ -560,7 +564,7 @@ bad_onward:
#if !defined (LWS_PLUGIN_STATIC)
static const struct lws_protocols protocols[] = {
LWS_VISIBLE const struct lws_protocols lws_raw_proxy_protocols[] = {
LWS_PLUGIN_PROTOCOL_RAW_PROXY
};
@ -572,8 +576,8 @@ LWS_VISIBLE const lws_plugin_protocol_t lws_raw_proxy = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols,
.count_protocols = LWS_ARRAY_SIZE(protocols),
.protocols = lws_raw_proxy_protocols,
.count_protocols = LWS_ARRAY_SIZE(lws_raw_proxy_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -2561,7 +2561,7 @@ bail:
1024, 0, NULL, 900 \
}
const struct lws_protocols protocols_sshd[] = {
LWS_VISIBLE const struct lws_protocols lws_ssh_base_protocols[] = {
LWS_PLUGIN_PROTOCOL_LWS_RAW_SSHD,
{ NULL, NULL, 0, 0, 0, NULL, 0 } /* terminator */
};
@ -2576,8 +2576,8 @@ LWS_VISIBLE const lws_plugin_protocol_t lws_ssh_base = {
LWS_PLUGIN_API_MAGIC
},
.protocols = protocols_sshd,
.count_protocols = LWS_ARRAY_SIZE(protocols_sshd),
.protocols = lws_ssh_base_protocols,
.count_protocols = LWS_ARRAY_SIZE(lws_ssh_base_protocols),
.extensions = NULL,
.count_extensions = 0,
};

View File

@ -134,7 +134,7 @@ if ((LWS_ROLE_H1 OR LWS_ROLE_H2))
"")
target_compile_definitions(test-server PRIVATE LWS_BUILDING_SHARED)
if (LWS_WITH_CGI AND LWS_WITH_TLS)
if (LWS_WITH_CGI AND (LWS_WITH_PLUGINS OR LWS_WITH_PLUGINS_BUILTIN) AND LWS_WITH_TLS)
create_test_app(test-sshd "test-sshd.c"
""
""

View File

@ -677,7 +677,7 @@ int main()
info.port = 2200;
info.options = LWS_SERVER_OPTION_ONLY_RAW;
info.vhost_name = "sshd";
info.protocols = protocols_sshd;
info.protocols = lws_sshd_demo_protocols;
info.pvo = &pvo_ssh;
vh_sshd = lws_create_vhost(context, &info);