{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1752648680,
"reponame":"libwebsockets",
"desc":"libwebsockets lightweight C networking library",
"owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets",
"f":3,
"items": [
{"schema":"libjg2-1",
"cid":"641e966a48de125a97173cc05f90e162",
"commit": {"type":"commit",
"time": 1460638756,
"time_ofs": 480,
"oid_tree": { "oid": "5dccc40b5ef4bcf21b35c4bcf658163cfd05b7c3", "alias": []},
"oid":{ "oid": "3c6a8c1a24a61dedfa55f470e92d2a10000441b2", "alias": []},
"msg": "Add unix domain socket",
"sig_commit": { "git_time": { "time": 1460638756, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },
"sig_author": { "git_time": { "time": 1459403222, "offset": -420 }, "name": "Yeonjun Lim", "email": "yjroot@gmail.com", "md5": "0ee151fd38cd10889d38a511d20f5d28" }},
"body": "Add unix domain socket\n"
,
"diff": "diff --git a/CMakeLists.txt b/CMakeLists.txt\nindex b74913e..41ebbc1 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -86,6 +86,7 @@ option(LWS_WITHOUT_EXTENSIONS \u0022Don't compile with extensions\u0022 OFF)\n option(LWS_WITH_LATENCY \u0022Build latency measuring code into the library\u0022 OFF)\n option(LWS_WITHOUT_DAEMONIZE \u0022Don't build the daemonization api\u0022 ON)\n option(LWS_IPV6 \u0022Compile with support for ipv6\u0022 OFF)\n+option(LWS_UNIX_SOCK \u0022Compile with support for UNIX domain socket\u0022 OFF)\n option(LWS_WITH_HTTP2 \u0022Compile with support for http2\u0022 OFF)\n option(LWS_MBED3 \u0022Platform is MBED3\u0022 OFF)\n option(LWS_SSL_SERVER_WITH_ECDH_CERT \u0022Include SSL server use ECDH certificate\u0022 OFF)\n@@ -275,6 +276,10 @@ if (WIN32)\n \t\tset(LWS_IPV6 OFF)\n \t\tmessage(WARNING \u0022IPv6 does not currently work on Windows!\u0022)\n \tendif()\n+ if (LWS_UNIX_SOCK)\n+\t\tset(LWS_UNIX_SOCK OFF)\n+ message(WARNING \u0022Windows does not support UNIX domain sockets\u0022)\n+\tendif()\n else()\n \tset(LWS_OPENSSL_CLIENT_CERTS /etc/pki/tls/certs/ CACHE PATH \u0022Client SSL certificate directory\u0022)\n endif()\n@@ -319,6 +324,10 @@ if (LWS_IPV6)\n \tset(LWS_USE_IPV6 1)\n endif()\n \n+if (LWS_UNIX_SOCK)\n+ set(LWS_USE_UNIX_SOCK 1)\n+endif()\n+\n if (LWS_WITH_HTTP2)\n \tset(LWS_USE_HTTP2 1)\n endif()\n@@ -1434,6 +1443,7 @@ message(\u0022 LWS_WITHOUT_DAEMONIZE \u003d ${LWS_WITHOUT_DAEMONIZE}\u0022)\n message(\u0022 LWS_USE_LIBEV \u003d ${LWS_USE_LIBEV}\u0022)\n message(\u0022 LWS_USE_LIBUV \u003d ${LWS_USE_LIBUV}\u0022)\n message(\u0022 LWS_IPV6 \u003d ${LWS_IPV6}\u0022)\n+message(\u0022 LWS_UNIX_SOCK \u003d ${LWS_UNIX_SOCK}\u0022)\n message(\u0022 LWS_WITH_HTTP2 \u003d ${LWS_WITH_HTTP2}\u0022)\n message(\u0022 LWS_MBED3 \u003d ${LWS_MBED3}\u0022)\n message(\u0022 LWS_SSL_SERVER_WITH_ECDH_CERT \u003d ${LWS_SSL_SERVER_WITH_ECDH_CERT}\u0022)\ndiff --git a/lib/context.c b/lib/context.c\nindex f75be87..7c9250d 100644\n--- a/lib/context.c\n+++ b/lib/context.c\n@@ -278,6 +278,12 @@ lws_create_vhost(struct lws_context *context,\n \n \tvh-\u003emount_list \u003d mounts;\n \n+#ifdef LWS_USE_UNIX_SOCK\n+\tif (LWS_UNIX_SOCK_ENABLED(context)) {\n+\t\tlwsl_notice(\u0022Creating Vhost '%s' path \u005c\u0022%s\u005c\u0022, %d protocols\u005cn\u0022,\n+\t\t\t\tvh-\u003ename, info-\u003eiface, vh-\u003ecount_protocols);\n+\t} else\n+#endif\n \tlwsl_notice(\u0022Creating Vhost '%s' port %d, %d protocols\u005cn\u0022,\n \t\t\tvh-\u003ename, info-\u003eport, vh-\u003ecount_protocols);\n \ndiff --git a/lib/libwebsockets.c b/lib/libwebsockets.c\nindex 5fe0bdc..c99e578 100644\n--- a/lib/libwebsockets.c\n+++ b/lib/libwebsockets.c\n@@ -1489,6 +1489,9 @@ lws_socket_bind(struct lws_context *context, int sockfd, int port,\n \t\tconst char *iface)\n {\n #if LWS_POSIX\n+#ifdef LWS_USE_UNIX_SOCK\n+\tstruct sockaddr_un serv_unix;\n+#endif\n #ifdef LWS_USE_IPV6\n \tstruct sockaddr_in6 serv_addr6;\n #endif\n@@ -1498,6 +1501,20 @@ lws_socket_bind(struct lws_context *context, int sockfd, int port,\n \tstruct sockaddr_in sin;\n \tstruct sockaddr *v;\n \n+#ifdef LWS_USE_UNIX_SOCK\n+\tif (LWS_UNIX_SOCK_ENABLED(context)) {\n+\t\tv \u003d (struct sockaddr *)\u0026serv_unix;\n+\t\tn \u003d sizeof(struct sockaddr_un);\n+\t\tbzero((char *) \u0026serv_unix, sizeof(serv_unix));\n+\t\tserv_unix.sun_family \u003d AF_UNIX;\n+\t\tif (sizeof(serv_unix.sun_path) \u003c\u003d strlen(iface)) {\n+\t\t\tlwsl_err(\u0022\u005c\u0022%s\u005c\u0022 too long for UNIX domain socket\u005cn\u0022,\n+\t\t\t iface);\n+\t\t\treturn -1;\n+\t\t}\n+\t\tstrcpy(serv_unix.sun_path, iface);\n+\t} else\n+#endif\n #ifdef LWS_USE_IPV6\n \tif (LWS_IPV6_ENABLED(context)) {\n \t\tv \u003d (struct sockaddr *)\u0026serv_addr6;\n@@ -1526,6 +1543,13 @@ lws_socket_bind(struct lws_context *context, int sockfd, int port,\n \t} /* ipv4 */\n \n \tn \u003d bind(sockfd, v, n);\n+#ifdef LWS_USE_UNIX_SOCK\n+\tif (n \u003c 0 \u0026\u0026 LWS_UNIX_SOCK_ENABLED(context)) {\n+\t\tlwsl_err(\u0022ERROR on binding fd %d to \u005c\u0022%s\u005c\u0022 (%d %d)\u005cn\u0022,\n+\t\t\t\tsockfd, iface, n, LWS_ERRNO);\n+\t\treturn -1;\n+\t} else\n+#endif\n \tif (n \u003c 0) {\n \t\tlwsl_err(\u0022ERROR on binding fd %d to port %d (%d %d)\u005cn\u0022,\n \t\t\t\tsockfd, port, n, LWS_ERRNO);\ndiff --git a/lib/libwebsockets.h b/lib/libwebsockets.h\nindex 278a584..4d586ff 100644\n--- a/lib/libwebsockets.h\n+++ b/lib/libwebsockets.h\n@@ -332,6 +332,7 @@ enum lws_context_options {\n \t\t\t\t\t\t\t\t (1 \u003c\u003c 12),\n \tLWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT\t\t\t\u003d (1 \u003c\u003c 12),\n \tLWS_SERVER_OPTION_EXPLICIT_VHOSTS\t\t\t\u003d (1 \u003c\u003c 13),\n+\tLWS_SERVER_OPTION_UNIX_SOCK\t\t\t\t\u003d (1 \u003c\u003c 14),\n \n \t/****** add new things just above ---^ ******/\n };\n@@ -1373,6 +1374,8 @@ struct lws_protocol_vhost_options {\n *\t\tclient\n * @iface:\tNULL to bind the listen socket to all interfaces, or the\n *\t\tinterface name, eg, \u0022eth2\u0022\n+ *\t\tIf options specifies LWS_SERVER_OPTION_UNIX_SOCK, this member is\n+ *\t\tthe pathname of a UNIX domain socket.\n * @protocols:\tArray of structures listing supported protocols and a protocol-\n *\t\tspecific callback for each one. The list is ended with an\n *\t\tentry that has a NULL callback pointer.\ndiff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h\nindex 1cab3c1..b6c9bed 100644\n--- a/lib/private-libwebsockets.h\n+++ b/lib/private-libwebsockets.h\n@@ -848,6 +848,12 @@ LWS_EXTERN void lws_feature_status_libuv(struct lws_context_creation_info *info)\n #define LWS_IPV6_ENABLED(context) (0)\n #endif\n \n+#ifdef LWS_USE_UNIX_SOCK\n+#define LWS_UNIX_SOCK_ENABLED(context) \u005c\n+\t(context-\u003eoptions \u0026 LWS_SERVER_OPTION_UNIX_SOCK)\n+#else\n+#define LWS_UNIX_SOCK_ENABLED(context) (0)\n+#endif\n enum uri_path_states {\n \tURIPS_IDLE,\n \tURIPS_SEEN_SLASH,\ndiff --git a/lib/server.c b/lib/server.c\nindex 37a2ea3..b2ea3f6 100644\n--- a/lib/server.c\n+++ b/lib/server.c\n@@ -61,6 +61,11 @@ lws_context_init_server(struct lws_context_creation_info *info,\n #endif\n \n \tfor (m \u003d 0; m \u003c limit; m++) {\n+#ifdef LWS_USE_UNIX_SOCK\n+\tif (LWS_UNIX_SOCK_ENABLED(vhost-\u003econtext))\n+\t\tsockfd \u003d socket(AF_UNIX, SOCK_STREAM, 0);\n+\telse\n+#endif\n #ifdef LWS_USE_IPV6\n \tif (LWS_IPV6_ENABLED(context))\n \t\tsockfd \u003d socket(AF_INET6, SOCK_STREAM, 0);\n@@ -132,8 +137,14 @@ lws_context_init_server(struct lws_context_creation_info *info,\n #else\n \tmbed3_tcp_stream_bind(wsi-\u003esock, info-\u003eport, wsi);\n #endif\n-\tif (!lws_check_opt(info-\u003eoptions, LWS_SERVER_OPTION_EXPLICIT_VHOSTS))\n-\t\tlwsl_notice(\u0022 Listening on port %d\u005cn\u0022, info-\u003eport);\n+\tif (!lws_check_opt(info-\u003eoptions, LWS_SERVER_OPTION_EXPLICIT_VHOSTS)) {\n+#ifdef LWS_USE_UNIX_SOCK\n+\t\tif (LWS_UNIX_SOCK_ENABLED(vhost-\u003econtext))\n+\t\t\tlwsl_notice(\u0022 Listening on \u005c\u0022%s\u005c\u0022\u005cn\u0022, info-\u003eiface);\n+\t\telse\n+#endif\n+\t\t\tlwsl_notice(\u0022 Listening on port %d\u005cn\u0022, info-\u003eport);\n+ }\n \n \treturn 0;\n \ndiff --git a/lws_config.h.in b/lws_config.h.in\nindex 452e969..5e6b206 100644\n--- a/lws_config.h.in\n+++ b/lws_config.h.in\n@@ -52,6 +52,9 @@\n /* Build with support for ipv6 */\n #cmakedefine LWS_USE_IPV6\n \n+/* Build with support for UNIX domain socket */\n+#cmakedefine LWS_USE_UNIX_SOCK\n+\n /* Build with support for HTTP2 */\n #cmakedefine LWS_USE_HTTP2\n \n","s":{"c":1752648680,"u": 9162}}
],"g": 11567,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}