diff --git a/package/gluon-status-page-api/Makefile b/package/gluon-status-page-api/Makefile deleted file mode 100644 index b27cf07e..00000000 --- a/package/gluon-status-page-api/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -include $(TOPDIR)/rules.mk - -PKG_NAME:=gluon-status-page-api -PKG_VERSION:=1 -PKG_RELEASE:=1 - -PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) -PKG_BUILD_DEPENDS := respondd - -include ../gluon.mk - - -define Package/gluon-status-page-api - SECTION:=gluon - CATEGORY:=Gluon - TITLE:=API for gluon-status-page - DEPENDS:=+gluon-core +uhttpd +sse-multiplex +gluon-neighbour-info +gluon-respondd +libiwinfo +libjson-c +libnl-tiny +libubus-lua +libbatadv -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - -define Build/Compile - $(call Build/Compile/Default) - $(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/) -endef - -define Package/gluon-status-page-api/install - $(INSTALL_DIR) $(1)/lib/gluon/status-page/providers - $(INSTALL_BIN) $(PKG_BUILD_DIR)/neighbours-batadv $(1)/lib/gluon/status-page/providers/ - $(INSTALL_BIN) $(PKG_BUILD_DIR)/stations $(1)/lib/gluon/status-page/providers/ - - $(INSTALL_DIR) $(1)/lib/gluon/respondd - $(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/lib/gluon/respondd/status-page-api.so - - $(CP) ./files/* $(1)/ - $(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/ -endef - -$(eval $(call BuildPackage,gluon-status-page-api)) diff --git a/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/nodeinfo b/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/nodeinfo deleted file mode 100755 index d34381fa..00000000 --- a/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/nodeinfo +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -cat < - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include - - -static struct json_object * respondd_provider_nodeinfo(void) { - struct json_object *ret = json_object_new_object(); - - struct json_object *software = json_object_new_object(); - struct json_object *software_status_page = json_object_new_object(); - json_object_object_add(software_status_page, "api", json_object_new_int(1)); - json_object_object_add(software, "status-page", software_status_page); - json_object_object_add(ret, "software", software); - - return ret; -} - -const struct respondd_provider_info respondd_providers[] = { - {"nodeinfo", respondd_provider_nodeinfo}, - {} -}; diff --git a/package/gluon-status-page/Makefile b/package/gluon-status-page/Makefile index c283f928..d69443a4 100644 --- a/package/gluon-status-page/Makefile +++ b/package/gluon-status-page/Makefile @@ -12,19 +12,20 @@ define Package/gluon-status-page SECTION:=gluon CATEGORY:=Gluon TITLE:=Status page showing information about the node - DEPENDS:=+gluon-web +gluon-status-page-api + DEPENDS:=+gluon-web +gluon-neighbour-info +gluon-respondd +uhttpd +sse-multiplex +libiwinfo +libjson-c +libnl-tiny +libbatadv endef -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) -endef define Build/Compile + $(call Build/Compile/Default) $(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/) $(call GluonBuildI18N,gluon-status-page,i18n) endef define Package/gluon-status-page/install + $(INSTALL_DIR) $(1)/lib/gluon/status-page/providers + $(INSTALL_BIN) $(PKG_BUILD_DIR)/{neighbours-batadv,stations} $(1)/lib/gluon/status-page/providers/ + $(CP) ./files/* $(1)/ $(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/ diff --git a/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-batadv b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-batadv similarity index 73% rename from package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-batadv rename to package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-batadv index 075e8b8b..abd99032 100755 --- a/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-batadv +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-batadv @@ -1,7 +1,5 @@ #!/bin/sh -echo 'Access-Control-Allow-Origin: *' - CMD='exec /lib/gluon/status-page/providers/neighbours-batadv' exec /usr/sbin/sse-multiplex "$CMD" diff --git a/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo similarity index 87% rename from package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo rename to package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo index 657f17e5..b514d236 100755 --- a/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo @@ -6,8 +6,6 @@ badrequest() { exit 1 } -echo 'Access-Control-Allow-Origin: *' - batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" || badrequest exec /usr/bin/gluon-neighbour-info -s neighbour -i "$QUERY_STRING" -d ff02::2:1001 -p 1001 -r nodeinfo diff --git a/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/stations b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations similarity index 87% rename from package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/stations rename to package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations index 258122fb..73dbb44e 100755 --- a/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/stations +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations @@ -6,8 +6,6 @@ badrequest() { exit 1 } -echo 'Access-Control-Allow-Origin: *' - batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" || badrequest CMD="exec /lib/gluon/status-page/providers/stations '$QUERY_STRING'" diff --git a/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/statistics b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/statistics similarity index 75% rename from package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/statistics rename to package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/statistics index ef0dd3d8..502d35ea 100755 --- a/package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/statistics +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/statistics @@ -1,7 +1,5 @@ #!/bin/sh -echo 'Access-Control-Allow-Origin: *' - CMD='exec gluon-neighbour-info -s "" -l -d ::1 -p 1001 -t 3 -r statistics' exec /usr/sbin/sse-multiplex "$CMD" diff --git a/package/gluon-status-page-api/files/usr/lib/autoupdater/abort.d/70gluon-status-page-api b/package/gluon-status-page/files/usr/lib/autoupdater/abort.d/70gluon-status-page similarity index 100% rename from package/gluon-status-page-api/files/usr/lib/autoupdater/abort.d/70gluon-status-page-api rename to package/gluon-status-page/files/usr/lib/autoupdater/abort.d/70gluon-status-page diff --git a/package/gluon-status-page-api/files/usr/lib/autoupdater/download.d/30gluon-status-page-api b/package/gluon-status-page/files/usr/lib/autoupdater/download.d/30gluon-status-page similarity index 100% rename from package/gluon-status-page-api/files/usr/lib/autoupdater/download.d/30gluon-status-page-api rename to package/gluon-status-page/files/usr/lib/autoupdater/download.d/30gluon-status-page diff --git a/package/gluon-status-page/luasrc/lib/gluon/upgrade/500-status-page b/package/gluon-status-page/luasrc/lib/gluon/upgrade/500-status-page new file mode 100755 index 00000000..9771a034 --- /dev/null +++ b/package/gluon-status-page/luasrc/lib/gluon/upgrade/500-status-page @@ -0,0 +1,38 @@ +#!/usr/bin/lua + +local uci = require('simple-uci').cursor() + + +local function get_mem_total() + for line in io.lines('/proc/meminfo') do + local match = line:match('^MemTotal:%s+(%d+)') + if match then + return tonumber(match) + end + end +end + +local max_requests = 32 +if get_mem_total() < 48*1024 then + max_requests = 16 +end + +uci:section('uhttpd', 'uhttpd', 'main', { + listen_http = { '0.0.0.0:80', '[::]:80' }, + listen_https = {}, + + home = '/lib/gluon/status-page/www', + max_requests = max_requests, +}) +uci:save('uhttpd') + + +for _, zone in ipairs({'mesh', 'local_client'}) do + uci:section('firewall', 'rule', zone .. '_http', { + src = zone, + dest_port = '80', + proto = 'tcp', + target = 'ACCEPT', + }) +end +uci:save('firewall') diff --git a/package/gluon-status-page-api/src/Makefile b/package/gluon-status-page/src/Makefile similarity index 91% rename from package/gluon-status-page-api/src/Makefile rename to package/gluon-status-page/src/Makefile index 90f5e714..bf5141a7 100644 --- a/package/gluon-status-page-api/src/Makefile +++ b/package/gluon-status-page/src/Makefile @@ -29,13 +29,10 @@ ifeq ($(origin LIBBATADV_CFLAGS) $(origin LIBBATADV_LDLIBS), undefined undefined LIBBATADV_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBBATADV_NAME)) endif -all: neighbours-batadv stations respondd.so +all: neighbours-batadv stations neighbours-batadv: neighbours-batadv.c $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LIBNL_CFLAGS) $(LIBBATADV_CFLAGS) $(LDFLAGS) $(LDFLAGS_JSONC) $(LIBNL_LDLIBS) $(LIBBATADV_LDLIBS) -Wall -o $@ $^ $(LDLIBS) stations: stations.c $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LDFLAGS) $(LDFLAGS_JSONC) -Wall -o $@ $^ $(LDLIBS) -liwinfo - -respondd.so: respondd.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -fPIC -o $@ $^ $(LDLIBS) diff --git a/package/gluon-status-page-api/src/neighbours-batadv.c b/package/gluon-status-page/src/neighbours-batadv.c similarity index 100% rename from package/gluon-status-page-api/src/neighbours-batadv.c rename to package/gluon-status-page/src/neighbours-batadv.c diff --git a/package/gluon-status-page-api/src/stations.c b/package/gluon-status-page/src/stations.c similarity index 100% rename from package/gluon-status-page-api/src/stations.c rename to package/gluon-status-page/src/stations.c