Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1746420285, "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":"a6191b6b27f2865c9ea76f55920e1547", "commit": {"type":"commit", "time": 1398641534, "time_ofs": 480, "oid_tree": { "oid": "6946fc35e42df249cb17dc6b4dc57424a60b0b9c", "alias": []}, "oid":{ "oid": "7cc7ae476a6e032a27661cc2dc73a6c61b5e5a15", "alias": []}, "msg": "Fix for binding socket to a specific interface (fixes #116) also allow binding to IP address w", "sig_commit": { "git_time": { "time": 1398641534, "offset": 480 }, "name": "Andy Green", "email": "andy.green@linaro.org", "md5": "4863edaebb4491aa6049a4d2d9c98c2c" }, "sig_author": { "git_time": { "time": 1398594735, "offset": 120 }, "name": "vpeter4", "email": "peter.vicman@gmail.com", "md5": "60249b7cb98fd38f4e28a5dd028b20e4" }}, "body": "Fix for binding socket to a specific interface (fixes #116)\n also allow binding to IP address with @iface info.iface \u003d \u0022eth0\u0022; info.iface\n \u003d \u0022192.168.1.5\u0022;\n" , "diff": "diff --git a/lib/lws-plat-unix.c b/lib/lws-plat-unix.c\nindex b0c4a4c..28a7ed5 100644\n--- a/lib/lws-plat-unix.c\n+++ b/lib/lws-plat-unix.c\n@@ -334,6 +334,17 @@ interface_to_sa(struct libwebsocket_context *context,\n \n \tfreeifaddrs(ifr);\n \t\n+\tif (rc \u003d\u003d -1) {\n+\t\t/* check if bind to IP adddress */\n+#ifdef LWS_USE_IPV6\n+\t\tif (inet_pton(AF_INET6, ifname, \u0026addr6-\u003esin6_addr) \u003d\u003d 1)\n+\t\t\trc \u003d 0;\n+\t\telse\n+#endif\n+\t\tif (inet_pton(AF_INET, ifname, \u0026addr-\u003esin_addr) \u003d\u003d 1)\n+\t\t\trc \u003d 0;\n+\t}\n+\n \treturn rc;\n }\n \ndiff --git a/lib/server.c b/lib/server.c\nindex 8d55e96..37ce6a1 100644\n--- a/lib/server.c\n+++ b/lib/server.c\n@@ -78,7 +78,6 @@ int lws_context_init_server(struct lws_context_creation_info *info,\n \t\tbzero((char *) \u0026serv_addr4, sizeof(serv_addr4));\n \t\tserv_addr4.sin_addr.s_addr \u003d INADDR_ANY;\n \t\tserv_addr4.sin_family \u003d AF_INET;\n-\t\tserv_addr4.sin_port \u003d htons(info-\u003eport);\n \n \t\tif (info-\u003eiface) {\n \t\t\tif (interface_to_sa(context, info-\u003eiface,\n@@ -89,6 +88,8 @@ int lws_context_init_server(struct lws_context_creation_info *info,\n \t\t\t\treturn 1;\n \t\t\t}\n \t\t}\n+\n+\t\tserv_addr4.sin_port \u003d htons(info-\u003eport);\n \t} /* ipv4 */\n \n \tn \u003d bind(sockfd, v, n);\n","s":{"c":1746393252,"u": 4666}} ],"g": 655,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "7d0a"}