summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/http.cc25
-rw-r--r--src/muniad.cc26
2 files changed, 36 insertions, 15 deletions
diff --git a/src/http.cc b/src/http.cc
index 396e042..f00cbb7 100644
--- a/src/http.cc
+++ b/src/http.cc
@@ -35,17 +35,20 @@
int callback_http(struct libwebsocket_context * context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
- void *in, size_t len)
+ void *i, size_t len)
{
- char client_name[128];
- char client_ip[128];
+ char *in = (char*)i;
+ // char client_name[128];
+ // char client_ip[128];
switch(reason) {
case LWS_CALLBACK_HTTP:
DEBUG(httpd,"serving HTTP URI %s\n", (char *)in);
-//
+
+ while(*in == '/') in++; // skip trailing slashes
+
// add favicon later
- if(in && strcmp((const char *)in, "/favicon.ico") == 0) {
+ if(in && strcmp((const char *)in, "favicon.ico") == 0) {
if(libwebsockets_serve_http_file(context, wsi,
LOCAL_RESOURCE_PATH"/favicon.ico",
"image/x-icon"))
@@ -54,7 +57,7 @@ int callback_http(struct libwebsocket_context * context,
}
// css
- if(in && strcmp((const char *)in, "/munia.css") == 0) {
+ if(in && strcmp((const char *)in, "munia.css") == 0) {
if(libwebsockets_serve_http_file(context, wsi,
LOCAL_RESOURCE_PATH"/munia.css",
"text/css"))
@@ -63,7 +66,7 @@ int callback_http(struct libwebsocket_context * context,
}
// script
- if(in && strcmp((const char *)in, "/proto.js") == 0) {
+ if(in && strcmp((const char *)in, "proto.js") == 0) {
if(libwebsockets_serve_http_file(context, wsi,
LOCAL_RESOURCE_PATH"/proto.js",
"text/javascript"))
@@ -71,7 +74,7 @@ int callback_http(struct libwebsocket_context * context,
break;
}
- if(in && strcmp((const char *)in, "/handler.js") == 0) {
+ if(in && strcmp((const char *)in, "handler.js") == 0) {
if(libwebsockets_serve_http_file(context, wsi,
LOCAL_RESOURCE_PATH"/handler.js",
"text/javascript"))
@@ -79,7 +82,7 @@ int callback_http(struct libwebsocket_context * context,
break;
}
- if(in && strcmp((const char *)in, "/view.js") == 0) {
+ if(in && strcmp((const char *)in, "view.js") == 0) {
if(libwebsockets_serve_http_file(context, wsi,
LOCAL_RESOURCE_PATH"/view.js",
"text/javascript"))
@@ -87,7 +90,7 @@ int callback_http(struct libwebsocket_context * context,
break;
}
- if(in && strcmp((const char *)in, "/task.js") == 0) {
+ if(in && strcmp((const char *)in, "task.js") == 0) {
if(libwebsockets_serve_http_file(context, wsi,
LOCAL_RESOURCE_PATH"/task.js",
"text/javascript"))
@@ -112,6 +115,7 @@ int callback_http(struct libwebsocket_context * context,
*/
case LWS_CALLBACK_FILTER_NETWORK_CONNECTION:
+ /*
libwebsockets_get_peer_addresses((int)(long)user,
client_name,
sizeof(client_name),
@@ -119,6 +123,7 @@ int callback_http(struct libwebsocket_context * context,
sizeof(client_ip));
DEBUG(httpd,"Received network connect from %s (%s)\n",
client_name, client_ip);
+ */
/* if we returned non-zero from here, we kill the connection */
break;
diff --git a/src/muniad.cc b/src/muniad.cc
index ebf0870..995bb67 100644
--- a/src/muniad.cc
+++ b/src/muniad.cc
@@ -96,7 +96,7 @@ int main(int argc, char **argv)
// case 'd':
// dumpfile = optarg;
case 'k':
- opts = LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK;
+ //opts = LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK;
break;
case 'p':
port = atoi(optarg);
@@ -121,10 +121,26 @@ int main(int argc, char **argv)
if(!use_ssl) cert_path = key_path = NULL;
- context = libwebsocket_create_context(port, interface, protocols,
- libwebsocket_internal_extensions,
- cert_path, key_path, "", -1, -1, opts,
- NULL);
+ struct lws_context_creation_info info;
+ memset(&info, 0, sizeof info);
+ info.port = port;
+ info.iface = interface;
+ info.protocols = protocols;
+ info.extensions = libwebsocket_get_internal_extensions();
+
+ //if (!use_ssl) {
+ info.ssl_cert_filepath = cert_path;
+ info.ssl_private_key_filepath = NULL;
+ //} else {
+ // info.ssl_cert_filepath = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem";
+ // info.ssl_private_key_filepath = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem";
+//}
+
+ info.gid = -1;
+ info.uid = -1;
+ info.options = opts;
+
+ context = libwebsocket_create_context(&info);
if (context == NULL) {
fprintf(stderr, "libwebsocket init failed\n");
return -1;