mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-03-14 21:10:11 +01:00
Added haproxy for use with uhttpd
This commit is contained in:
parent
18c46eb2a7
commit
07f3f120df
3 changed files with 304 additions and 0 deletions
140
haproxy/Makefile
Normal file
140
haproxy/Makefile
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
#
|
||||
# Copyright (C) 2010-2013 OpenWrt.org
|
||||
# Copyright (C) 2009-2014 Thomas Heil <heil@terminal-consulting.de>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=haproxy
|
||||
PKG_VERSION:=1.5.14
|
||||
PKG_RELEASE:=00
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/haproxy/haproxy.git
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)
|
||||
PKG_SOURCE_VERSION:=master
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_MAINTAINER:=Thomas Heil <heil@terminal-consulting.de>
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/haproxy/Default
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=The Reliable, High Performance TCP/HTTP Load Balancer
|
||||
URL:=http://haproxy.1wt.eu/
|
||||
endef
|
||||
|
||||
define Package/haproxy/Default/conffiles
|
||||
/etc/haproxy.cfg
|
||||
endef
|
||||
|
||||
define Package/haproxy/Default/description
|
||||
Open source Reliable, High Performance TCP/HTTP Load Balancer.
|
||||
endef
|
||||
|
||||
define Package/haproxy
|
||||
DEPENDS+= +libpcre +libltdl +zlib +libpthread +libopenssl
|
||||
TITLE+= (with SSL support)
|
||||
VARIANT:=ssl
|
||||
$(call Package/haproxy/Default)
|
||||
endef
|
||||
|
||||
define Package/haproxy/conffiles
|
||||
$(call Package/haproxy/Default/conffiles)
|
||||
endef
|
||||
|
||||
define Package/haproxy/description
|
||||
$(call Package/haproxy/Default/description)
|
||||
This package is built with SSL support.
|
||||
endef
|
||||
|
||||
define Package/haproxy-nossl
|
||||
TITLE+= (without SSL support)
|
||||
VARIANT:=nossl
|
||||
DEPENDS+= +libpcre +libltdl +zlib +libpthread
|
||||
TITLE+= (with SSL support)
|
||||
$(call Package/haproxy/Default)
|
||||
endef
|
||||
|
||||
define Package/haproxy-nossl/conffiles
|
||||
$(call Package/haproxy/Default/conffiles)
|
||||
endef
|
||||
|
||||
define Package/haproxy-nossl/description
|
||||
$(call Package/haproxy/Default/description)
|
||||
This package is built without SSL support.
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_avr32),y)
|
||||
LINUX_TARGET:=linux26
|
||||
else
|
||||
LINUX_TARGET:=linux2628
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_VARIANT),ssl)
|
||||
USE_OPENSSL=USE_OPENSSL=1
|
||||
else
|
||||
USE_OPENSSL=
|
||||
endif
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) TARGET=$(LINUX_TARGET) -C $(PKG_BUILD_DIR) \
|
||||
DESTDIR="$(PKG_INSTALL_DIR)" \
|
||||
CC="$(TARGET_CC)" \
|
||||
CFLAGS="$(TARGET_CFLAGS) -fno-align-jumps -fno-align-functions -fno-align-labels -fno-align-loops -pipe -fomit-frame-pointer -fhonour-copts" \
|
||||
LD="$(TARGET_CC)" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
PCREDIR="$(STAGING_DIR)/usr" \
|
||||
SMALL_OPTS="-DBUFSIZE=16384 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=165530 " \
|
||||
USE_LINUX_TPROXY=1 USE_LINUX_SPLICE=1 USE_REGPARM=1 $(USE_OPENSSL) \
|
||||
USE_ZLIB=yes USE_PCRE=1 \
|
||||
VERSION="$(PKG_VERSION)-patch$(PKG_RELEASE)" \
|
||||
install
|
||||
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)/contrib/halog \
|
||||
CC="$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS)" \
|
||||
OPTIMIZE="" \
|
||||
halog
|
||||
endef
|
||||
|
||||
define Package/haproxy/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/haproxy $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_CONF) ./files/haproxy.cfg $(1)/etc/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/haproxy.init $(1)/etc/init.d/haproxy
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/net
|
||||
$(INSTALL_BIN) ./files/haproxy.hotplug $(1)/etc/hotplug.d/net/90-haproxy
|
||||
endef
|
||||
|
||||
Package/haproxy-nossl/install = $(Package/haproxy/install)
|
||||
|
||||
define Package/halog
|
||||
MENU:=1
|
||||
$(call Package/haproxy/Default)
|
||||
TITLE+= halog
|
||||
DEPENDS:=haproxy
|
||||
endef
|
||||
|
||||
define Package/halog/description
|
||||
HAProxy Log Analyzer
|
||||
endef
|
||||
|
||||
define Package/halog/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/contrib/halog/halog $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,haproxy-nossl))
|
||||
$(eval $(call BuildPackage,haproxy))
|
||||
$(eval $(call BuildPackage,halog))
|
||||
108
libpcre/Makefile
Normal file
108
libpcre/Makefile
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
#
|
||||
# Copyright (C) 2006-2015 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=pcre
|
||||
PKG_VERSION:=8.37
|
||||
PKG_RELEASE:=2
|
||||
|
||||
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/vmg/libpcre.git
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)
|
||||
PKG_SOURCE_VERSION:=master
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_MAINTAINER:=Thomas Heil <heil@terminal-consulting.de>
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=LICENCE
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/libpcre/default
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
URL:=http://www.pcre.org/
|
||||
endef
|
||||
|
||||
define Package/libpcre
|
||||
$(call Package/libpcre/default)
|
||||
TITLE:=A Perl Compatible Regular Expression library
|
||||
endef
|
||||
|
||||
define Package/libpcre16
|
||||
$(call Package/libpcre/default)
|
||||
TITLE:=A Perl Compatible Regular Expression library (16bit support)
|
||||
endef
|
||||
|
||||
define Package/libpcrecpp
|
||||
$(call Package/libpcre/default)
|
||||
TITLE:=C++ wrapper for Perl Compatible Regular Expression library
|
||||
DEPENDS:=+libpcre +libstdcpp
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += $(FPIC)
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-utf8 \
|
||||
--enable-unicode-properties \
|
||||
--enable-pcre16 \
|
||||
|
||||
ifneq ($(CONFIG_PACKAGE_libpcrecpp),)
|
||||
CONFIGURE_ARGS+= --enable-cpp
|
||||
else
|
||||
CONFIGURE_ARGS+= --disable-cpp
|
||||
endif
|
||||
|
||||
MAKE_FLAGS += \
|
||||
CFLAGS="$(TARGET_CFLAGS)"
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/pcre-config $(1)/usr/bin/
|
||||
|
||||
$(INSTALL_DIR) $(2)/bin
|
||||
$(LN) $(STAGING_DIR)/usr/bin/pcre-config $(2)/bin
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/pcre*.h $(1)/usr/include/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre*.{a,so*} $(1)/usr/lib/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libpcre*.pc $(1)/usr/lib/pkgconfig/
|
||||
endef
|
||||
|
||||
define Package/libpcre/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre{,posix}.so.* $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre.so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libpcre16/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre16.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libpcrecpp/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcrecpp.so.* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libpcre))
|
||||
$(eval $(call BuildPackage,libpcre16))
|
||||
$(eval $(call BuildPackage,libpcrecpp))
|
||||
|
|
@ -800,6 +800,61 @@ router_dump_keys(struct blob_buf *b, bool table)
|
|||
if (table) blobmsg_close_table(b, t);
|
||||
}
|
||||
|
||||
static int uci_get_value(const char *config_path, const char *varname, char *output, size_t out_size){
|
||||
FILE *fp;
|
||||
char cmd[256], buffer[256];
|
||||
char *ptr = output;
|
||||
snprintf(cmd, sizeof(cmd), "uci -c %s get %s", config_path, varname);
|
||||
|
||||
if(!(fp = popen(cmd, "r"))) return 0;
|
||||
|
||||
int len;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
||||
while(len = fgets(buffer, sizeof(buffer), fp)){
|
||||
if(len > 0) {
|
||||
remove_newline(buffer);
|
||||
strcpy(ptr, buffer);
|
||||
ptr += len;
|
||||
}
|
||||
if(len >= (out_size - (ptr - output))) break;
|
||||
}
|
||||
|
||||
pclose(fp);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static void router_dump_boardinfo(struct blob_buf *b){
|
||||
void *t, *l, *p;
|
||||
static char ports[256], port_order[256], lan_ports[256], wan_ports[256];
|
||||
|
||||
t = blobmsg_open_table(b, "ethernet");
|
||||
//p = blobmsg_open_array(b, "ports");
|
||||
uci_get_value("/lib/db/config", "hw.board.ethernetPortNames", ports, sizeof(ports));
|
||||
uci_get_value("/lib/db/config", "hw.board.ethernetPortOrder", port_order, sizeof(port_order));
|
||||
uci_get_value("/lib/db/config", "hw.board.ethernetLanPorts", lan_ports, sizeof(lan_ports));
|
||||
uci_get_value("/lib/db/config", "hw.board.ethernetWanPort", wan_ports, sizeof(wan_ports));
|
||||
blobmsg_add_string(b, "port_names", ports);
|
||||
blobmsg_add_string(b, "port_order", port_order);
|
||||
blobmsg_add_string(b, "lan_ports", lan_ports);
|
||||
blobmsg_add_string(b, "wan_port", wan_ports);
|
||||
//blobmsg_close_array(b, p);
|
||||
blobmsg_close_table(b, t);
|
||||
}
|
||||
|
||||
static int
|
||||
quest_board_info(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
blob_buf_init(&bb, 0);
|
||||
router_dump_boardinfo(&bb);
|
||||
ubus_send_reply(ctx, req, bb.head);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
router_dump_system_info(struct blob_buf *b, bool table)
|
||||
{
|
||||
|
|
@ -1679,6 +1734,7 @@ quest_reload(struct ubus_context *ctx, struct ubus_object *obj,
|
|||
|
||||
static struct ubus_method router_object_methods[] = {
|
||||
UBUS_METHOD_NOARG("info", quest_router_info),
|
||||
UBUS_METHOD_NOARG("boardinfo", quest_board_info),
|
||||
UBUS_METHOD("quest", quest_router_specific, quest_policy),
|
||||
UBUS_METHOD_NOARG("networks", quest_router_networks),
|
||||
UBUS_METHOD_NOARG("dslstats", dslstats_rpc),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue