*
* Copyright (C) 2010-2016 Andy Green <andy@warmcat.com>
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation:
- * version 2.1 of the License.
+ * This file is made available under the Creative Commons CC0 1.0
+ * Universal Public Domain Dedication.
*
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
+ * The person who associated a work with this deed has dedicated
+ * the work to the public domain by waiving all of his or her rights
+ * to the work worldwide under copyright law, including all related
+ * and neighboring rights, to the extent allowed by law. You can copy,
+ * modify, distribute and perform the work, even for commercial purposes,
+ * all without asking permission.
*
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
+ * The test apps are intended to be adapted for use in your code, which
+ * may be proprietary. So unlike the library itself, they are licensed
+ * Public Domain.
*/
#include "test-server.h"
volatile int force_exit = 0;
struct lws_context *context;
+#if defined(LWS_OPENSSL_SUPPORT) && defined(LWS_HAVE_SSL_CTX_set1_param)
+char crl_path[1024] = "";
+#endif
+
+#define LWS_PLUGIN_STATIC
+#include "../plugins/protocol_lws_mirror.c"
+#include "../plugins/protocol_lws_status.c"
+
/*
* This mutex lock protects code that changes or relies on wsi list outside of
- * the service thread. The service thread will acquire it when changing the
+ * the service thread. The service thread will acquire it when changing the
* wsi list and other threads should acquire it while dereferencing wsis or
* calling apis like lws_callback_on_writable_all_protocol() which
* use the wsi list and wsis from a different thread context.
PROTOCOL_DUMB_INCREMENT,
PROTOCOL_LWS_MIRROR,
+ PROTOCOL_LWS_STATUS,
/* always last */
DEMO_PROTOCOL_COUNT
"dumb-increment-protocol",
callback_dumb_increment,
sizeof(struct per_session_data__dumb_increment),
- 10,
- },
- {
- "lws-mirror-protocol",
- callback_lws_mirror,
- sizeof(struct per_session_data__lws_mirror),
- 128,
+ 10, /* rx buf size must be >= permessage-deflate rx size
+ * dumb-increment only sends very small packets, so we set
+ * this accordingly. If your protocol will send bigger
+ * things, adjust this to match */
},
+ LWS_PLUGIN_PROTOCOL_MIRROR,
+ LWS_PLUGIN_PROTOCOL_LWS_STATUS,
{ NULL, NULL, 0, 0 } /* terminator */
};
{
"permessage-deflate",
lws_extension_callback_pm_deflate,
- "permessage-deflate"
+ "permessage-deflate; client_no_context_takeover; client_max_window_bits"
},
{
"deflate-frame",
{ "port", required_argument, NULL, 'p' },
{ "ssl", no_argument, NULL, 's' },
{ "allow-non-ssl", no_argument, NULL, 'a' },
- { "interface", required_argument, NULL, 'i' },
- { "closetest", no_argument, NULL, 'c' },
+ { "interface", required_argument, NULL, 'i' },
+ { "closetest", no_argument, NULL, 'c' },
{ "libev", no_argument, NULL, 'e' },
{ "threads", required_argument, NULL, 'j' },
#ifndef LWS_NO_DAEMONIZE
- { "daemonize", no_argument, NULL, 'D' },
+ { "daemonize", no_argument, NULL, 'D' },
#endif
{ "resource_path", required_argument, NULL, 'r' },
{ NULL, 0, 0, 0 }
pthread_t pthread_dumb, pthread_service[32];
char cert_path[1024];
char key_path[1024];
- int threads = 1;
+ int threads = 1;
int use_ssl = 0;
void *retval;
int opts = 0;
int n = 0;
#ifndef _WIN32
+/* LOG_PERROR is not POSIX standard, and may not be portable */
+#ifdef __sun
+ int syslog_options = LOG_PID;
+#else
int syslog_options = LOG_PID | LOG_PERROR;
#endif
+#endif
#ifndef LWS_NO_DAEMONIZE
- int daemonize = 0;
+ int daemonize = 0;
#endif
/*
case 'j':
threads = atoi(optarg);
if (threads > ARRAY_SIZE(pthread_service)) {
- lwsl_err("Max threads %d\n",
- ARRAY_SIZE(pthread_service));
+ lwsl_err("Max threads %lu\n",
+ (unsigned long)ARRAY_SIZE(pthread_service));
return 1;
}
break;
#ifndef LWS_NO_DAEMONIZE
case 'D':
daemonize = 1;
- #ifndef _WIN32
+ #if !defined(_WIN32) && !defined(__sun)
syslog_options &= ~LOG_PERROR;
#endif
break;
info.iface = iface;
info.protocols = protocols;
-#ifndef LWS_NO_EXTENSIONS
- info.extensions = lws_get_internal_extensions();
-#endif
+ info.extensions = exts;
info.ssl_cert_filepath = NULL;
info.ssl_private_key_filepath = NULL;
/* wait for all the service threads to exit */
- for (n = 0; n < lws_get_count_threads(context); n++)
+ while ((--n) >= 0)
pthread_join(pthread_service[n], &retval);
/* wait for pthread_dumb to exit */
lws_context_destroy(context);
pthread_mutex_destroy(&lock_established_conns);
-
lwsl_notice("libwebsockets-test-server exited cleanly\n");
#ifndef _WIN32