mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
plugins: gitws libjsongit2 support
This adds a plugin that interfaces to libjsongit2 https://warmcat.com/git/libjsongit2 to provide a per-vhost service for presenting bare git repos in a web interface.
This commit is contained in:
parent
12ec231411
commit
a03dd40e62
13 changed files with 55 additions and 24 deletions
|
@ -669,7 +669,7 @@ if (LWS_WITH_LIBUV)
|
|||
CHECK_INCLUDE_FILE(uv-version.h LWS_HAVE_UV_VERSION_H)
|
||||
# libuv changed the location in 1.21.0. Retain both
|
||||
# checks temporarily to ensure a smooth transition.
|
||||
if(NOT LWS_HAVE_UV_VERSION_H)
|
||||
if (NOT LWS_HAVE_UV_VERSION_H)
|
||||
CHECK_INCLUDE_FILE(uv/version.h LWS_HAVE_NEW_UV_VERSION_H)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -1795,6 +1795,9 @@ if ((LWS_ROLE_H1 OR LWS_ROLE_H2) AND NOT LWS_WITHOUT_TESTAPPS)
|
|||
INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins"
|
||||
)
|
||||
|
||||
SET_TARGET_PROPERTIES(${PLUGIN_NAME}
|
||||
PROPERTIES COMPILE_FLAGS ${CMAKE_C_FLAGS})
|
||||
|
||||
# set_target_properties(${PLUGIN_NAME}
|
||||
# PROPERTIES
|
||||
# OUTPUT_NAME ${PLUGIN_NAME})
|
||||
|
|
|
@ -2733,6 +2733,27 @@ lws_json_purify(char *escaped, const char *string, int len)
|
|||
}
|
||||
|
||||
while (*p && len-- > 6) {
|
||||
if (*p == '\t') {
|
||||
p++;
|
||||
*q++ = '\\';
|
||||
*q++ = 't';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*p == '\n') {
|
||||
p++;
|
||||
*q++ = '\\';
|
||||
*q++ = 'n';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*p == '\r') {
|
||||
p++;
|
||||
*q++ = '\\';
|
||||
*q++ = 'r';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*p == '\"' || *p == '\\' || *p < 0x20) {
|
||||
*q++ = '\\';
|
||||
*q++ = 'u';
|
||||
|
|
|
@ -1320,7 +1320,7 @@ lws_handshake_server(struct lws *wsi, unsigned char **buf, size_t len);
|
|||
LWS_EXTERN int
|
||||
lws_access_log(struct lws *wsi);
|
||||
LWS_EXTERN void
|
||||
lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int meth);
|
||||
lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int len, int meth);
|
||||
#else
|
||||
#define lws_access_log(_a)
|
||||
#endif
|
||||
|
|
|
@ -442,6 +442,8 @@ lws_plat_plugins_destroy(struct lws_context *context)
|
|||
void *v;
|
||||
int m;
|
||||
|
||||
// return 0;
|
||||
|
||||
#if defined(__MINGW32__) || !defined(WIN32)
|
||||
pofs = 3;
|
||||
#endif
|
||||
|
|
|
@ -4101,7 +4101,7 @@ LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
|
|||
lws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx);
|
||||
|
||||
/**
|
||||
* lws_hdr_copy() - copy a single fragment of the given header to a buffer
|
||||
* lws_hdr_copy() - copy all fragments of the given header to a buffer
|
||||
* The buffer length len must include space for an additional
|
||||
* terminating '\0', or it will fail returning -1.
|
||||
*
|
||||
|
@ -4111,7 +4111,8 @@ lws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx)
|
|||
* \param h: which header index we are interested in
|
||||
*
|
||||
* copies the whole, aggregated header, even if it was delivered in
|
||||
* several actual headers piece by piece
|
||||
* several actual headers piece by piece. Returns -1 or length of the whole
|
||||
* header.
|
||||
*/
|
||||
LWS_VISIBLE LWS_EXTERN int
|
||||
lws_hdr_copy(struct lws *wsi, char *dest, int len, enum lws_token_indexes h);
|
||||
|
|
|
@ -2073,7 +2073,7 @@ lws_h2_client_handshake(struct lws *wsi)
|
|||
|
||||
if (lws_add_http_header_by_token(wsi,
|
||||
WSI_TOKEN_HTTP_COLON_SCHEME,
|
||||
(unsigned char *)"http", 4,
|
||||
(unsigned char *)"https", 4,
|
||||
&p, end))
|
||||
goto fail_length;
|
||||
|
||||
|
|
|
@ -319,7 +319,7 @@ create_new_conn:
|
|||
}
|
||||
#endif
|
||||
} else {
|
||||
lwsl_err("getaddrinfo failed\n");
|
||||
lwsl_err("getaddrinfo failed: %d\n", n);
|
||||
cce = "getaddrinfo failed";
|
||||
goto oom4;
|
||||
}
|
||||
|
|
|
@ -38,14 +38,14 @@ static const char * const hver[] = {
|
|||
};
|
||||
|
||||
void
|
||||
lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int meth)
|
||||
lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int uri_len, int meth)
|
||||
{
|
||||
#ifdef LWS_WITH_IPV6
|
||||
char ads[INET6_ADDRSTRLEN];
|
||||
#else
|
||||
char ads[INET_ADDRSTRLEN];
|
||||
#endif
|
||||
char da[64];
|
||||
char da[64], uri[256];
|
||||
const char *pa, *me;
|
||||
struct tm *tmp;
|
||||
time_t t = time(NULL);
|
||||
|
@ -81,11 +81,20 @@ lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int meth)
|
|||
if (!me)
|
||||
me = "(null)";
|
||||
|
||||
m = uri_len;
|
||||
if (m > (int)sizeof(uri) - 1)
|
||||
m = sizeof(uri) - 1;
|
||||
|
||||
strncpy(uri, uri_ptr, m);
|
||||
uri[m] = '\0';
|
||||
|
||||
lws_snprintf(wsi->http.access_log.header_log, l,
|
||||
"%s - - [%s] \"%s %s %s\"",
|
||||
pa, da, me, uri_ptr,
|
||||
pa, da, me, uri,
|
||||
hver[wsi->http.request_version]);
|
||||
|
||||
lwsl_notice("%s\n", wsi->http.access_log.header_log);
|
||||
|
||||
l = lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_USER_AGENT);
|
||||
if (l) {
|
||||
wsi->http.access_log.user_agent = lws_malloc(l + 2, "access log");
|
||||
|
|
|
@ -599,7 +599,8 @@ issue_char(struct lws *wsi, unsigned char c)
|
|||
* If we haven't hit the token limit, just copy the character into
|
||||
* the header
|
||||
*/
|
||||
if (frag_len < wsi->http.ah->current_token_limit) {
|
||||
if (!wsi->http.ah->current_token_limit ||
|
||||
frag_len < wsi->http.ah->current_token_limit) {
|
||||
wsi->http.ah->data[wsi->http.ah->pos++] = c;
|
||||
if (c)
|
||||
wsi->http.ah->frags[wsi->http.ah->nfrag].len++;
|
||||
|
|
|
@ -1001,7 +1001,7 @@ lws_http_action(struct lws *wsi)
|
|||
#endif
|
||||
|
||||
#ifdef LWS_WITH_ACCESS_LOG
|
||||
lws_prepare_access_log_info(wsi, uri_ptr, meth);
|
||||
lws_prepare_access_log_info(wsi, uri_ptr, uri_len, meth);
|
||||
#endif
|
||||
|
||||
/* can we serve it from the mount list? */
|
||||
|
@ -1292,7 +1292,7 @@ lws_http_action(struct lws *wsi)
|
|||
}
|
||||
#endif
|
||||
|
||||
n = (int)strlen(s);
|
||||
n = uri_len - (s - uri_ptr); // (int)strlen(s);
|
||||
if (s[0] == '\0' || (n == 1 && s[n - 1] == '/'))
|
||||
s = (char *)hit->def;
|
||||
if (!s)
|
||||
|
@ -1548,7 +1548,7 @@ raw_transition:
|
|||
&uri_ptr, &uri_len);
|
||||
if (meth >= 0)
|
||||
lws_prepare_access_log_info(wsi,
|
||||
uri_ptr, meth);
|
||||
uri_ptr, uri_len, meth);
|
||||
|
||||
/* wsi close will do the log */
|
||||
#endif
|
||||
|
@ -1714,7 +1714,7 @@ lws_http_transaction_completed(struct lws *wsi)
|
|||
|
||||
/* if we can't go back to accept new headers, drop the connection */
|
||||
if (wsi->http2_substream)
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
if (wsi->seen_zero_length_recv)
|
||||
return 1;
|
||||
|
|
|
@ -208,7 +208,7 @@ reload_handler(int signum)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int n = 0, budget = 100, debug_level = 7;
|
||||
int n = 0, budget = 100, debug_level = 1024 + 7;
|
||||
#ifndef _WIN32
|
||||
int m;
|
||||
int status, syslog_options = LOG_PID | LOG_PERROR;
|
||||
|
|
|
@ -415,6 +415,9 @@ callback_lws_sshd_demo(struct lws *wsi, enum lws_callback_reasons reason,
|
|||
case LWS_CALLBACK_VHOST_CERT_AGING:
|
||||
break;
|
||||
|
||||
case LWS_CALLBACK_EVENT_WAIT_CANCELLED:
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!vhd->ssh_base_protocol) {
|
||||
vhd->ssh_base_protocol = lws_vhost_name_to_protocol(
|
||||
|
|
9
test-apps/.gitignore
vendored
9
test-apps/.gitignore
vendored
|
@ -1,9 +0,0 @@
|
|||
#Ignore build files
|
||||
libwebsockets-test-*
|
||||
Makefile
|
||||
*.o
|
||||
*.lo
|
||||
*.la
|
||||
.libs
|
||||
.deps
|
||||
|
Loading…
Add table
Reference in a new issue