mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
Merge remote-tracking branch 'upstream/master'
Updated to latest trunk
This commit is contained in:
@@ -0,0 +1,203 @@
|
||||
#
|
||||
# Copyright (C) 2006-2012 OpenWrt.org
|
||||
# 2014 Noah Meyerhans <frodo@morgul.net>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=bind
|
||||
PKG_VERSION:=9.9.5-P1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER := Noah Meyerhans <frodo@morgul.net>
|
||||
PKG_LICENSE := BSD-3-Clause
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:= \
|
||||
ftp://ftp.isc.org/isc/bind9/$(PKG_VERSION) \
|
||||
http://www.mirrorservice.org/sites/ftp.isc.org/isc/bind9/$(PKG_VERSION)
|
||||
PKG_MD5SUM:=3408af8c6d27d6cb8a05287f2ee32ad0
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_REMOVE_FILES:=aclocal.m4 libtool.m4
|
||||
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/bind/Default
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+bind-libs
|
||||
TITLE:=bind
|
||||
URL:=https://www.isc.org/software/bind
|
||||
SUBMENU:=IP Addresses and Names
|
||||
endef
|
||||
|
||||
define Package/bind-libs
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
DEPENDS:=+libopenssl
|
||||
TITLE:=bind shared libraries
|
||||
URL:=https://www.isc.org/software/bind
|
||||
endef
|
||||
|
||||
define Package/bind-server
|
||||
$(call Package/bind/Default)
|
||||
TITLE+= DNS server
|
||||
endef
|
||||
|
||||
define Package/bind-client
|
||||
$(call Package/bind/Default)
|
||||
TITLE+= dynamic DNS client
|
||||
endef
|
||||
|
||||
define Package/bind-tools
|
||||
$(call Package/bind/Default)
|
||||
TITLE+= administration tools (all)
|
||||
endef
|
||||
|
||||
define Package/bind-rndc
|
||||
$(call Package/bind/Default)
|
||||
TITLE+= administration tools (rndc and rndc-confgen only)
|
||||
endef
|
||||
|
||||
define Package/bind-check
|
||||
$(call Package/bind/Default)
|
||||
TITLE+= administration tools (named-checkconf and named-checkzone only)
|
||||
endef
|
||||
|
||||
define Package/bind-dnssec
|
||||
$(call Package/bind/Default)
|
||||
TITLE+= administration tools (dnssec-keygen and dnssec-signzone only)
|
||||
endef
|
||||
|
||||
define Package/bind-host
|
||||
$(call Package/bind/Default)
|
||||
TITLE+= simple DNS client
|
||||
endef
|
||||
|
||||
define Package/bind-dig
|
||||
$(call Package/bind/Default)
|
||||
TITLE+= DNS excavation tool
|
||||
endef
|
||||
|
||||
export BUILD_CC="$(TARGET_CC)"
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-shared \
|
||||
--enable-static \
|
||||
--with-randomdev="/dev/urandom" \
|
||||
--disable-threads \
|
||||
--disable-linux-caps \
|
||||
--with-openssl="$(STAGING_DIR)/usr" \
|
||||
--with-libtool \
|
||||
--with-libxml2=no \
|
||||
--enable-epoll=yes \
|
||||
--with-gost=no \
|
||||
--with-gssapi=no \
|
||||
--with-ecdsa=no \
|
||||
--with-readline=no
|
||||
|
||||
CONFIGURE_VARS += \
|
||||
BUILD_CC="$(TARGET_CC)" \
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)/lib/dns \
|
||||
BUILD_CC="$(HOSTCC)" \
|
||||
CC="$(HOSTCC)" \
|
||||
CFLAGS="-O2" \
|
||||
LIBS="" \
|
||||
gen
|
||||
$(call Build/Compile/Default)
|
||||
endef
|
||||
|
||||
define Package/bind-libs/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib
|
||||
endef
|
||||
|
||||
define Package/bind-server/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/named $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc/bind
|
||||
$(CP) \
|
||||
./files/bind/db.0 \
|
||||
./files/bind/db.127 \
|
||||
./files/bind/db.255 \
|
||||
./files/bind/db.local \
|
||||
./files/bind/db.root \
|
||||
$(1)/etc/bind/
|
||||
$(CP) ./files/bind/named.conf.example $(1)/etc/bind/named.conf
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/named.init $(1)/etc/init.d/named
|
||||
find $(1)/etc/bind/ -name ".svn" | xargs rm -rf
|
||||
endef
|
||||
|
||||
define Package/bind-server/conffiles
|
||||
/etc/bind/db.0
|
||||
/etc/bind/db.127
|
||||
/etc/bind/db.255
|
||||
/etc/bind/db.local
|
||||
/etc/bind/db.root
|
||||
/etc/bind/named.conf
|
||||
endef
|
||||
|
||||
define Package/bind-client/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/nsupdate $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
define Package/bind-tools/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dig $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/host $(1)/usr/bin/
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/dnssec-keygen $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/dnssec-signzone $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/named-checkconf $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/named-checkzone $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/rndc $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/rndc-confgen $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
define Package/bind-rndc/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/rndc $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/rndc-confgen $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
define Package/bind-check/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/named-checkconf $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/named-checkzone $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
define Package/bind-dnssec/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/dnssec-keygen $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/dnssec-signzone $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
define Package/bind-host/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/host $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
define Package/bind-dig/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dig $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,bind-libs))
|
||||
$(eval $(call BuildPackage,bind-server))
|
||||
$(eval $(call BuildPackage,bind-client))
|
||||
$(eval $(call BuildPackage,bind-tools))
|
||||
$(eval $(call BuildPackage,bind-rndc))
|
||||
$(eval $(call BuildPackage,bind-check))
|
||||
$(eval $(call BuildPackage,bind-dnssec))
|
||||
$(eval $(call BuildPackage,bind-host))
|
||||
$(eval $(call BuildPackage,bind-dig))
|
||||
@@ -0,0 +1,12 @@
|
||||
;
|
||||
; BIND reverse data file for broadcast zone
|
||||
;
|
||||
$TTL 604800
|
||||
@ IN SOA localhost. root.localhost. (
|
||||
1 ; Serial
|
||||
604800 ; Refresh
|
||||
86400 ; Retry
|
||||
2419200 ; Expire
|
||||
604800 ) ; Negative Cache TTL
|
||||
;
|
||||
@ IN NS localhost.
|
||||
@@ -0,0 +1,13 @@
|
||||
;
|
||||
; BIND reverse data file for local loopback interface
|
||||
;
|
||||
$TTL 604800
|
||||
@ IN SOA localhost. root.localhost. (
|
||||
1 ; Serial
|
||||
604800 ; Refresh
|
||||
86400 ; Retry
|
||||
2419200 ; Expire
|
||||
604800 ) ; Negative Cache TTL
|
||||
;
|
||||
@ IN NS localhost.
|
||||
1.0.0 IN PTR localhost.
|
||||
@@ -0,0 +1,12 @@
|
||||
;
|
||||
; BIND reverse data file for broadcast zone
|
||||
;
|
||||
$TTL 604800
|
||||
@ IN SOA localhost. root.localhost. (
|
||||
1 ; Serial
|
||||
604800 ; Refresh
|
||||
86400 ; Retry
|
||||
2419200 ; Expire
|
||||
604800 ) ; Negative Cache TTL
|
||||
;
|
||||
@ IN NS localhost.
|
||||
@@ -0,0 +1,13 @@
|
||||
;
|
||||
; BIND data file for local loopback interface
|
||||
;
|
||||
$TTL 604800
|
||||
@ IN SOA localhost. root.localhost. (
|
||||
1 ; Serial
|
||||
604800 ; Refresh
|
||||
86400 ; Retry
|
||||
2419200 ; Expire
|
||||
604800 ) ; Negative Cache TTL
|
||||
;
|
||||
@ IN NS localhost.
|
||||
@ IN A 127.0.0.1
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
; <<>> DiG 9.2.3 <<>> ns . @a.root-servers.net.
|
||||
;; global options: printcmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18944
|
||||
;; flags: qr aa rd; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 13
|
||||
|
||||
;; QUESTION SECTION:
|
||||
;. IN NS
|
||||
|
||||
;; ANSWER SECTION:
|
||||
. 518400 IN NS A.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS B.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS C.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS D.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS E.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS F.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS G.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS H.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS I.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS J.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS K.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS L.ROOT-SERVERS.NET.
|
||||
. 518400 IN NS M.ROOT-SERVERS.NET.
|
||||
|
||||
;; ADDITIONAL SECTION:
|
||||
A.ROOT-SERVERS.NET. 3600000 IN A 198.41.0.4
|
||||
B.ROOT-SERVERS.NET. 3600000 IN A 192.228.79.201
|
||||
C.ROOT-SERVERS.NET. 3600000 IN A 192.33.4.12
|
||||
D.ROOT-SERVERS.NET. 3600000 IN A 128.8.10.90
|
||||
E.ROOT-SERVERS.NET. 3600000 IN A 192.203.230.10
|
||||
F.ROOT-SERVERS.NET. 3600000 IN A 192.5.5.241
|
||||
G.ROOT-SERVERS.NET. 3600000 IN A 192.112.36.4
|
||||
H.ROOT-SERVERS.NET. 3600000 IN A 128.63.2.53
|
||||
I.ROOT-SERVERS.NET. 3600000 IN A 192.36.148.17
|
||||
J.ROOT-SERVERS.NET. 3600000 IN A 192.58.128.30
|
||||
K.ROOT-SERVERS.NET. 3600000 IN A 193.0.14.129
|
||||
L.ROOT-SERVERS.NET. 3600000 IN A 199.7.83.42
|
||||
M.ROOT-SERVERS.NET. 3600000 IN A 202.12.27.33
|
||||
|
||||
;; Query time: 81 msec
|
||||
;; SERVER: 198.41.0.4#53(a.root-servers.net.)
|
||||
;; WHEN: Sun Feb 1 11:27:14 2004
|
||||
;; MSG SIZE rcvd: 436
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// This is the primary configuration file for the BIND DNS server named.
|
||||
|
||||
options {
|
||||
directory "/tmp";
|
||||
|
||||
// If your ISP provided one or more IP addresses for stable
|
||||
// nameservers, you probably want to use them as forwarders.
|
||||
// Uncomment the following block, and insert the addresses replacing
|
||||
// the all-0's placeholder.
|
||||
|
||||
// forwarders {
|
||||
// 0.0.0.0;
|
||||
// };
|
||||
|
||||
auth-nxdomain no; # conform to RFC1035
|
||||
};
|
||||
|
||||
// prime the server with knowledge of the root servers
|
||||
zone "." {
|
||||
type hint;
|
||||
file "/etc/bind/db.root";
|
||||
};
|
||||
|
||||
// be authoritative for the localhost forward and reverse zones, and for
|
||||
// broadcast zones as per RFC 1912
|
||||
|
||||
zone "localhost" {
|
||||
type master;
|
||||
file "/etc/bind/db.local";
|
||||
};
|
||||
|
||||
zone "127.in-addr.arpa" {
|
||||
type master;
|
||||
file "/etc/bind/db.127";
|
||||
};
|
||||
|
||||
zone "0.in-addr.arpa" {
|
||||
type master;
|
||||
file "/etc/bind/db.0";
|
||||
};
|
||||
|
||||
zone "255.in-addr.arpa" {
|
||||
type master;
|
||||
file "/etc/bind/db.255";
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
START=50
|
||||
|
||||
config_file=/etc/bind/named.conf
|
||||
pid_file=/var/run/named/named.pid
|
||||
|
||||
start() {
|
||||
if [ -e $pid_file ]
|
||||
then
|
||||
echo " named already running with PID `cat $pid_file`"
|
||||
return 1
|
||||
fi
|
||||
echo Starting isc-bind
|
||||
|
||||
/usr/sbin/named -c $config_file
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo " isc-bind failed to start"
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo "Stopping isc-bind"
|
||||
if [ -e $pid_file ]
|
||||
then
|
||||
kill `cat $pid_file`
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo " PID " `cat $pid_file` not found
|
||||
echo " Is the named server running?"
|
||||
fi
|
||||
|
||||
rm -f $pid_file
|
||||
|
||||
else
|
||||
echo " $pid_file not found"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
Index: bind-9.9.4/bin/Makefile.in
|
||||
===================================================================
|
||||
--- bind-9.9.4.orig/bin/Makefile.in
|
||||
+++ bind-9.9.4/bin/Makefile.in
|
||||
@@ -19,7 +19,7 @@ srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
-SUBDIRS = named rndc dig dnssec tools tests nsupdate \
|
||||
+SUBDIRS = named rndc dig dnssec tools nsupdate \
|
||||
check confgen @PYTHON_TOOLS@ @PKCS11_TOOLS@
|
||||
TARGETS =
|
||||
|
||||
Index: bind-9.9.4/lib/Makefile.in
|
||||
===================================================================
|
||||
--- bind-9.9.4.orig/lib/Makefile.in
|
||||
+++ bind-9.9.4/lib/Makefile.in
|
||||
@@ -23,7 +23,7 @@ top_srcdir = @top_srcdir@
|
||||
# Attempt to disable parallel processing.
|
||||
.NOTPARALLEL:
|
||||
.NO_PARALLEL:
|
||||
-SUBDIRS = isc isccc dns isccfg bind9 lwres tests
|
||||
+SUBDIRS = isc isccc dns isccfg bind9 lwres
|
||||
TARGETS =
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
@@ -3,6 +3,7 @@ include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=ddns-scripts
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_RELEASE:=23
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#
|
||||
# Copyright (C) 2009-2012 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:=dmapd
|
||||
PKG_VERSION:=0.0.70
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=W. Michael Petullo <mike@flyn.org>
|
||||
|
||||
PKG_LICENSE:=GPLv2
|
||||
PKG_LICENSE_FILE:=COPYING
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.flyn.org/projects/dmapd
|
||||
PKG_MD5SUM:=f503bf95f79b5c1f9418cccf26203952
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_INSTALL:=2
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/nls.mk
|
||||
|
||||
define Package/dmapd
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+libdmapsharing +libdb47 +vips
|
||||
TITLE:= dmapd
|
||||
URL:=http://www.flyn.org/projects/dmapd/
|
||||
endef
|
||||
|
||||
define Package/dmapd/decription
|
||||
Dmapd is a DMAP server
|
||||
endef
|
||||
|
||||
define Package/dmapd/conffiles
|
||||
/etc/dmapd.conf
|
||||
endef
|
||||
|
||||
TARGET_LDFLAGS+=\
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
|
||||
define Package/dmapd/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/distro/dmapd.conf $(1)/etc/
|
||||
$(INSTALL_BIN) ./files/dmapd.init $(1)/etc/init.d/dmapd
|
||||
$(INSTALL_DIR) $(1)/usr/lib/dmapd/$(PKG_VERSION)/modules
|
||||
$(CP) \
|
||||
$(PKG_INSTALL_DIR)/usr/sbin/dmapd \
|
||||
$(1)/usr/sbin/
|
||||
$(CP) \
|
||||
$(PKG_INSTALL_DIR)/usr/lib/libdmapd.so* \
|
||||
$(1)/usr/lib/
|
||||
$(CP) \
|
||||
$(PKG_INSTALL_DIR)/usr/lib/dmapd/$(PKG_VERSION)/modules/*.so \
|
||||
$(1)/usr/lib/dmapd/$(PKG_VERSION)/modules/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,dmapd))
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2009-2012 OpenWrt.org
|
||||
|
||||
START=60
|
||||
|
||||
start() {
|
||||
user_exists dmapd 56 || user_add dmapd 56
|
||||
group_exists dmapd 56 || group_add dmapd 56
|
||||
[ -d /var/run/dmapd ] || {
|
||||
mkdir -m 0755 -p /var/run/dmapd
|
||||
chown dmapd:dmapd /var/run/dmapd
|
||||
}
|
||||
[ -d /var/db/dmapd/DAAP ] || {
|
||||
mkdir -m 0755 -p /var/db/dmapd/DAAP
|
||||
chown dmapd:dmapd /var/db/dmapd/DAAP
|
||||
}
|
||||
[ -d /var/db/dmapd/DPAP ] || {
|
||||
mkdir -m 0755 -p /var/db/dmapd/DPAP
|
||||
chown dmapd:dmapd /var/db/dmapd/DPAP
|
||||
}
|
||||
mkdir -m 0755 -p /var/lock/subsys
|
||||
mkdir -m 0755 -p /var/media/music
|
||||
mkdir -m 0755 -p /var/media/pictures
|
||||
|
||||
service_start /usr/sbin/dmapd -u dmapd -g dmapd -m /var/media/music -p /var/media/pictures --vips-disc-threshold 64k
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /usr/sbin/dmapd
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/distro/dmapd.conf
|
||||
+++ b/distro/dmapd.conf
|
||||
@@ -3,7 +3,7 @@
|
||||
Database-Dir=/var/db/dmapd
|
||||
|
||||
# Name that will be used to identify share:
|
||||
-Share-Name=dmapd
|
||||
+Share-Name=OpenWrt
|
||||
|
||||
# User that dmapd will run as, current user if undefined:
|
||||
User=dmapd
|
||||
@@ -8,13 +8,16 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ethtool
|
||||
PKG_VERSION:=3.14
|
||||
PKG_VERSION:=3.15
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Matthias Schiffer <mschiffer@universe-factory.net>
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=@KERNEL/software/network/ethtool
|
||||
PKG_MD5SUM:=d46b809ddd672b51d7e23787ae9122e0
|
||||
PKG_MD5SUM:=e7bf0c355d2bf6ee281ebc713c5fb987
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_LICENSE_FILE:=COPYING
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_INSTALL:=1
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
--- a/Makefile.am
|
||||
+++ b/Makefile.am
|
||||
@@ -13,7 +13,7 @@ ethtool_SOURCES += \
|
||||
fec_8xx.c ibm_emac.c ixgb.c ixgbe.c natsemi.c \
|
||||
pcnet32.c realtek.c tg3.c marvell.c vioc.c \
|
||||
smsc911x.c at76c50x-usb.c sfc.c stmmac.c \
|
||||
- sfpid.c sfpdiag.c ixgbevf.c
|
||||
+ sfpid.c sfpdiag.c ixgbevf.c ixp4xx.c
|
||||
endif
|
||||
|
||||
TESTS = test-cmdline test-features
|
||||
--- a/ethtool.c
|
||||
+++ b/ethtool.c
|
||||
@@ -894,6 +894,7 @@ static const struct {
|
||||
{ "ixgb", ixgb_dump_regs },
|
||||
{ "ixgbe", ixgbe_dump_regs },
|
||||
{ "ixgbevf", ixgbevf_dump_regs },
|
||||
+ { "ixp4xx", ixp4xx_dump_regs },
|
||||
{ "natsemi", natsemi_dump_regs },
|
||||
{ "e100", e100_dump_regs },
|
||||
{ "amd8111e", amd8111e_dump_regs },
|
||||
--- a/internal.h
|
||||
+++ b/internal.h
|
||||
@@ -243,6 +243,9 @@ int st_gmac_dump_regs(struct ethtool_drv
|
||||
/* Et131x ethernet controller */
|
||||
int et131x_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
|
||||
|
||||
+/* Intel IXP4xx internal MAC */
|
||||
+int ixp4xx_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
|
||||
+
|
||||
/* Rx flow classification */
|
||||
int rxclass_parse_ruleopts(struct cmd_context *ctx,
|
||||
struct ethtool_rx_flow_spec *fsp);
|
||||
--- /dev/null
|
||||
+++ b/ixp4xx.c
|
||||
@@ -0,0 +1,130 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2006 Christian Hohnstaed <chohnstaedt@innominate.com>
|
||||
+ * This file is released under the GPLv2
|
||||
+ */
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include "internal.h"
|
||||
+
|
||||
+#ifndef BIT
|
||||
+#define BIT(x) (1<<x)
|
||||
+#endif
|
||||
+
|
||||
+#define TX_CNTRL1_TX_EN BIT(0)
|
||||
+#define TX_CNTRL1_DUPLEX BIT(1)
|
||||
+#define TX_CNTRL1_RETRY BIT(2)
|
||||
+#define TX_CNTRL1_PAD_EN BIT(3)
|
||||
+#define TX_CNTRL1_FCS_EN BIT(4)
|
||||
+#define TX_CNTRL1_2DEFER BIT(5)
|
||||
+#define TX_CNTRL1_RMII BIT(6)
|
||||
+
|
||||
+/* TX Control Register 2 */
|
||||
+#define TX_CNTRL2_RETRIES_MASK 0xf
|
||||
+
|
||||
+/* RX Control Register 1 */
|
||||
+#define RX_CNTRL1_RX_EN BIT(0)
|
||||
+#define RX_CNTRL1_PADSTRIP_EN BIT(1)
|
||||
+#define RX_CNTRL1_CRC_EN BIT(2)
|
||||
+#define RX_CNTRL1_PAUSE_EN BIT(3)
|
||||
+#define RX_CNTRL1_LOOP_EN BIT(4)
|
||||
+#define RX_CNTRL1_ADDR_FLTR_EN BIT(5)
|
||||
+#define RX_CNTRL1_RX_RUNT_EN BIT(6)
|
||||
+#define RX_CNTRL1_BCAST_DIS BIT(7)
|
||||
+
|
||||
+/* Core Control Register */
|
||||
+#define CORE_RESET BIT(0)
|
||||
+#define CORE_RX_FIFO_FLUSH BIT(1)
|
||||
+#define CORE_TX_FIFO_FLUSH BIT(2)
|
||||
+#define CORE_SEND_JAM BIT(3)
|
||||
+#define CORE_MDC_EN BIT(4)
|
||||
+
|
||||
+#define MAC "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
+#define MAC_DATA(d) (d)[0], (d)[1], (d)[2], (d)[3], (d)[4], (d)[5]
|
||||
+
|
||||
+int ixp4xx_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
|
||||
+{
|
||||
+ u8 *data = regs->data;
|
||||
+
|
||||
+ fprintf(stdout,
|
||||
+ "TXctrl: 0x%02x:0x%02x\n"
|
||||
+ " Enable: %s\n"
|
||||
+ " Duplex: %s\n"
|
||||
+ " Retry: %s (%d)\n"
|
||||
+ " Padding: %s\n"
|
||||
+ " Frame check: %s\n"
|
||||
+ " TX deferral: %s\n"
|
||||
+ " Connection: %s\n"
|
||||
+ "\n",
|
||||
+ data[0], data[1],
|
||||
+ data[0] & TX_CNTRL1_TX_EN ? "yes" : "no",
|
||||
+ data[0] & TX_CNTRL1_DUPLEX ? "half" : "full",
|
||||
+ data[0] & TX_CNTRL1_RETRY ? "enabled" : "disabled",
|
||||
+ data[1] & TX_CNTRL2_RETRIES_MASK,
|
||||
+ data[0] & TX_CNTRL1_PAD_EN ? "enabled" : "disabled",
|
||||
+ data[0] & TX_CNTRL1_FCS_EN ? "enabled" : "disabled",
|
||||
+ data[0] & TX_CNTRL1_2DEFER ? "two-part" : "one-part",
|
||||
+ data[0] & TX_CNTRL1_RMII ? "RMII" : "Full MII"
|
||||
+ );
|
||||
+
|
||||
+ fprintf(stdout,
|
||||
+ "RXctrl: 0x%02x\n"
|
||||
+ " Enable: %s\n"
|
||||
+ " Pad strip: %s\n"
|
||||
+ " CRC check: %s\n"
|
||||
+ " Pause: %s\n"
|
||||
+ " Loop: %s\n"
|
||||
+ " Promiscous: %s\n"
|
||||
+ " Runt frames: %s\n"
|
||||
+ " Broadcast: %s\n"
|
||||
+ "\n",
|
||||
+ data[2],
|
||||
+ data[2] & RX_CNTRL1_RX_EN ? "yes" : "no",
|
||||
+ data[2] & RX_CNTRL1_PADSTRIP_EN ? "enabled" : "disabled",
|
||||
+ data[2] & RX_CNTRL1_CRC_EN ? "enabled" : "disabled",
|
||||
+ data[2] & RX_CNTRL1_PAUSE_EN ? "enabled" : "disabled",
|
||||
+ data[2] & RX_CNTRL1_LOOP_EN ? "enabled" : "disabled",
|
||||
+ data[2] & RX_CNTRL1_ADDR_FLTR_EN ? "disabled" : "enabled",
|
||||
+ data[2] & RX_CNTRL1_RX_RUNT_EN ? "forward" : "discard",
|
||||
+ data[2] & RX_CNTRL1_BCAST_DIS ? "disabled" : "enabled"
|
||||
+ );
|
||||
+ fprintf(stdout,
|
||||
+ "Core control: 0x%02x\n"
|
||||
+ " Core state: %s\n"
|
||||
+ " RX fifo: %s\n"
|
||||
+ " TX fifo: %s\n"
|
||||
+ " Send jam: %s\n"
|
||||
+ " MDC clock %s\n"
|
||||
+ "\n",
|
||||
+ data[32],
|
||||
+ data[32] & CORE_RESET ? "reset" : "normal operation",
|
||||
+ data[32] & CORE_RX_FIFO_FLUSH ? "flush" : "ok",
|
||||
+ data[32] & CORE_TX_FIFO_FLUSH ? "flush" : "ok",
|
||||
+ data[32] & CORE_SEND_JAM ? "yes" : "no",
|
||||
+ data[32] & CORE_MDC_EN ? "output" : "input"
|
||||
+ );
|
||||
+ fprintf(stdout,
|
||||
+ "MAC addresses: \n"
|
||||
+ " Multicast mask: " MAC "\n"
|
||||
+ " Multicast address: " MAC "\n"
|
||||
+ " Unicast address: " MAC "\n"
|
||||
+ "\n",
|
||||
+ MAC_DATA(data+13), MAC_DATA(data+19), MAC_DATA(data+26)
|
||||
+ );
|
||||
+ fprintf(stdout,
|
||||
+ "Random seed: 0x%02x\n"
|
||||
+ "Threshold empty: %3d\n"
|
||||
+ "Threshold full: %3d\n"
|
||||
+ "TX buffer size: %3d\n"
|
||||
+ "TX deferral: %3d\n"
|
||||
+ "RX deferral: %3d\n"
|
||||
+ "TX two deferral 1: %3d\n"
|
||||
+ "TX two deferral 2: %3d\n"
|
||||
+ "Slot time: %3d\n"
|
||||
+ "Internal clock: %3d\n"
|
||||
+ "\n",
|
||||
+ data[4], data[5], data[6], data[7], data[8], data[9],
|
||||
+ data[10], data[11], data[12], data[25]
|
||||
+ );
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
@@ -16,6 +16,9 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=https://projects.universe-factory.net/attachments/download/75
|
||||
PKG_MD5SUM:=34f6bdebd0410a1fba7c8fd06fff7a05
|
||||
|
||||
PKG_LICENSE:=BSD-2-Clause
|
||||
PKG_LICENSE_FILE:=COPYRIGHT
|
||||
|
||||
PKG_CONFIG_DEPENDS:=\
|
||||
CONFIG_FASTD_ENABLE_METHOD_CIPHER_TEST \
|
||||
CONFIG_FASTD_ENABLE_METHOD_COMPOSED_GMAC \
|
||||
|
||||
@@ -15,9 +15,12 @@ PKG_SOURCE:=freeradius-server-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=ftp://ftp.freeradius.org/pub/freeradius/
|
||||
PKG_MD5SUM:=40535bace507d7a3134c3d858f3cbc5a
|
||||
PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_LICENSE_FILES:=COPYRIGHT LICENSE
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/freeradius-server-$(PKG_VERSION)
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_CHECK_FORMAT_SECURITY:=0
|
||||
|
||||
PKG_CONFIG_DEPENDS := \
|
||||
FREERADIUS_OPENSSL \
|
||||
@@ -415,14 +418,14 @@ PKG_DICTIONARIES:= \
|
||||
microsoft \
|
||||
wispr \
|
||||
|
||||
#ifneq ($(SDK)$(CONFIG_PACKAGE_freeradius2-mod-ldap),)
|
||||
# CONFIGURE_ARGS+= \
|
||||
# --with-rlm_ldap-include-dir="$(STAGING_DIR)/usr/include" \
|
||||
# --with-rlm_ldap-lib-dir="$(STAGING_DIR)/usr/lib"
|
||||
# CONFIGURE_LIBS+= -lcrypto -lssl
|
||||
#else
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_freeradius2-mod-ldap),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-rlm_ldap-include-dir="$(STAGING_DIR)/usr/include" \
|
||||
--with-rlm_ldap-lib-dir="$(STAGING_DIR)/usr/lib"
|
||||
CONFIGURE_LIBS+= -lcrypto -lssl
|
||||
else
|
||||
CONFIGURE_ARGS+= --without-rlm_ldap
|
||||
#endif
|
||||
endif
|
||||
|
||||
#ifneq ($(SDK)$(CONFIG_PACKAGE_freeradius2-mod-sql-mysql),)
|
||||
# CONFIGURE_ARGS+= \
|
||||
@@ -612,7 +615,7 @@ $(eval $(call BuildPlugin,freeradius2-mod-exec,rlm_exec,modules/exec modules/ech
|
||||
$(eval $(call BuildPlugin,freeradius2-mod-attr-rewrite,rlm_attr_rewrite,modules/attr_rewrite,modules,))
|
||||
$(eval $(call BuildPlugin,freeradius2-mod-files,rlm_files,acct_users preproxy_users users modules/files,modules,))
|
||||
$(eval $(call BuildPlugin,freeradius2-mod-passwd,rlm_passwd,modules/passwd,modules,))
|
||||
#$(eval $(call BuildPlugin,freeradius2-mod-ldap,rlm_ldap,ldap.attrmap modules/ldap,modules,))
|
||||
$(eval $(call BuildPlugin,freeradius2-mod-ldap,rlm_ldap,ldap.attrmap modules/ldap,modules,))
|
||||
$(eval $(call BuildPlugin,freeradius2-mod-mschap,rlm_mschap,modules/mschap,modules,))
|
||||
$(eval $(call BuildPlugin,freeradius2-mod-pap,rlm_pap,modules/pap,modules,))
|
||||
$(eval $(call BuildPlugin,freeradius2-mod-preprocess,rlm_preprocess,hints huntgroups modules/preprocess,modules,))
|
||||
|
||||
+3
-3
@@ -8,12 +8,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=git
|
||||
PKG_VERSION:=2.0.0
|
||||
PKG_VERSION:=2.1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=@KERNEL/software/scm/git/
|
||||
PKG_MD5SUM:=0646202ae979e4339f3e47f2375b5773
|
||||
PKG_MD5SUM:=47b1f55d9a16be112f7ae2c778a9b30c
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
@@ -24,7 +24,7 @@ define Package/git
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Version Control Systems
|
||||
DEPENDS:=+libopenssl +libpthread
|
||||
DEPENDS:=+libopenssl +libpthread +librt
|
||||
TITLE:=The fast version control system
|
||||
URL:=http://git-scm.com
|
||||
MAINTAINER:=Peter Wagner <tripolar@gmx.at>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -532,16 +532,7 @@ EXTRA_PROGRAMS =
|
||||
@@ -533,16 +533,7 @@ EXTRA_PROGRAMS =
|
||||
# ... and all the rest that could be moved out of bindir to gitexecdir
|
||||
PROGRAMS += $(EXTRA_PROGRAMS)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
# Binary suffix, set to .exe for Windows builds
|
||||
X =
|
||||
@@ -1002,6 +993,12 @@ BUILTIN_OBJS += builtin/var.o
|
||||
@@ -1007,6 +998,12 @@ BUILTIN_OBJS += builtin/verify-commit.o
|
||||
BUILTIN_OBJS += builtin/verify-pack.o
|
||||
BUILTIN_OBJS += builtin/verify-tag.o
|
||||
BUILTIN_OBJS += builtin/write-tree.o
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
|
||||
EXTLIBS =
|
||||
@@ -1165,7 +1162,7 @@ endif
|
||||
@@ -1174,7 +1171,7 @@ endif
|
||||
EXTLIBS += -lz
|
||||
|
||||
ifndef NO_OPENSSL
|
||||
@@ -40,7 +40,7 @@
|
||||
ifdef OPENSSLDIR
|
||||
BASIC_CFLAGS += -I$(OPENSSLDIR)/include
|
||||
OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
|
||||
@@ -2049,10 +2046,6 @@ endif
|
||||
@@ -2067,10 +2064,6 @@ endif
|
||||
git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
|
||||
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
|
||||
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
|
||||
$(LIBS) $(CURL_LIBCURL)
|
||||
@@ -2364,24 +2357,22 @@ endif
|
||||
@@ -2388,24 +2381,22 @@ endif
|
||||
bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
|
||||
execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
|
||||
{ test "$$bindir/" = "$$execdir/" || \
|
||||
@@ -80,7 +80,7 @@
|
||||
done && \
|
||||
--- a/builtin.h
|
||||
+++ b/builtin.h
|
||||
@@ -136,5 +136,11 @@ extern int cmd_verify_pack(int argc, con
|
||||
@@ -137,5 +137,11 @@ extern int cmd_verify_pack(int argc, con
|
||||
extern int cmd_show_ref(int argc, const char **argv, const char *prefix);
|
||||
extern int cmd_pack_refs(int argc, const char **argv, const char *prefix);
|
||||
extern int cmd_replace(int argc, const char **argv, const char *prefix);
|
||||
@@ -118,7 +118,7 @@
|
||||
+#include "../upload-pack.c"
|
||||
--- a/daemon.c
|
||||
+++ b/daemon.c
|
||||
@@ -1125,7 +1125,7 @@ static int serve(struct string_list *lis
|
||||
@@ -1119,7 +1119,7 @@ static int serve(struct string_list *lis
|
||||
return service_loop(&socklist);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
struct string_list listen_addr = STRING_LIST_INIT_NODUP;
|
||||
--- a/fast-import.c
|
||||
+++ b/fast-import.c
|
||||
@@ -3356,7 +3356,7 @@ static void parse_argv(void)
|
||||
@@ -3343,7 +3343,7 @@ static void parse_argv(void)
|
||||
read_marks();
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
|
||||
--- a/git.c
|
||||
+++ b/git.c
|
||||
@@ -275,11 +275,11 @@ static int handle_alias(int *argcp, cons
|
||||
@@ -312,11 +312,11 @@ static int handle_alias(int *argcp, cons
|
||||
|
||||
struct cmd_struct {
|
||||
const char *cmd;
|
||||
@@ -154,7 +154,7 @@
|
||||
{
|
||||
int status, help;
|
||||
struct stat st;
|
||||
@@ -359,6 +359,7 @@ static struct cmd_struct commands[] = {
|
||||
@@ -396,6 +396,7 @@ static struct cmd_struct commands[] = {
|
||||
{ "config", cmd_config, RUN_SETUP_GENTLY },
|
||||
{ "count-objects", cmd_count_objects, RUN_SETUP },
|
||||
{ "credential", cmd_credential, RUN_SETUP_GENTLY },
|
||||
@@ -162,16 +162,16 @@
|
||||
{ "describe", cmd_describe, RUN_SETUP },
|
||||
{ "diff", cmd_diff },
|
||||
{ "diff-files", cmd_diff_files, RUN_SETUP | NEED_WORK_TREE },
|
||||
@@ -377,6 +378,8 @@ static struct cmd_struct commands[] = {
|
||||
@@ -414,6 +415,8 @@ static struct cmd_struct commands[] = {
|
||||
{ "grep", cmd_grep, RUN_SETUP_GENTLY },
|
||||
{ "hash-object", cmd_hash_object },
|
||||
{ "help", cmd_help },
|
||||
+ { "http-backend", cmd_http_backend },
|
||||
+ { "imap-send", cmd_imap_send },
|
||||
{ "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
|
||||
{ "init", cmd_init_db },
|
||||
{ "init-db", cmd_init_db },
|
||||
@@ -424,6 +427,7 @@ static struct cmd_struct commands[] = {
|
||||
{ "init", cmd_init_db, NO_SETUP },
|
||||
{ "init-db", cmd_init_db, NO_SETUP },
|
||||
@@ -461,6 +464,7 @@ static struct cmd_struct commands[] = {
|
||||
{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
|
||||
{ "rm", cmd_rm, RUN_SETUP },
|
||||
{ "send-pack", cmd_send_pack, RUN_SETUP },
|
||||
@@ -179,17 +179,17 @@
|
||||
{ "shortlog", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER },
|
||||
{ "show", cmd_show, RUN_SETUP },
|
||||
{ "show-branch", cmd_show_branch, RUN_SETUP },
|
||||
@@ -440,6 +444,7 @@ static struct cmd_struct commands[] = {
|
||||
@@ -477,6 +481,7 @@ static struct cmd_struct commands[] = {
|
||||
{ "update-server-info", cmd_update_server_info, RUN_SETUP },
|
||||
{ "upload-archive", cmd_upload_archive },
|
||||
{ "upload-archive--writer", cmd_upload_archive_writer },
|
||||
+ { "upload-pack", cmd_upload_pack },
|
||||
{ "var", cmd_var, RUN_SETUP_GENTLY },
|
||||
{ "verify-commit", cmd_verify_commit, RUN_SETUP },
|
||||
{ "verify-pack", cmd_verify_pack },
|
||||
{ "verify-tag", cmd_verify_tag, RUN_SETUP },
|
||||
--- a/http-backend.c
|
||||
+++ b/http-backend.c
|
||||
@@ -563,7 +563,7 @@ static struct service_cmd {
|
||||
@@ -566,7 +566,7 @@ static struct service_cmd {
|
||||
{"POST", "/git-receive-pack$", service_rpc}
|
||||
};
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
char *dir;
|
||||
--- a/imap-send.c
|
||||
+++ b/imap-send.c
|
||||
@@ -1362,7 +1362,7 @@ static int git_imap_config(const char *k
|
||||
@@ -1365,7 +1365,7 @@ static int git_imap_config(const char *k
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@
|
||||
struct strbuf msg = STRBUF_INIT;
|
||||
--- a/shell.c
|
||||
+++ b/shell.c
|
||||
@@ -142,7 +142,7 @@ static struct commands {
|
||||
@@ -138,7 +138,7 @@ static struct commands {
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=haproxy
|
||||
PKG_VERSION:=1.5.3
|
||||
PKG_RELEASE:=03
|
||||
PKG_RELEASE:=06
|
||||
PKG_SOURCE:=haproxy-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://haproxy.1wt.eu/download/1.5/src/
|
||||
PKG_MD5SUM:=e999a547d57445d5a5ab7eb6a06df9a1
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
From a772b945d757c25037ac58de64ccc27ceeb4b4a7 Mon Sep 17 00:00:00 2001
|
||||
From: Baptiste Assmann <bedis9@gmail.com>
|
||||
Date: Fri, 8 Aug 2014 17:29:06 +0200
|
||||
Subject: [PATCH 4/4] BUG: config: error in http-response replace-header number
|
||||
of arguments
|
||||
|
||||
A couple of typo fixed in 'http-response replace-header':
|
||||
- an error when counting the number of arguments
|
||||
- a typo in the alert message
|
||||
|
||||
This should be backported to 1.5.
|
||||
(cherry picked from commit 12cb00b216d67468b7c4bd84abedcb4ecd1a32bc)
|
||||
---
|
||||
src/proto_http.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/proto_http.c b/src/proto_http.c
|
||||
index b7ed85d..2b75b32 100644
|
||||
--- a/src/proto_http.c
|
||||
+++ b/src/proto_http.c
|
||||
@@ -9281,8 +9281,8 @@ struct http_res_rule *parse_http_res_cond(const char **args, const char *file, i
|
||||
cur_arg = 1;
|
||||
|
||||
if (!*args[cur_arg] || !*args[cur_arg+1] || !*args[cur_arg+2] ||
|
||||
- (*args[cur_arg+3] && strcmp(args[cur_arg+2], "if") != 0 && strcmp(args[cur_arg+2], "unless") != 0)) {
|
||||
- Alert("parsing [%s:%d]: 'http-request %s' expects exactly 3 arguments.\n",
|
||||
+ (*args[cur_arg+3] && strcmp(args[cur_arg+3], "if") != 0 && strcmp(args[cur_arg+3], "unless") != 0)) {
|
||||
+ Alert("parsing [%s:%d]: 'http-response %s' expects exactly 3 arguments.\n",
|
||||
file, linenum, args[0]);
|
||||
goto out_err;
|
||||
}
|
||||
--
|
||||
1.8.5.5
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
From fc566b541e4c67cfbd8d6b40b627ce27dfc8a7cb Mon Sep 17 00:00:00 2001
|
||||
From: Thierry FOURNIER <tfournier@exceliance.fr>
|
||||
Date: Fri, 22 Aug 2014 06:55:26 +0200
|
||||
Subject: [PATCH 5/6] BUG/MEDIUM: http: tarpit timeout is reset
|
||||
|
||||
Before the commit bbba2a8ecc35daf99317aaff7015c1931779c33b
|
||||
(1.5-dev24-8), the tarpit section set timeout and return, after this
|
||||
commit, the tarpit section set the timeout, and go to the "done" label
|
||||
which reset the timeout.
|
||||
|
||||
Thanks Bryan Talbot for the bug report and analysis.
|
||||
|
||||
This should be backported in 1.5.
|
||||
(cherry picked from commit 7566e30477bf5ea4206bda5950d2d83108c4a3dc)
|
||||
---
|
||||
src/proto_http.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/proto_http.c b/src/proto_http.c
|
||||
index 2b75b32..bebc8bf 100644
|
||||
--- a/src/proto_http.c
|
||||
+++ b/src/proto_http.c
|
||||
@@ -4117,8 +4117,9 @@ int http_process_req_common(struct session *s, struct channel *req, int an_bit,
|
||||
done: /* done with this analyser, continue with next ones that the calling
|
||||
* points will have set, if any.
|
||||
*/
|
||||
- req->analysers &= ~an_bit;
|
||||
req->analyse_exp = TICK_ETERNITY;
|
||||
+ done_without_exp: /* done with this analyser, but dont reset the analyse_exp. */
|
||||
+ req->analysers &= ~an_bit;
|
||||
return 1;
|
||||
|
||||
tarpit:
|
||||
@@ -4144,7 +4145,7 @@ int http_process_req_common(struct session *s, struct channel *req, int an_bit,
|
||||
s->be->be_counters.denied_req++;
|
||||
if (s->listener->counters)
|
||||
s->listener->counters->denied_req++;
|
||||
- goto done;
|
||||
+ goto done_without_exp;
|
||||
|
||||
deny: /* this request was blocked (denied) */
|
||||
txn->flags |= TX_CLDENY;
|
||||
--
|
||||
1.8.5.5
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
From d6ec605d2059191163cad27b7d7b215ed8d3725b Mon Sep 17 00:00:00 2001
|
||||
From: Dave McCowan <11235david@gmail.com>
|
||||
Date: Wed, 30 Jul 2014 10:39:13 -0400
|
||||
Subject: [PATCH 6/6] MEDIUM: connection: add new bit in Proxy Protocol V2
|
||||
|
||||
There are two sample commands to get information about the presence of a
|
||||
client certificate.
|
||||
ssl_fc_has_crt is true if there is a certificate present in the current
|
||||
connection
|
||||
ssl_c_used is true if there is a certificate present in the session.
|
||||
If a session has stopped and resumed, then ssl_c_used could be true, while
|
||||
ssl_fc_has_crt is false.
|
||||
|
||||
In the client byte of the TLS TLV of Proxy Protocol V2, there is only one
|
||||
bit to indicate whether a certificate is present on the connection. The
|
||||
attached patch adds a second bit to indicate the presence for the session.
|
||||
|
||||
This maintains backward compatibility.
|
||||
|
||||
[wt: this should be backported to 1.5 to help maintain compatibility
|
||||
between versions]
|
||||
(cherry picked from commit 328fb58d745c03a0dc706da9e2fcd4e9f860a14b)
|
||||
---
|
||||
include/proto/ssl_sock.h | 3 ++-
|
||||
include/types/connection.h | 5 +++--
|
||||
src/connection.c | 6 ++++--
|
||||
src/ssl_sock.c | 21 +++++++++++++++++++--
|
||||
4 files changed, 28 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/include/proto/ssl_sock.h b/include/proto/ssl_sock.h
|
||||
index 3e111cd..10541ed 100644
|
||||
--- a/include/proto/ssl_sock.h
|
||||
+++ b/include/proto/ssl_sock.h
|
||||
@@ -51,7 +51,8 @@ void ssl_sock_free_all_ctx(struct bind_conf *bind_conf);
|
||||
const char *ssl_sock_get_cipher_name(struct connection *conn);
|
||||
const char *ssl_sock_get_proto_version(struct connection *conn);
|
||||
char *ssl_sock_get_version(struct connection *conn);
|
||||
-int ssl_sock_get_cert_used(struct connection *conn);
|
||||
+int ssl_sock_get_cert_used_sess(struct connection *conn);
|
||||
+int ssl_sock_get_cert_used_conn(struct connection *conn);
|
||||
int ssl_sock_get_remote_common_name(struct connection *conn, struct chunk *out);
|
||||
unsigned int ssl_sock_get_verify_result(struct connection *conn);
|
||||
#ifdef SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB
|
||||
diff --git a/include/types/connection.h b/include/types/connection.h
|
||||
index 2ae16d7..b317007 100644
|
||||
--- a/include/types/connection.h
|
||||
+++ b/include/types/connection.h
|
||||
@@ -345,8 +345,9 @@ struct tlv_ssl {
|
||||
uint8_t sub_tlv[0];
|
||||
}__attribute__((packed));
|
||||
|
||||
-#define PP2_CLIENT_SSL 0x01
|
||||
-#define PP2_CLIENT_CERT 0x02
|
||||
+#define PP2_CLIENT_SSL 0x01
|
||||
+#define PP2_CLIENT_CERT_CONN 0x02
|
||||
+#define PP2_CLIENT_CERT_SESS 0x04
|
||||
|
||||
#endif /* _TYPES_CONNECTION_H */
|
||||
|
||||
diff --git a/src/connection.c b/src/connection.c
|
||||
index 2dd2c02..3af6d9a 100644
|
||||
--- a/src/connection.c
|
||||
+++ b/src/connection.c
|
||||
@@ -678,9 +678,11 @@ int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct connec
|
||||
tlv_len = make_tlv(&buf[ret+ssl_tlv_len], (buf_len-ret-ssl_tlv_len), PP2_TYPE_SSL_VERSION, strlen(value), value);
|
||||
ssl_tlv_len += tlv_len;
|
||||
}
|
||||
- if (ssl_sock_get_cert_used(remote)) {
|
||||
- tlv->client |= PP2_CLIENT_CERT;
|
||||
+ if (ssl_sock_get_cert_used_sess(remote)) {
|
||||
+ tlv->client |= PP2_CLIENT_CERT_SESS;
|
||||
tlv->verify = htonl(ssl_sock_get_verify_result(remote));
|
||||
+ if (ssl_sock_get_cert_used_conn(remote))
|
||||
+ tlv->client |= PP2_CLIENT_CERT_CONN;
|
||||
}
|
||||
if (srv->pp_opts & SRV_PP_V2_SSL_CN) {
|
||||
cn_trash = get_trash_chunk();
|
||||
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
|
||||
index cf8adc7..da99a30 100644
|
||||
--- a/src/ssl_sock.c
|
||||
+++ b/src/ssl_sock.c
|
||||
@@ -2720,8 +2720,25 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
-/* returns 1 if client passed a certificate, 0 if not */
|
||||
-int ssl_sock_get_cert_used(struct connection *conn)
|
||||
+/* returns 1 if client passed a certificate for this session, 0 if not */
|
||||
+int ssl_sock_get_cert_used_sess(struct connection *conn)
|
||||
+{
|
||||
+ X509 *crt = NULL;
|
||||
+
|
||||
+ if (!ssl_sock_is_ssl(conn))
|
||||
+ return 0;
|
||||
+
|
||||
+ /* SSL_get_peer_certificate, it increase X509 * ref count */
|
||||
+ crt = SSL_get_peer_certificate(conn->xprt_ctx);
|
||||
+ if (!crt)
|
||||
+ return 0;
|
||||
+
|
||||
+ X509_free(crt);
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+/* returns 1 if client passed a certificate for this connection, 0 if not */
|
||||
+int ssl_sock_get_cert_used_conn(struct connection *conn)
|
||||
{
|
||||
if (!ssl_sock_is_ssl(conn))
|
||||
return 0;
|
||||
--
|
||||
1.8.5.5
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# Copyright (C) 2014 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:=ibrdtn-tools
|
||||
PKG_VERSION:=0.12.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.ibr.cs.tu-bs.de/projects/ibr-dtn/releases
|
||||
PKG_MD5SUM:=0ce0c6e754263919ad48661967c2f6fd
|
||||
PKG_MAINTAINER:=Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ibrdtn-tools
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+ibrdtn +libarchive
|
||||
TITLE:=DTN Tools
|
||||
endef
|
||||
|
||||
define Package/ibrdtn-tools/description
|
||||
The IBR-DTN Tools include functionality for sending and receiving files (dtnsend/dtnrecv)
|
||||
and a tools to ping a DTN node (dtnping).
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--without-libdaemon
|
||||
|
||||
define Package/ibrdtn-tools/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtnping $(1)/usr/bin/dtnping
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtnsend $(1)/usr/bin/dtnsend
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtnrecv $(1)/usr/bin/dtnrecv
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtninbox $(1)/usr/bin/dtninbox
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtnoutbox $(1)/usr/bin/dtnoutbox
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtntrigger $(1)/usr/bin/dtntrigger
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtntracepath $(1)/usr/bin/dtntracepath
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtnstream $(1)/usr/bin/dtnstream
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ibrdtn-tools))
|
||||
@@ -0,0 +1,89 @@
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -67,34 +67,57 @@ AC_TYPE_UINT8_T
|
||||
AC_FUNC_MALLOC
|
||||
AC_CHECK_FUNCS([memset])
|
||||
|
||||
-PKG_CHECK_MODULES(DAEMON, libdaemon >= 0.12, [
|
||||
- AC_SUBST(DAEMON_CFLAGS)
|
||||
- AC_SUBST(DAEMON_LIBS)
|
||||
- AC_DEFINE(HAVE_LIBDAEMON, [1], ["daemon library is available"])
|
||||
- AC_CHECK_LIB(daemon, daemon_reset_sigs, [
|
||||
- AC_DEFINE(HAVE_DAEMON_RESET_SIGS, [1], ["daemon library has daemon_reset_sigs() and daemon_unblock_sigs() functions"])
|
||||
- ])
|
||||
-], [
|
||||
- AC_MSG_WARN([daemon library not found, daemonize features disabled])
|
||||
-])
|
||||
+AC_ARG_WITH([libdaemon],
|
||||
+ AS_HELP_STRING([--without-libdaemon], [Build without daemonize support]),
|
||||
+ [
|
||||
+ AC_MSG_NOTICE([daemonize support disabled])
|
||||
+ ], [
|
||||
+ PKG_CHECK_MODULES(DAEMON, libdaemon >= 0.12, [
|
||||
+ AC_SUBST(DAEMON_CFLAGS)
|
||||
+ AC_SUBST(DAEMON_LIBS)
|
||||
+ AC_DEFINE(HAVE_LIBDAEMON, [1], ["daemon library is available"])
|
||||
+ AC_CHECK_LIB(daemon, daemon_reset_sigs, [
|
||||
+ AC_DEFINE(HAVE_DAEMON_RESET_SIGS, [1], ["daemon library has daemon_reset_sigs() and daemon_unblock_sigs() functions"])
|
||||
+ ])
|
||||
+ ], [
|
||||
+ AC_MSG_WARN([daemon library not found, daemonize features disabled])
|
||||
+ ])
|
||||
+ ]
|
||||
+)
|
||||
|
||||
-PKG_CHECK_MODULES(ARCHIVE, libarchive >= 3.0, [
|
||||
- AC_SUBST(ARCHIVE_CFLAGS)
|
||||
- AC_SUBST(ARCHIVE_LIBS)
|
||||
- AC_DEFINE(HAVE_LIBARCHIVE, [1], ["libarchive is available"])
|
||||
- has_libarchive="yes"
|
||||
-], [
|
||||
- AC_MSG_WARN([libarchive not found, dtninbox and dtnoutbox will not be compiled])
|
||||
-])
|
||||
+AC_ARG_WITH([libarchive],
|
||||
+ AS_HELP_STRING([--without-libarchive], [Build without archive support]),
|
||||
+ [
|
||||
+ has_libarchive="no"
|
||||
+ AC_MSG_NOTICE([archive support disabled, dtninbox and dtnoutbox will not be compiled])
|
||||
+ ], [
|
||||
+ PKG_CHECK_MODULES(ARCHIVE, libarchive >= 3.0, [
|
||||
+ AC_SUBST(ARCHIVE_CFLAGS)
|
||||
+ AC_SUBST(ARCHIVE_LIBS)
|
||||
+ AC_DEFINE(HAVE_LIBARCHIVE, [1], ["libarchive is available"])
|
||||
+ has_libarchive="yes"
|
||||
+ ], [
|
||||
+ AC_MSG_WARN([libarchive not found, dtninbox and dtnoutbox will not be compiled])
|
||||
+ ])
|
||||
+ ]
|
||||
+)
|
||||
|
||||
-PKG_CHECK_MODULES(OPENSSL, openssl, [
|
||||
- AC_SUBST(OPENSSL_CFLAGS)
|
||||
- AC_SUBST(OPENSSL_LIBS)
|
||||
- AC_DEFINE(HAVE_OPENSSL, [1], ["openssl available"])
|
||||
- has_openssl="yes"
|
||||
-], [
|
||||
- AC_MSG_WARN([openssl not found, dtninbox and dtnoutbox will not be compiled])
|
||||
-])
|
||||
+AC_ARG_WITH([openssl],
|
||||
+ AS_HELP_STRING([--without-openssl], [Build without openssl support]),
|
||||
+ [
|
||||
+ has_openssl="no"
|
||||
+ AC_MSG_NOTICE([openssl support disabled, dtninbox and dtnoutbox will not be compiled])
|
||||
+ ], [
|
||||
+ PKG_CHECK_MODULES(OPENSSL, openssl, [
|
||||
+ AC_SUBST(OPENSSL_CFLAGS)
|
||||
+ AC_SUBST(OPENSSL_LIBS)
|
||||
+ AC_DEFINE(HAVE_OPENSSL, [1], ["openssl available"])
|
||||
+ has_openssl="yes"
|
||||
+ ], [
|
||||
+ AC_MSG_WARN([openssl not found, dtninbox and dtnoutbox will not be compiled])
|
||||
+ ])
|
||||
+ ]
|
||||
+)
|
||||
|
||||
AC_ARG_WITH([tffs],
|
||||
AS_HELP_STRING([--with-tffs=PATH], [set the tffs path for fat-image support in dtnoutbox]), [
|
||||
--
|
||||
1.9.1
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#
|
||||
# Copyright (C) 2014 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:=ibrdtnd
|
||||
PKG_VERSION:=0.12.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.ibr.cs.tu-bs.de/projects/ibr-dtn/releases
|
||||
PKG_MD5SUM:=8dad5ebbcfaa4c16ba151c9c289066c3
|
||||
PKG_MAINTAINER:=Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ibrdtnd
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+dtndht +ibrdtn +libsqlite3
|
||||
TITLE:=DTN Deamon
|
||||
endef
|
||||
|
||||
define Package/ibrdtnd/conffiles
|
||||
/etc/config/ibrdtn
|
||||
endef
|
||||
|
||||
define Package/ibrdtnd/description
|
||||
The implementation of the bundle protocol of the IBR (TU Braunschweig).
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--with-tls \
|
||||
--with-sqlite \
|
||||
--without-wifip2p \
|
||||
--without-vmime \
|
||||
--disable-libdaemon
|
||||
|
||||
define Package/ibrdtnd/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/dtnd $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) files/safety-wrapper.sh $(1)/usr/sbin/dtnd-safety-wrapper.sh
|
||||
$(INSTALL_DIR) $(1)/usr/share/ibrdtn/
|
||||
$(INSTALL_BIN) files/build-config.sh $(1)/usr/share/ibrdtn/build-config.sh
|
||||
$(INSTALL_BIN) files/mkcontainer.sh $(1)/usr/share/ibrdtn/mkcontainer.sh
|
||||
$(INSTALL_BIN) files/mountcontainer.sh $(1)/usr/share/ibrdtn/mountcontainer.sh
|
||||
$(INSTALL_BIN) files/systemcheck.sh $(1)/usr/share/ibrdtn/systemcheck.sh
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
$(INSTALL_BIN) files/ibrdtn.init $(1)/etc/init.d/ibrdtn
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) files/ibrdtn.uci $(1)/etc/config/ibrdtn
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ibrdtnd))
|
||||
@@ -0,0 +1,168 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# convert uci configuration into daemon specific format
|
||||
#
|
||||
|
||||
UCI=/sbin/uci
|
||||
|
||||
create_file() {
|
||||
echo "# -- DO NOT EDIT THIS FILE --" > $1
|
||||
echo "# automatic generated configuration file for IBR-DTN daemon" >> $1
|
||||
echo "#" >> $1
|
||||
}
|
||||
|
||||
add_param() {
|
||||
VALUE=`$UCI -q get $2`
|
||||
|
||||
if [ $? == 0 ]; then
|
||||
echo "$3 = $VALUE" >> $1
|
||||
fi
|
||||
}
|
||||
|
||||
getconfig() {
|
||||
$UCI -q get ibrdtn.$1
|
||||
return $?
|
||||
}
|
||||
|
||||
if [ "$1" == "--safe-mode" ]; then
|
||||
SAFEMODE=yes
|
||||
CONFFILE=$2
|
||||
else
|
||||
SAFEMODE=no
|
||||
CONFFILE=$1
|
||||
fi
|
||||
|
||||
# create the file and write some header info
|
||||
create_file $CONFFILE
|
||||
|
||||
add_param $CONFFILE "ibrdtn.main.uri" "local_uri"
|
||||
add_param $CONFFILE "ibrdtn.main.routing" "routing"
|
||||
add_param $CONFFILE "ibrdtn.main.fragmentation" "fragmentation"
|
||||
|
||||
if [ "$SAFEMODE" == "yes" ]; then
|
||||
if [ -n "`getconfig safemode.forwarding`" ]; then
|
||||
add_param $CONFFILE "ibrdtn.safemode.forwarding" "routing_forwarding"
|
||||
else
|
||||
add_param $CONFFILE "ibrdtn.main.forwarding" "routing_forwarding"
|
||||
fi
|
||||
|
||||
if [ -n "`getconfig safemode.maxblock`" ]; then
|
||||
add_param $CONFFILE "ibrdtn.safemode.maxblock" "limit_blocksize"
|
||||
else
|
||||
add_param $CONFFILE "ibrdtn.main.blocksize" "limit_blocksize"
|
||||
fi
|
||||
|
||||
if [ -n "`getconfig safemode.storage`" ]; then
|
||||
add_param $CONFFILE "ibrdtn.safemode.storage" "limit_storage"
|
||||
else
|
||||
add_param $CONFFILE "ibrdtn.storage.limit" "limit_storage"
|
||||
fi
|
||||
else
|
||||
add_param $CONFFILE "ibrdtn.main.forwarding" "routing_forwarding"
|
||||
add_param $CONFFILE "ibrdtn.main.blocksize" "limit_blocksize"
|
||||
add_param $CONFFILE "ibrdtn.storage.limit" "limit_storage"
|
||||
add_param $CONFFILE "ibrdtn.storage.blobs" "blob_path"
|
||||
add_param $CONFFILE "ibrdtn.storage.bundles" "storage_path"
|
||||
add_param $CONFFILE "ibrdtn.storage.engine" "storage"
|
||||
fi
|
||||
|
||||
add_param $CONFFILE "ibrdtn.main.max_predated_timestamp" "limit_predated_timestamp"
|
||||
add_param $CONFFILE "ibrdtn.main.limit_lifetime" "limit_lifetime"
|
||||
add_param $CONFFILE "ibrdtn.main.foreign_blocksize" "limit_foreign_blocksize"
|
||||
|
||||
add_param $CONFFILE "ibrdtn.discovery.address" "discovery_address"
|
||||
add_param $CONFFILE "ibrdtn.discovery.timeout" "discovery_timeout"
|
||||
add_param $CONFFILE "ibrdtn.discovery.version" "discovery_version"
|
||||
add_param $CONFFILE "ibrdtn.discovery.crosslayer" "discovery_crosslayer"
|
||||
|
||||
add_param $CONFFILE "ibrdtn.tcptuning.idle_timeout" "tcp_idle_timeout"
|
||||
add_param $CONFFILE "ibrdtn.tcptuning.nodelay" "tcp_nodelay"
|
||||
add_param $CONFFILE "ibrdtn.tcptuning.chunksize" "tcp_chunksize"
|
||||
|
||||
add_param $CONFFILE "ibrdtn.security.level" "security_level"
|
||||
add_param $CONFFILE "ibrdtn.security.bab_key" "security_bab_default_key"
|
||||
add_param $CONFFILE "ibrdtn.security.key_path" "security_path"
|
||||
add_param $CONFFILE "ibrdtn.security.generate_dh" "generate_dh_params"
|
||||
|
||||
add_param $CONFFILE "ibrdtn.tls.certificate" "security_certificate"
|
||||
add_param $CONFFILE "ibrdtn.tls.key" "security_key"
|
||||
add_param $CONFFILE "ibrdtn.tls.trustedpath" "security_trusted_ca_path"
|
||||
add_param $CONFFILE "ibrdtn.tls.required" "security_tls_required"
|
||||
add_param $CONFFILE "ibrdtn.tls.noencryption" "security_tls_disable_encryption"
|
||||
add_param $CONFFILE "ibrdtn.tls.fallback_badclock" "security_tls_fallback_badclock"
|
||||
|
||||
add_param $CONFFILE "ibrdtn.timesync.reference" "time_reference"
|
||||
add_param $CONFFILE "ibrdtn.timesync.synchronize" "time_synchronize"
|
||||
add_param $CONFFILE "ibrdtn.timesync.discovery_announcement" "time_discovery_announcements"
|
||||
add_param $CONFFILE "ibrdtn.timesync.sigma" "time_sigma"
|
||||
add_param $CONFFILE "ibrdtn.timesync.psi" "time_psi"
|
||||
add_param $CONFFILE "ibrdtn.timesync.sync_level" "time_sync_level"
|
||||
add_param $CONFFILE "ibrdtn.timesync.time_set_clock" "time_set_clock"
|
||||
|
||||
add_param $CONFFILE "ibrdtn.dht.enabled" "dht_enabled"
|
||||
add_param $CONFFILE "ibrdtn.dht.port" "dht_port"
|
||||
add_param $CONFFILE "ibrdtn.dht.id" "dht_id"
|
||||
add_param $CONFFILE "ibrdtn.dht.bootstrap" "dht_bootstrapping"
|
||||
add_param $CONFFILE "ibrdtn.dht.nodesfile" "dht_nodes_file"
|
||||
add_param $CONFFILE "ibrdtn.dht.enable_ipv4" "dht_enable_ipv4"
|
||||
add_param $CONFFILE "ibrdtn.dht.enable_ipv6" "dht_enable_ipv6"
|
||||
add_param $CONFFILE "ibrdtn.dht.bind_ipv4" "dht_bind_ipv4"
|
||||
add_param $CONFFILE "ibrdtn.dht.bind_ipv6" "dht_bind_ipv6"
|
||||
add_param $CONFFILE "ibrdtn.dht.ignore_neighbour_informations" "dht_ignore_neighbour_informations"
|
||||
add_param $CONFFILE "ibrdtn.dht.allow_neighbours_to_announce_me" "dht_allow_neighbours_to_announce_me"
|
||||
add_param $CONFFILE "ibrdtn.dht.allow_neighbour_announcement" "dht_allow_neighbour_announcement"
|
||||
|
||||
|
||||
# iterate through all network interfaces
|
||||
iter=0
|
||||
netinterfaces=
|
||||
while [ 1 == 1 ]; do
|
||||
$UCI -q get "ibrdtn.@network[$iter]" > /dev/null
|
||||
if [ $? == 0 ]; then
|
||||
netinterfaces="${netinterfaces} lan${iter}"
|
||||
add_param $CONFFILE "ibrdtn.@network[$iter].type" "net_lan${iter}_type"
|
||||
add_param $CONFFILE "ibrdtn.@network[$iter].interface" "net_lan${iter}_interface"
|
||||
add_param $CONFFILE "ibrdtn.@network[$iter].port" "net_lan${iter}_port"
|
||||
else
|
||||
break
|
||||
fi
|
||||
|
||||
let iter=iter+1
|
||||
done
|
||||
|
||||
# write list of network interfaces
|
||||
echo "net_interfaces =$netinterfaces" >> $CONFFILE
|
||||
|
||||
# iterate through all static routes
|
||||
iter=0
|
||||
while [ 1 == 1 ]; do
|
||||
$UCI -q get "ibrdtn.@static-route[$iter]" > /dev/null
|
||||
if [ $? == 0 ]; then
|
||||
PATTERN=`$UCI -q get "ibrdtn.@static-route[$iter].pattern"`
|
||||
DESTINATION=`$UCI -q get "ibrdtn.@static-route[$iter].destination"`
|
||||
let NUMBER=iter+1
|
||||
echo "route$NUMBER = $PATTERN $DESTINATION" >> $CONFFILE
|
||||
else
|
||||
break
|
||||
fi
|
||||
|
||||
let iter=iter+1
|
||||
done
|
||||
|
||||
#iterate through all static connections
|
||||
iter=0
|
||||
while [ 1 == 1 ]; do
|
||||
$UCI -q get "ibrdtn.@static-connection[$iter]" > /dev/null
|
||||
if [ $? == 0 ]; then
|
||||
let NUMBER=iter+1
|
||||
add_param $CONFFILE "ibrdtn.@static-connection[$iter].uri" "static${NUMBER}_uri"
|
||||
add_param $CONFFILE "ibrdtn.@static-connection[$iter].address" "static${NUMBER}_address"
|
||||
add_param $CONFFILE "ibrdtn.@static-connection[$iter].port" "static${NUMBER}_port"
|
||||
add_param $CONFFILE "ibrdtn.@static-connection[$iter].protocol" "static${NUMBER}_proto"
|
||||
add_param $CONFFILE "ibrdtn.@static-connection[$iter].immediately" "static${NUMBER}_immediately"
|
||||
else
|
||||
break
|
||||
fi
|
||||
|
||||
let iter=iter+1
|
||||
done
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2007 OpenWrt.org
|
||||
|
||||
START=90
|
||||
|
||||
start() {
|
||||
# check if the daemon is disabled
|
||||
if [ "`/sbin/uci -P/var/state -q get ibrdtn.disable`" == "1" ]; then
|
||||
/bin/echo "dtnd is disabled"
|
||||
return
|
||||
fi
|
||||
|
||||
/bin/echo -n "running dtnd ..."
|
||||
|
||||
# startup the safety-wrapper for the daemon
|
||||
/usr/sbin/dtnd-safety-wrapper.sh &
|
||||
|
||||
# store the pid of the process in uci states
|
||||
/sbin/uci -P/var/state -q set ibrdtn.safetypid=`echo $!`
|
||||
|
||||
/bin/echo " done"
|
||||
}
|
||||
|
||||
stop() {
|
||||
# check if the daemon is disabled
|
||||
if [ "`/sbin/uci -P/var/state -q get ibrdtn.disable`" == "1" ]; then
|
||||
/bin/echo "dtnd is disabled"
|
||||
return
|
||||
fi
|
||||
|
||||
/bin/echo -n "stopping dtnd ..."
|
||||
|
||||
# set state to None, this indicates a clear shutdown to the safety-wrapper.
|
||||
/sbin/uci -P/var/state -q set ibrdtn.state=None
|
||||
|
||||
# stop the safety-wrapper
|
||||
if [ -n "`/sbin/uci -P/var/state -q get ibrdtn.safetypid`" ]; then
|
||||
/usr/bin/kill `/sbin/uci -P/var/state -q get ibrdtn.safetypid` 2> /dev/null >/dev/null
|
||||
fi
|
||||
|
||||
# finally kill really all safety-wrapper!
|
||||
/bin/sleep 2
|
||||
/usr/bin/killall -9 dtnd-safety-wrapper.sh
|
||||
|
||||
# send a kill signal to the daemon
|
||||
/usr/bin/killall dtnd 2> /dev/null >/dev/null
|
||||
|
||||
# wait for some time
|
||||
TIMEOUT=0;
|
||||
|
||||
# check if the daemon is running
|
||||
while [ -n "`ps | grep dtnd | grep -v grep`" ]; do
|
||||
# check if the daemon is still running
|
||||
if [ $TIMEOUT -ge 10 ]; then
|
||||
/bin/echo " killing"
|
||||
# kill all processes of dtnd
|
||||
/usr/bin/killall -9 dtnd 2> /dev/null >/dev/null
|
||||
return
|
||||
fi
|
||||
|
||||
# increment timeout
|
||||
TIMEOUT=`expr $TIMEOUT + 1`
|
||||
|
||||
echo -n "."
|
||||
|
||||
# wait some time
|
||||
/bin/sleep 1
|
||||
done
|
||||
|
||||
echo " done"
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
#####################################
|
||||
# IBR-DTN daemon #
|
||||
#####################################
|
||||
|
||||
config 'daemon' 'main'
|
||||
# The local eid of the dtn node. Default is the hostname.
|
||||
# option uri dtn://node.dtn
|
||||
|
||||
# logfile for standard output
|
||||
option logfile /tmp/ibrdtn.log
|
||||
option errfile /tmp/ibrdtn.err
|
||||
|
||||
# debug level
|
||||
# option debug 20
|
||||
|
||||
# block size limit
|
||||
# option blocksize 512M
|
||||
# option foreign_blocksize 128M
|
||||
|
||||
|
||||
#
|
||||
# If something bad happened, the safe mode will be activated.
|
||||
# These are the restrictions for safe mode only.
|
||||
#
|
||||
config 'daemon' 'safemode'
|
||||
option forwarding no
|
||||
option storage 64M
|
||||
option maxblock 16M
|
||||
# option wait_mount /dev/sda1
|
||||
|
||||
|
||||
#####################################
|
||||
# storage configuration #
|
||||
#####################################
|
||||
|
||||
config 'daemon' 'storage'
|
||||
# possible engines are: simple, sqlite
|
||||
option engine simple
|
||||
option blobs /tmp/ibrdtn/blobs
|
||||
option bundles /tmp/ibrdtn/bundles
|
||||
# option container /tmp/ibrdtn/container.img
|
||||
# option path /tmp/ibrdtn/container
|
||||
# option limit 1G
|
||||
|
||||
|
||||
#####################################
|
||||
# routing configuration #
|
||||
#####################################
|
||||
|
||||
#
|
||||
# In the "default" the daemon only delivers bundles to neighbors and static
|
||||
# available nodes. The alternative module "epidemic" spread all bundles to
|
||||
# all available neighbors.
|
||||
#
|
||||
config 'daemon' 'main'
|
||||
# values: none | default | epidemic | flooding | prophet
|
||||
option routing prophet
|
||||
# option forwarding no
|
||||
# option fragmentation yes
|
||||
|
||||
#
|
||||
# static routing rules
|
||||
# - a rule is a regex pattern
|
||||
# - format is <target-scheme> <routing-node>
|
||||
#
|
||||
#config 'static-route'
|
||||
# list pattern ^dtn://[[:alpha:]].moon.dtn/[[:alpha:]]
|
||||
# option destination dtn://router.dtn
|
||||
|
||||
|
||||
#####################################
|
||||
# static connections
|
||||
#####################################
|
||||
|
||||
#config 'static-connection'
|
||||
# option uri dtn://node-five.dtn
|
||||
# option address 10.0.0.5
|
||||
# option port 4556
|
||||
# option protocol tcp
|
||||
# option immediately yes
|
||||
|
||||
#config 'static-connection'
|
||||
# option uri dtn://node-ten
|
||||
# option address 10.0.0.10
|
||||
# option port 4556
|
||||
# option protocol udp
|
||||
# option immediately no
|
||||
|
||||
|
||||
#####################################
|
||||
# convergence layer configuration #
|
||||
#####################################
|
||||
|
||||
#
|
||||
# You can specify an multicast address to listen to for discovery announcements.
|
||||
# If no address is specified the multicast equivalent of broadcast is used.
|
||||
#
|
||||
config 'daemon' 'discovery'
|
||||
# option address 224.0.0.1
|
||||
# option timeout 5
|
||||
# option crosslayer yes
|
||||
|
||||
config 'daemon' 'tcptuning'
|
||||
# option 'idle_timeout' 120
|
||||
# option 'nodelay' yes
|
||||
# option 'chunksize' 4096
|
||||
|
||||
config 'network'
|
||||
option type tcp
|
||||
option interface eth0
|
||||
option port 4556
|
||||
|
||||
#config 'network'
|
||||
# option type tcp
|
||||
# option interface wlan0
|
||||
# option port 4556
|
||||
|
||||
|
||||
#####################################
|
||||
# bundle security protocol #
|
||||
#####################################
|
||||
|
||||
#
|
||||
# the level specifies the security constains
|
||||
#
|
||||
# 0 = no constrains (default)
|
||||
# 1 = accept only BAB authenticated bundles
|
||||
# 2 = accept only encrypted bundles
|
||||
# 3 = accept only BAB authenticated and encrypted bundles
|
||||
#
|
||||
|
||||
#config 'daemon' 'security'
|
||||
# option level 0
|
||||
# option bab_key /path/to/default-bab-key.mac
|
||||
# option key_path /path/to/security-keys
|
||||
# option generate_dh yes
|
||||
|
||||
#config 'daemon' 'tls'
|
||||
# option certificate /path/to/tls-cert.crt
|
||||
# option key /path/to/tls-key.key
|
||||
# option trustedpath /path/to/tls-ca
|
||||
# option required no
|
||||
# option noencryption no
|
||||
|
||||
|
||||
#####################################
|
||||
# time synchronization #
|
||||
#####################################
|
||||
|
||||
#config 'daemon' 'timesync'
|
||||
# option reference yes
|
||||
# option synchronize yes
|
||||
# option discovery_announcement yes
|
||||
# option sigma 1.001
|
||||
# option psi 0.9
|
||||
# option sync_level 0.1
|
||||
|
||||
#####################################
|
||||
# DHT #
|
||||
#####################################
|
||||
|
||||
config 'daemon' 'dht'
|
||||
# option 'enabled' 'yes'
|
||||
# option 'id' '<enter your unique id here>'
|
||||
option 'bootstrap' 'yes'
|
||||
# option 'nodesfile' '/tmp/dht_nodes.dat'
|
||||
option 'port' '9999'
|
||||
option 'enable_ipv6' 'no'
|
||||
# option 'enable_ipv4' 'no'
|
||||
# option 'bind_ipv4' '127.0.0.1'
|
||||
# option 'bind_ipv6' '::1'
|
||||
option 'ignore_neighbour_informations' 'yes'
|
||||
option 'allow_neighbours_to_announce_me' 'no'
|
||||
option 'allow_neighbour_announcement' 'no'
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This script creates a bundle storage of a given size.
|
||||
#
|
||||
# $1 = container file
|
||||
# $2 = size of the container in MB
|
||||
#
|
||||
|
||||
help_message() {
|
||||
echo "usage: "
|
||||
echo " $0 <container file> <size in MB>"
|
||||
}
|
||||
|
||||
if [ $# -le 1 ]; then
|
||||
help_message
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CONTAINER=$(cd "$(dirname "$1")"; pwd)/$(basename $1)
|
||||
SIZE=$2
|
||||
|
||||
# check if the container already exists
|
||||
if [ -f $CONTAINER ]; then
|
||||
echo "Aborted! The specified container already exists."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# create the container
|
||||
echo -n "creating the container file..."
|
||||
/bin/dd if=/dev/zero of=$CONTAINER bs=1M count=$SIZE >/dev/null 2>/dev/null
|
||||
echo " done"
|
||||
|
||||
# create file system
|
||||
echo -n "initializing ext3 filesystem for the container..."
|
||||
/usr/sbin/mkfs.ext3 -q -F $CONTAINER > /dev/null
|
||||
echo " done"
|
||||
|
||||
# final hint
|
||||
echo "The container is now ready. To use it with IBR-DTN set the container with:"
|
||||
echo "# uci set ibrdtn.storage.container=$CONTAINER"
|
||||
echo "# uci set ibrdtn.storage.container_size=$SIZE"
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,122 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
|
||||
CONTAINER=`/sbin/uci -q get ibrdtn.storage.container`
|
||||
CPATH=`/sbin/uci -q get ibrdtn.storage.path`
|
||||
|
||||
check_var() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "$2"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_path() {
|
||||
if [ ! -d "$1" ]; then
|
||||
echo "$2"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_file() {
|
||||
if [ ! -f "$1" ]; then
|
||||
echo "$2"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
container_mount() {
|
||||
CONTAINER=`/sbin/uci -q get ibrdtn.storage.container`
|
||||
CPATH=`/sbin/uci -q get ibrdtn.storage.path`
|
||||
|
||||
if [ -z "`mount | grep ' on $CPATH '`" ]; then
|
||||
# try to mount the container
|
||||
/bin/mount -o loop $CONTAINER $CPATH
|
||||
|
||||
return $?
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
container_reinitialize() {
|
||||
SIZE=`/sbin/uci get -q ibrdtn.storage.container_size`
|
||||
CONTAINER=`/sbin/uci -q get ibrdtn.storage.container`
|
||||
|
||||
# try to rebuild the container
|
||||
if [ -n "$SIZE" ]; then
|
||||
/bin/rm -f $CONTAINER
|
||||
/usr/share/ibrdtn/mkcontainer.sh $CONTAINER $SIZE
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
container_mount
|
||||
return $?
|
||||
fi
|
||||
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
check_var $CONTAINER "Storage container not set in uci.\nuse: uci set ibrdtn.storage.container=<container-file>"
|
||||
check_var $CPATH "Storage container mount path not set in uci.\nuse: uci set ibrdtn.storage.path=<mount-path>"
|
||||
|
||||
check_path $CPATH "Storage container mount path does not exist."
|
||||
if [ $? -gt 0 ]; then
|
||||
/bin/mkdir -p $CPATH
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
echo "can not create container mount path."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" == "-u" ]; then
|
||||
/bin/umount $CPATH
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "`/bin/mount | grep $CPATH`" ]; then
|
||||
echo "Container already mounted"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -f "$CONTAINER" ]; then
|
||||
echo "Storage container file $CONTAINER does not exist."
|
||||
container_reinitialize
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# try to mount the container
|
||||
container_mount
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
echo -n "can not mount container file. checking... "
|
||||
/usr/sbin/e2fsck -p $CONTAINER
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
echo " error"
|
||||
echo "Container file $CONTAINER broken. Try to reinitialize the container."
|
||||
container_reinitialize
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "container ready!"
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo "done"
|
||||
|
||||
container_mount
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
echo "mount failed!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "container ready!"
|
||||
exit 0
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# safety wrapper for IBR-DTN daemon
|
||||
#
|
||||
# Tasks:
|
||||
# * start IBR-DTN daemon
|
||||
# * restart the daemon after a crash
|
||||
# * if respawning to fast, then slow down with backoff
|
||||
# * check for enough space on disk and delete bundles if necessary.
|
||||
# * clean the blob directory on startup
|
||||
#
|
||||
|
||||
DTND=/usr/sbin/dtnd
|
||||
TMPCONF=/tmp/ibrdtn.config
|
||||
UCI=/sbin/uci
|
||||
|
||||
getstate() {
|
||||
$UCI -P/var/state -q get ibrdtn.$1
|
||||
return $?
|
||||
}
|
||||
|
||||
setstate() {
|
||||
$UCI -P/var/state -q set ibrdtn.$1=$2
|
||||
return $?
|
||||
}
|
||||
|
||||
getconfig() {
|
||||
$UCI -q get ibrdtn.$1
|
||||
return $?
|
||||
}
|
||||
|
||||
setconfig() {
|
||||
$UCI -q set ibrdtn.$1=$2
|
||||
return $?
|
||||
}
|
||||
|
||||
# remove the old state file
|
||||
/bin/rm /var/state/ibrdtn
|
||||
|
||||
# read uci configuration
|
||||
BLOB_PATH=`getconfig storage.blobs`
|
||||
BUNDLE_PATH=`getconfig storage.bundles`
|
||||
CONTAINER_PATH=`getconfig storage.path`
|
||||
CONTAINER_FILE=`getconfig storage.container`
|
||||
LOG_FILE=`getconfig main.logfile`
|
||||
ERR_FILE=`getconfig main.errfile`
|
||||
DEBUG_LEVEL=`getconfig main.debug`
|
||||
SAFEMODE=no
|
||||
|
||||
# run a system check
|
||||
/bin/sh /usr/share/ibrdtn/systemcheck.sh
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
# mount container if specified
|
||||
if [ -n "$CONTAINER_FILE" ] && [ -n "$CONTAINER_PATH" ]; then
|
||||
/bin/sh /usr/share/ibrdtn/mountcontainer.sh
|
||||
|
||||
# if the mount of the container failed
|
||||
# switch to safe mode!
|
||||
if [ $? -gt 0 ]; then
|
||||
SAFEMODE=yes
|
||||
fi
|
||||
fi
|
||||
else
|
||||
SAFEMODE=yes
|
||||
fi
|
||||
|
||||
# create blob & bundle path
|
||||
if [ -n "$BLOB_PATH" ]; then
|
||||
/bin/mkdir -p $BLOB_PATH
|
||||
|
||||
# clean the blob directory on startup
|
||||
/bin/rm -f $BLOB_PATH/file*
|
||||
fi
|
||||
|
||||
if [ -n "$BUNDLE_PATH" ]; then
|
||||
/bin/mkdir -p $BUNDLE_PATH
|
||||
fi
|
||||
|
||||
LOGGING=""
|
||||
if [ -n "$LOG_FILE" ]; then
|
||||
LOGGING="$LOGGING > $LOG_FILE"
|
||||
else
|
||||
LOGGING="$LOGGING > /dev/null"
|
||||
fi
|
||||
|
||||
if [ -n "$ERR_FILE" ]; then
|
||||
LOGGING="$LOGGING 2> $ERR_FILE"
|
||||
else
|
||||
LOGGING="$LOGGING 2> /dev/null"
|
||||
fi
|
||||
|
||||
if [ -z "$LOG_FILE" ] && [ -z "$ERR_FILE" ]; then
|
||||
LOGGING="-q"
|
||||
fi
|
||||
|
||||
# check for debugging option
|
||||
if [ -n "$DEBUG_LEVEL" ]; then
|
||||
DEBUG_ARGS="-v -d ${DEBUG_LEVEL}"
|
||||
else
|
||||
DEBUG_ARGS=""
|
||||
fi
|
||||
|
||||
# create configuration
|
||||
if [ "$SAFEMODE" == "yes" ]; then
|
||||
/bin/sh /usr/share/ibrdtn/build-config.sh --safe-mode $TMPCONF
|
||||
else
|
||||
/bin/sh /usr/share/ibrdtn/build-config.sh $TMPCONF
|
||||
fi
|
||||
|
||||
# set the crash counter to zero
|
||||
CRASH=0
|
||||
|
||||
# run the daemon
|
||||
setstate state running
|
||||
|
||||
while [ "`getstate state`" == "running" ]; do
|
||||
# run a system check
|
||||
/bin/sh /usr/share/ibrdtn/systemcheck.sh
|
||||
|
||||
# run in safe mode if the system check has failed
|
||||
if [ $? -gt 0 ] && [ "$SAFEMODE" == "no" ]; then
|
||||
SAFEMODE=yes
|
||||
/usr/bin/logger -t "ibrdtn-safe-wrapper" -p 2 "system check failed! Switch to safe-mode settings."
|
||||
/bin/sh /usr/share/ibrdtn/build-config.sh --safe-mode $TMPCONF
|
||||
fi
|
||||
|
||||
# measure the running time
|
||||
TIMESTART=`/bin/date +%s`
|
||||
|
||||
# run the daemon
|
||||
echo "${DTND} ${DEBUG_ARGS} -c ${TMPCONF} ${LOGGING}" | /bin/sh
|
||||
|
||||
# measure the stopping time
|
||||
TIMESTOP=`/bin/date +%s`
|
||||
|
||||
# calc the running time
|
||||
let TIMERUN=$TIMESTOP-$TIMESTART
|
||||
|
||||
# reset the CRASH counter if there is one hour between the crashes
|
||||
if [ $TIMERUN -ge 3600 ]; then
|
||||
CRASH=0
|
||||
fi
|
||||
|
||||
# check if the daemon is crashed
|
||||
if [ "`getstate state`" == "running" ]; then
|
||||
# if the crash counter is higher than 20 switch to safe-mode settings
|
||||
if [ $CRASH -eq 20 ] && [ "$SAFEMODE" == "no" ]; then
|
||||
SAFEMODE=yes
|
||||
/usr/bin/logger -t "ibrdtn-safe-wrapper" -p 2 "IBR-DTN daemon crashed 20 times! Switch to safe-mode settings."
|
||||
/bin/sh /usr/share/ibrdtn/build-config.sh --safe-mode $TMPCONF
|
||||
fi
|
||||
|
||||
# increment the crash counter
|
||||
let CRASH=$CRASH+1
|
||||
|
||||
# backoff wait timer
|
||||
let WAIT=2**$CRASH
|
||||
|
||||
# set a upper limit for the wait time
|
||||
if [ $WAIT -ge 1800 ]; then
|
||||
WAIT=1800
|
||||
fi
|
||||
|
||||
# log the crash
|
||||
/usr/bin/logger -t "ibrdtn-safe-wrapper" -p 2 "IBR-DTN daemon crashed $CRASH times! Wait $WAIT seconds."
|
||||
|
||||
# wait sometime
|
||||
/bin/sleep $WAIT
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
|
||||
check_mounted() {
|
||||
DIR=$1
|
||||
while [ "$DIR" != "/" ]; do
|
||||
if [ -n "`mount | grep "$DIR"`" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
DIR=`dirname $DIR`
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
check_writable() {
|
||||
CHECKFILE="$1/.container-lock"
|
||||
/bin/touch $CHECKFILE
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
return 1;
|
||||
fi
|
||||
|
||||
/bin/echo "0123456789" >> $CHECKFILE
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
return 2;
|
||||
fi
|
||||
|
||||
/bin/rm $CHECKFILE
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
return 3;
|
||||
fi
|
||||
}
|
||||
|
||||
check_mountdev() {
|
||||
# get wait_mount option
|
||||
WAIT_MOUNT_DEV=`uci -q get ibrdtn.safemode.wait_mount`
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
DATA=`mount | grep ${WAIT_MOUNT_DEV}`
|
||||
|
||||
if [ -n "${DATA}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# check the storage device
|
||||
check_mountdev
|
||||
RET=$?
|
||||
|
||||
if [ ${RET} -ne 0 ]; then
|
||||
WAIT_SECONDS=60
|
||||
/usr/bin/logger -t "systemcheck.sh" -p 2 "disk storage not ready, wait max. ${WAIT_SECONDS} seconds until it is mounted"
|
||||
while [ ${RET} -ne 0 ] && [ ${WAIT_SECONDS} -ne 0 ]; do
|
||||
sleep 1
|
||||
let WAIT_SECONDS=WAIT_SECONDS-1
|
||||
check_mountdev
|
||||
RET=$?
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ${RET} -ne 0 ]; then
|
||||
# failed, storage not mounted
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get the path for the container
|
||||
CONTAINER=`uci -q get ibrdtn.storage.container`
|
||||
|
||||
if [ -z "$CONTAINER" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CONTAINER_PATH=`dirname $CONTAINER`
|
||||
|
||||
if [ -n "$CONTAINER_PATH" ]; then
|
||||
# check if the container is on a mounted device
|
||||
check_mounted $CONTAINER_PATH
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
# failed
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if the device is writable
|
||||
check_writable $CONTAINER_PATH
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
# failed
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -333,30 +333,46 @@ AS_IF([test "x$enable_android" = "xyes"], [
|
||||
dnl optional parameter: Wifi-P2P support
|
||||
dnl -----------------------------------------------
|
||||
|
||||
- PKG_CHECK_MODULES([WIFIP2P], wifip2p >= 0.1 , [
|
||||
- with_wifi_p2p="yes"
|
||||
- AC_SUBST(WIFIP2P_CFLAGS)
|
||||
- AC_SUBST(WIFIP2P_LIBS)
|
||||
- AC_DEFINE(WITH_WIFIP2P, [1], ["wifi-p2p support enabled"])
|
||||
- ], [
|
||||
- with_wifi_p2p="no"
|
||||
- AC_MSG_WARN([wifi-p2p library not found. wifi-p2p support is disabled.])
|
||||
- ])
|
||||
+ AC_ARG_WITH([wifip2p],
|
||||
+ AS_HELP_STRING([--without-wifip2p], [Build without wifip2p support]),
|
||||
+ [
|
||||
+ with_wifi_p2p="no"
|
||||
+ AC_MSG_NOTICE([WIFIP2P support disabled])
|
||||
+ ], [
|
||||
+ PKG_CHECK_MODULES([WIFIP2P], wifip2p >= 0.1 , [
|
||||
+ with_wifi_p2p="yes"
|
||||
+ AC_SUBST(WIFIP2P_CFLAGS)
|
||||
+ AC_SUBST(WIFIP2P_LIBS)
|
||||
+ AC_DEFINE(WITH_WIFIP2P, [1], ["wifi-p2p support enabled"])
|
||||
+ ], [
|
||||
+ with_wifi_p2p="no"
|
||||
+ AC_MSG_WARN([wifi-p2p library not found. wifi-p2p support is disabled.])
|
||||
+ ])
|
||||
+ ]
|
||||
+ )
|
||||
|
||||
- dnl -----------------------------------------------
|
||||
- dnl optional parameter: VMime support
|
||||
- dnl -----------------------------------------------
|
||||
-
|
||||
- PKG_CHECK_MODULES([VMIME], vmime >= 0.9.1 , [
|
||||
- with_vmime="yes"
|
||||
- AC_SUBST(VMIME_CFLAGS)
|
||||
- AC_SUBST(VMIME_LIBS)
|
||||
- AC_DEFINE(HAVE_VMIME, [1], ["Email Convergence Layer is available"])
|
||||
- AC_CHECK_HEADERS([vmime/utility/smartPtrInt.hpp])
|
||||
- ], [
|
||||
- with_vmime="no"
|
||||
- AC_MSG_WARN([VMime library not found. Email Convergence Layer is disabled.])
|
||||
- ])
|
||||
+ dnl -----------------------------------------------
|
||||
+ dnl optional parameter: VMime support
|
||||
+ dnl -----------------------------------------------
|
||||
+
|
||||
+ AC_ARG_WITH([vmime],
|
||||
+ AS_HELP_STRING([--without-vmime], [Build without vmime support]),
|
||||
+ [
|
||||
+ with_vmime="no"
|
||||
+ AC_MSG_NOTICE([VMIME support disabled])
|
||||
+ ], [
|
||||
+ PKG_CHECK_MODULES([VMIME], vmime >= 0.9.1 , [
|
||||
+ with_vmime="yes"
|
||||
+ AC_SUBST(VMIME_CFLAGS)
|
||||
+ AC_SUBST(VMIME_LIBS)
|
||||
+ AC_DEFINE(HAVE_VMIME, [1], ["Email Convergence Layer is available"])
|
||||
+ AC_CHECK_HEADERS([vmime/utility/smartPtrInt.hpp])
|
||||
+ ], [
|
||||
+ with_vmime="no"
|
||||
+ AC_MSG_WARN([VMime library not found. Email Convergence Layer is disabled.])
|
||||
+ ])
|
||||
+ ]
|
||||
+ )
|
||||
|
||||
dnl -----------------------------------------------
|
||||
dnl check for regex capabilities
|
||||
--
|
||||
1.9.1
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
#
|
||||
# Copyright (C) 2006-2011 OpenWrt.org
|
||||
# 2014 Noah Meyerhans <frodo@morgul.net>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=ipsec-tools
|
||||
PKG_VERSION:=0.8.2
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER := "Noah Meyerhans <frodo@morgul.net>"
|
||||
PKG_LICENSE := BSD-3-Clause
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=@SF/ipsec-tools
|
||||
PKG_MD5SUM:=d53ec14a0a3ece64e09e5e34b3350b41
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ipsec-tools
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=VPN
|
||||
DEPENDS:=+libopenssl +kmod-ipsec
|
||||
TITLE:=IPsec management tools
|
||||
URL:=http://ipsec-tools.sourceforge.net/
|
||||
MAINTAINER:=Noah Meyerhans <frodo@morgul.net>
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-shared \
|
||||
--enable-static \
|
||||
--with-kernel-headers="$(LINUX_DIR)/include" \
|
||||
--without-readline \
|
||||
--with-openssl="$(STAGING_DIR)/usr" \
|
||||
--without-libradius \
|
||||
--without-libpam \
|
||||
--enable-dpd \
|
||||
--enable-hybrid \
|
||||
--enable-security-context=no \
|
||||
--enable-natt \
|
||||
--enable-adminport \
|
||||
--enable-frag \
|
||||
$(call autoconf_bool,CONFIG_IPV6,ipv6)
|
||||
|
||||
# override CFLAGS holding "-Werror" that break builds on compile warnings
|
||||
MAKE_FLAGS+=\
|
||||
CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)"
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
chmod -R u+w $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
(cd $(PKG_BUILD_DIR); touch \
|
||||
configure.ac \
|
||||
aclocal.m4 \
|
||||
Makefile.in \
|
||||
config.h.in \
|
||||
configure \
|
||||
);
|
||||
$(call Build/Configure/Default)
|
||||
echo "#undef HAVE_SHADOW_H" >> $(PKG_BUILD_DIR)/config.h
|
||||
endef
|
||||
|
||||
define Package/ipsec-tools/install
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/src/racoon/samples/racoon.conf $(1)/etc/
|
||||
$(SED) 's|@sysconfdir_x@|/etc|g' $(1)/etc/racoon.conf
|
||||
$(INSTALL_DIR) $(1)/etc/racoon
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/src/racoon/samples/psk.txt $(1)/etc/racoon/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/racoon.init $(1)/etc/init.d/racoon
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libipsec.so.* $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libracoon.so.* $(1)/usr/lib/
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/plainrsa-gen $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/racoon $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/racoonctl $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/setkey $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
define Package/ipsec-tools/conffiles
|
||||
/etc/racoon.conf
|
||||
/etc/racoon/psk.txt
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ipsec-tools))
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2009-2011 OpenWrt.org
|
||||
# Copyright (C) 2011 Artem Makhutov
|
||||
|
||||
START=49
|
||||
|
||||
SERVICE_USE_PID=1
|
||||
|
||||
start() {
|
||||
mkdir -m 0700 -p /var/racoon
|
||||
[ -f /etc/ipsec.conf ] && /usr/sbin/setkey -f /etc/ipsec.conf
|
||||
service_start /usr/sbin/racoon -f /etc/racoon.conf
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /usr/sbin/racoon
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
--- a/src/racoon/oakley.c
|
||||
+++ b/src/racoon/oakley.c
|
||||
@@ -2424,8 +2424,21 @@ oakley_skeyid(iph1)
|
||||
plog(LLV_ERROR, LOCATION, iph1->remote,
|
||||
"couldn't find the pskey for %s.\n",
|
||||
saddrwop2str(iph1->remote));
|
||||
+ }
|
||||
+ }
|
||||
+ if (iph1->authstr == NULL) {
|
||||
+ /*
|
||||
+ * If we could not locate a psk above try and locate
|
||||
+ * the default psk, ie, "*".
|
||||
+ */
|
||||
+ iph1->authstr = privsep_getpsk("*", 1);
|
||||
+ if (iph1->authstr == NULL) {
|
||||
+ plog(LLV_ERROR, LOCATION, iph1->remote,
|
||||
+ "couldn't find the the default pskey either.\n");
|
||||
goto end;
|
||||
}
|
||||
+ plog(LLV_NOTIFY, LOCATION, iph1->remote,
|
||||
+ "Using default PSK.\n");
|
||||
}
|
||||
plog(LLV_DEBUG, LOCATION, NULL, "the psk found.\n");
|
||||
/* should be secret PSK */
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/src/racoon/cftoken.l
|
||||
+++ b/src/racoon/cftoken.l
|
||||
@@ -104,6 +104,8 @@ static struct include_stack {
|
||||
static int incstackp = 0;
|
||||
|
||||
static int yy_first_time = 1;
|
||||
+
|
||||
+int yywrap(void) { return 1; }
|
||||
%}
|
||||
|
||||
/* common seciton */
|
||||
--- a/src/setkey/token.l
|
||||
+++ b/src/setkey/token.l
|
||||
@@ -86,6 +86,8 @@
|
||||
#if defined(SADB_X_EALG_AES) && ! defined(SADB_X_EALG_AESCBC)
|
||||
#define SADB_X_EALG_AESCBC SADB_X_EALG_AES
|
||||
#endif
|
||||
+
|
||||
+int yywrap(void) { return 1; }
|
||||
%}
|
||||
|
||||
/* common section */
|
||||
@@ -0,0 +1,72 @@
|
||||
--- a/src/racoon/isakmp_cfg.c
|
||||
+++ b/src/racoon/isakmp_cfg.c
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
-#include <utmpx.h>
|
||||
+#include <utmp.h>
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
#include <util.h>
|
||||
#endif
|
||||
@@ -1661,7 +1661,8 @@ isakmp_cfg_accounting_system(port, raddr
|
||||
int inout;
|
||||
{
|
||||
int error = 0;
|
||||
- struct utmpx ut;
|
||||
+ struct utmp ut;
|
||||
+ char term[UT_LINESIZE];
|
||||
char addr[NI_MAXHOST];
|
||||
|
||||
if (usr == NULL || usr[0]=='\0') {
|
||||
@@ -1670,34 +1671,37 @@ isakmp_cfg_accounting_system(port, raddr
|
||||
return -1;
|
||||
}
|
||||
|
||||
- memset(&ut, 0, sizeof ut);
|
||||
- gettimeofday((struct timeval *)&ut.ut_tv, NULL);
|
||||
- snprintf(ut.ut_id, sizeof ut.ut_id, TERMSPEC, port);
|
||||
+ sprintf(term, TERMSPEC, port);
|
||||
|
||||
switch (inout) {
|
||||
case ISAKMP_CFG_LOGIN:
|
||||
- ut.ut_type = USER_PROCESS;
|
||||
- strncpy(ut.ut_user, usr, sizeof ut.ut_user);
|
||||
+ strncpy(ut.ut_name, usr, UT_NAMESIZE);
|
||||
+ ut.ut_name[UT_NAMESIZE - 1] = '\0';
|
||||
+
|
||||
+ strncpy(ut.ut_line, term, UT_LINESIZE);
|
||||
+ ut.ut_line[UT_LINESIZE - 1] = '\0';
|
||||
|
||||
GETNAMEINFO_NULL(raddr, addr);
|
||||
- strncpy(ut.ut_host, addr, sizeof ut.ut_host);
|
||||
+ strncpy(ut.ut_host, addr, UT_HOSTSIZE);
|
||||
+ ut.ut_host[UT_HOSTSIZE - 1] = '\0';
|
||||
+
|
||||
+ ut.ut_time = time(NULL);
|
||||
|
||||
plog(LLV_INFO, LOCATION, NULL,
|
||||
"Accounting : '%s' logging on '%s' from %s.\n",
|
||||
- ut.ut_user, ut.ut_id, addr);
|
||||
-
|
||||
- pututxline(&ut);
|
||||
+ ut.ut_name, ut.ut_line, ut.ut_host);
|
||||
|
||||
+ login(&ut);
|
||||
+
|
||||
break;
|
||||
case ISAKMP_CFG_LOGOUT:
|
||||
- ut.ut_type = DEAD_PROCESS;
|
||||
|
||||
plog(LLV_INFO, LOCATION, NULL,
|
||||
"Accounting : '%s' unlogging from '%s'.\n",
|
||||
- usr, ut.ut_id);
|
||||
-
|
||||
- pututxline(&ut);
|
||||
+ usr, term);
|
||||
|
||||
+ logout(term);
|
||||
+
|
||||
break;
|
||||
default:
|
||||
plog(LLV_ERROR, LOCATION, NULL, "Unepected inout\n");
|
||||
@@ -0,0 +1,13 @@
|
||||
--- a/src/racoon/ipsec_doi.c
|
||||
+++ b/src/racoon/ipsec_doi.c
|
||||
@@ -3582,8 +3582,8 @@ ipsecdoi_checkid1(iph1)
|
||||
iph1->approval->authmethod == OAKLEY_ATTR_AUTH_METHOD_PSKEY) {
|
||||
if (id_b->type != IPSECDOI_ID_IPV4_ADDR
|
||||
&& id_b->type != IPSECDOI_ID_IPV6_ADDR) {
|
||||
- plog(LLV_ERROR, LOCATION, NULL,
|
||||
- "Expecting IP address type in main mode, "
|
||||
+ plog(LLV_WARNING, LOCATION, NULL,
|
||||
+ "Expecting IP address type in main mode (RFC2409) , "
|
||||
"but %s.\n", s_ipsecdoi_ident(id_b->type));
|
||||
return ISAKMP_NTYPE_INVALID_ID_INFORMATION;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/src/racoon/isakmp.c
|
||||
+++ b/src/racoon/isakmp.c
|
||||
@@ -31,6 +31,8 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
+#define __packed __attribute__((__packed__))
|
||||
+
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -0,0 +1,50 @@
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -74,9 +74,10 @@ case "$host_os" in
|
||||
[ KERNEL_INCLUDE="/lib/modules/`uname -r`/build/include" ])
|
||||
|
||||
AC_CHECK_HEADER($KERNEL_INCLUDE/linux/pfkeyv2.h, ,
|
||||
- [ AC_CHECK_HEADER(/usr/src/linux/include/linux/pfkeyv2.h,
|
||||
- KERNEL_INCLUDE=/usr/src/linux/include ,
|
||||
- [ AC_MSG_ERROR([Unable to find linux-2.6 kernel headers. Aborting.]) ] ) ] )
|
||||
+ [ AC_CHECK_HEADER($KERNEL_INCLUDE/uapi/linux/pfkeyv2.h, ,
|
||||
+ [ AC_CHECK_HEADER(/usr/src/linux/include/linux/pfkeyv2.h,
|
||||
+ KERNEL_INCLUDE=/usr/src/linux/include ,
|
||||
+ [ AC_MSG_ERROR([Unable to find linux-2.6 kernel headers. Aborting.]) ] ) ] ) ] )
|
||||
AC_SUBST(KERNEL_INCLUDE)
|
||||
# We need the configure script to run with correct kernel headers.
|
||||
# However we don't want to point to kernel source tree in compile time,
|
||||
@@ -643,7 +644,14 @@ AC_EGREP_CPP(yes,
|
||||
#ifdef SADB_X_EXT_NAT_T_TYPE
|
||||
yes
|
||||
#endif
|
||||
-], [kernel_natt="yes"])
|
||||
+], [kernel_natt="yes"], [
|
||||
+ AC_EGREP_CPP(yes,
|
||||
+ [#include <uapi/linux/pfkeyv2.h>
|
||||
+ #ifdef SADB_X_EXT_NAT_T_TYPE
|
||||
+ yes
|
||||
+ #endif
|
||||
+ ], [kernel_natt="yes"])
|
||||
+])
|
||||
;;
|
||||
freebsd*|netbsd*)
|
||||
# NetBSD case
|
||||
--- a/src/include-glibc/Makefile.am
|
||||
+++ b/src/include-glibc/Makefile.am
|
||||
@@ -1,14 +1,7 @@
|
||||
-
|
||||
-.includes: ${top_builddir}/config.status
|
||||
- ln -snf $(KERNEL_INCLUDE)/linux
|
||||
- touch .includes
|
||||
-
|
||||
-all: .includes
|
||||
-
|
||||
EXTRA_DIST = \
|
||||
glibc-bugs.h \
|
||||
net/pfkeyv2.h \
|
||||
netinet/ipsec.h \
|
||||
sys/queue.h
|
||||
|
||||
-DISTCLEANFILES = .includes linux
|
||||
+DISTCLEANFILES = linux
|
||||
@@ -0,0 +1,14 @@
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 8506245..eca8895 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -724,7 +724,8 @@ case $host in
|
||||
],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_POLICY_FWD], [], [Have forward policy])],
|
||||
- [AC_MSG_RESULT(no)])
|
||||
+ [AC_MSG_RESULT(forced)
|
||||
+ AC_DEFINE([HAVE_POLICY_FWD], [], [Have forward policy])])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
+2
-2
@@ -8,13 +8,13 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=knot
|
||||
PKG_VERSION:=1.5.0
|
||||
PKG_VERSION:=1.5.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_URL:=https://secure.nic.cz/files/knot-dns/
|
||||
PKG_MD5SUM:=d677de99c19afea3b1e8ef075a9d5a8b
|
||||
PKG_MD5SUM:=4109648a538d35babea8379993c34996
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
@@ -9,12 +9,14 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mosquitto
|
||||
PKG_VERSION:=1.3.2
|
||||
PKG_VERSION:=1.3.4
|
||||
PKG_RELEASE:=1
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILE:=LICENSE.txt
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://mosquitto.org/files/source/
|
||||
PKG_MD5SUM:=5d2fe7c8bf2518eb9829547751c04bbf
|
||||
PKG_MD5SUM:=9d729849efd74c6e3eee17a4a002e1e9
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
@@ -44,9 +46,9 @@ define Package/$(PKG_NAME)-nossl
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/default/description
|
||||
mosquitto is a message broker that supports v3.1 of the MQ Telemetry
|
||||
Transport protocol. MQTT provides a lightweight method for
|
||||
messaging using a publish/subscribe model.
|
||||
Mosquitto is an open source (BSD licensed) message broker that implements
|
||||
the MQTT protocol version 3.1 and 3.1.1. MQTT provides a lightweight
|
||||
method of carrying out messaging using a publish/subscribe model.
|
||||
|
||||
This package also includes some basic support for configuring via UCI
|
||||
endef
|
||||
@@ -119,7 +121,7 @@ define Package/libmosquitto/default/description
|
||||
use by any third party software that wants to communicate with a
|
||||
mosquitto server.
|
||||
|
||||
Should be useable for communicating with any MQTT v3.1 compatible
|
||||
Should be useable for communicating with any MQTT v3.1/3.1.1 compatible
|
||||
server, such as IBM's RSMB, in addition to Mosquitto
|
||||
endef
|
||||
|
||||
|
||||
+3
-1
@@ -14,6 +14,8 @@ PKG_RELEASE:=1
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=ftp://ftp.bitwizard.nl/mtr
|
||||
PKG_MD5SUM:=5e665c617e5659b6ec3e201ee7488eb1
|
||||
PKG_LICENSE:=GPL-2.0+
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
PKG_INSTALL:=1
|
||||
|
||||
@@ -27,7 +29,7 @@ define Package/mtr
|
||||
DEPENDS:=+libncurses
|
||||
TITLE:=Full screen ncurses traceroute tool
|
||||
URL:=http://www.bitwizard.nl/mtr/
|
||||
MAINTAINER:=Jonathan McCrohan <jmccrohan@gmail.com>
|
||||
PKG_MAINTAINER:=Jonathan McCrohan <jmccrohan@gmail.com>
|
||||
endef
|
||||
|
||||
define Package/mtr/description
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# Copyright (C) 2006-2014 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:=luci-app-mwan3
|
||||
PKG_VERSION:=1.3
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER:=Aedan Renner <chipdankly@gmail.com>
|
||||
PKG_LICENSE:=GPLv2
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/luci-app-mwan3
|
||||
SECTION:=LuCI
|
||||
CATEGORY:=LuCI
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:=LuCI support for the MWAN3 multiwan hotplug script
|
||||
DEPENDS:=+mwan3
|
||||
PKGARCH:=all
|
||||
MAINTAINER:=Aedan Renner <chipdankly@gmail.com>
|
||||
endef
|
||||
|
||||
define Package/luci-app-mwan3/description
|
||||
Hotplug script which makes configuration of multiple WAN interfaces simple and manageable
|
||||
With loadbalancing/failover support for up to 250 WAN interfaces, connection tracking and an easy to manage traffic ruleset
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/luci-app-mwan3/install
|
||||
$(CP) ./files/* $(1)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,luci-app-mwan3))
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
# to enable this script uncomment the case loop at the bottom
|
||||
# to report MWAN3 status on interface up/down events modify the lines in the send_reportdata function
|
||||
|
||||
send_alert()
|
||||
{
|
||||
# $1 stores the mwan3 status information
|
||||
# insert your code here to send the contents of $1
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
gather_event_info()
|
||||
{
|
||||
# create event information message
|
||||
local EVENT_INFO="Interface [ "$INTERFACE" ($DEVICE) ] on router [ "$(uci get -p /var/state system.@system[0].hostname)" ] has triggered an [ "$ACTION" ] hotplug event on "$(date)""
|
||||
|
||||
# get current interface, policy and rule status
|
||||
local CURRENT_STATUS="$(mwan3 status)"
|
||||
|
||||
# get last 50 mwan3 systemlog messages
|
||||
local MWAN3_LOG="$(echo -e "Last 50 MWAN3 systemlog entries. Newest entries sorted at the top:\n$(logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x')")"
|
||||
|
||||
# pass event info to send_alert function
|
||||
send_alert "$(echo -e "$EVENT_INFO\n\n$CURRENT_STATUS\n\n$MWAN3_LOG")"
|
||||
}
|
||||
|
||||
#case "$ACTION" in
|
||||
# ifup)
|
||||
# gather_event_info
|
||||
# ;;
|
||||
#
|
||||
# ifdown)
|
||||
# gather_event_info
|
||||
# ;;
|
||||
#esac
|
||||
|
||||
exit 0
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# delete existing mwan3 ucitrack entry and add new entry
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
del ucitrack.@mwan3[-1]
|
||||
add ucitrack mwan3
|
||||
set ucitrack.@mwan3[-1].exec="/etc/init.d/mwan3 restart"
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
# make controller file addition take effect without system restart
|
||||
rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,355 @@
|
||||
module("luci.controller.mwan3", package.seeall)
|
||||
|
||||
sys = require "luci.sys"
|
||||
ut = require "luci.util"
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/mwan3") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "network", "mwan3"},
|
||||
alias("admin", "network", "mwan3", "overview"),
|
||||
_("Load Balancing"), 600)
|
||||
|
||||
entry({"admin", "network", "mwan3", "overview"},
|
||||
alias("admin", "network", "mwan3", "overview", "over_iface"),
|
||||
_("Overview"), 10)
|
||||
entry({"admin", "network", "mwan3", "overview", "over_iface"},
|
||||
template("mwan3/mwan3_over_interface"))
|
||||
entry({"admin", "network", "mwan3", "overview", "iface_status"},
|
||||
call("mwan3_iface_status"))
|
||||
entry({"admin", "network", "mwan3", "overview", "over_detail"},
|
||||
template("mwan3/mwan3_over_detail"))
|
||||
entry({"admin", "network", "mwan3", "overview", "detail_status"},
|
||||
call("mwan3_detail_status"))
|
||||
|
||||
entry({"admin", "network", "mwan3", "configuration"},
|
||||
alias("admin", "network", "mwan3", "configuration", "interface"),
|
||||
_("Configuration"), 20)
|
||||
entry({"admin", "network", "mwan3", "configuration", "interface"},
|
||||
arcombine(cbi("mwan3/mwan3_interface"), cbi("mwan3/mwan3_interfaceconfig")),
|
||||
_("Interfaces"), 10).leaf = true
|
||||
entry({"admin", "network", "mwan3", "configuration", "member"},
|
||||
arcombine(cbi("mwan3/mwan3_member"), cbi("mwan3/mwan3_memberconfig")),
|
||||
_("Members"), 20).leaf = true
|
||||
entry({"admin", "network", "mwan3", "configuration", "policy"},
|
||||
arcombine(cbi("mwan3/mwan3_policy"), cbi("mwan3/mwan3_policyconfig")),
|
||||
_("Policies"), 30).leaf = true
|
||||
entry({"admin", "network", "mwan3", "configuration", "rule"},
|
||||
arcombine(cbi("mwan3/mwan3_rule"), cbi("mwan3/mwan3_ruleconfig")),
|
||||
_("Rules"), 40).leaf = true
|
||||
|
||||
entry({"admin", "network", "mwan3", "advanced"},
|
||||
alias("admin", "network", "mwan3", "advanced", "hotplug"),
|
||||
_("Advanced"), 100)
|
||||
entry({"admin", "network", "mwan3", "advanced", "hotplug"},
|
||||
form("mwan3/mwan3_adv_hotplug"))
|
||||
entry({"admin", "network", "mwan3", "advanced", "mwan3"},
|
||||
form("mwan3/mwan3_adv_mwan3"))
|
||||
entry({"admin", "network", "mwan3", "advanced", "network"},
|
||||
form("mwan3/mwan3_adv_network"))
|
||||
entry({"admin", "network", "mwan3", "advanced", "diag"},
|
||||
template("mwan3/mwan3_adv_diagnostics"))
|
||||
entry({"admin", "network", "mwan3", "advanced", "diag_display"},
|
||||
call("mwan3_diag_data"), nil).leaf = true
|
||||
entry({"admin", "network", "mwan3", "advanced", "tshoot"},
|
||||
template("mwan3/mwan3_adv_troubleshoot"))
|
||||
entry({"admin", "network", "mwan3", "advanced", "tshoot_display"},
|
||||
call("mwan3_tshoot_data"))
|
||||
end
|
||||
|
||||
function mwan3_get_iface_status(rulenum, ifname)
|
||||
if ut.trim(sys.exec("uci get -p /var/state mwan3." .. ifname .. ".enabled")) == "1" then
|
||||
if ut.trim(sys.exec("ip route list table " .. rulenum)) ~= "" then
|
||||
if ut.trim(sys.exec("uci get -p /var/state mwan3." .. ifname .. ".track_ip")) ~= "" then
|
||||
return "on"
|
||||
else
|
||||
return "nm"
|
||||
end
|
||||
else
|
||||
return "off"
|
||||
end
|
||||
else
|
||||
return "ne"
|
||||
end
|
||||
end
|
||||
|
||||
function mwan3_get_iface()
|
||||
local rulenum, str = 0, ""
|
||||
uci.cursor():foreach("mwan3", "interface",
|
||||
function (section)
|
||||
rulenum = rulenum+1
|
||||
str = str .. section[".name"] .. "[" .. mwan3_get_iface_status(rulenum, section[".name"]) .. "]"
|
||||
end
|
||||
)
|
||||
return str
|
||||
end
|
||||
|
||||
function mwan3_iface_status()
|
||||
local ntm = require "luci.model.network".init()
|
||||
|
||||
local rv = { }
|
||||
|
||||
-- overview status
|
||||
local statstr = mwan3_get_iface()
|
||||
if statstr ~= "" then
|
||||
rv.wans = { }
|
||||
wansid = {}
|
||||
|
||||
for wanname, ifstat in string.gfind(statstr, "([^%[]+)%[([^%]]+)%]") do
|
||||
local wanifname = ut.trim(sys.exec("uci get -p /var/state network." .. wanname .. ".ifname"))
|
||||
if wanifname == "" then
|
||||
wanifname = "X"
|
||||
end
|
||||
local wanlink = ntm:get_interface(wanifname)
|
||||
wanlink = wanlink and wanlink:get_network()
|
||||
wanlink = wanlink and wanlink:adminlink() or "#"
|
||||
wansid[wanname] = #rv.wans + 1
|
||||
rv.wans[wansid[wanname]] = { name = wanname, link = wanlink, ifname = wanifname, status = ifstat }
|
||||
end
|
||||
end
|
||||
|
||||
-- overview status log
|
||||
local mwlg = ut.trim(sys.exec("logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x'"))
|
||||
if mwlg ~= "" then
|
||||
rv.mwan3log = { }
|
||||
mwlog = {}
|
||||
mwlog[mwlg] = #rv.mwan3log + 1
|
||||
rv.mwan3log[mwlog[mwlg]] = { mwanlog = mwlg }
|
||||
end
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(rv)
|
||||
end
|
||||
|
||||
function mwan3_detail_status()
|
||||
local rv = { }
|
||||
|
||||
-- detailed mwan3 status
|
||||
local dst = ut.trim(sys.exec("mwan3 status"))
|
||||
if dst ~= "" then
|
||||
rv.mwan3dst = { }
|
||||
dstat = {}
|
||||
dstat[dst] = #rv.mwan3dst + 1
|
||||
rv.mwan3dst[dstat[dst]] = { detailstat = dst }
|
||||
end
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(rv)
|
||||
end
|
||||
|
||||
function mwan3_diag_data(iface, tool, alt)
|
||||
function get_ifnum()
|
||||
local num = 0
|
||||
uci.cursor():foreach("mwan3", "interface",
|
||||
function (section)
|
||||
num = num+1
|
||||
if section[".name"] == iface then
|
||||
ifnum = num
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
local rv = { }
|
||||
|
||||
local res = ""
|
||||
if tool == "service" then
|
||||
os.execute("mwan3 " .. alt)
|
||||
if alt == "restart" then
|
||||
res = "MWAN3 restarted"
|
||||
elseif alt == "stop" then
|
||||
res = "MWAN3 stopped"
|
||||
else
|
||||
res = "MWAN3 started"
|
||||
end
|
||||
else
|
||||
local ifdev = ut.trim(sys.exec("uci get -p /var/state network." .. iface .. ".ifname"))
|
||||
if ifdev ~= "" then
|
||||
if tool == "ping" then
|
||||
local gateway = ut.trim(sys.exec("route -n | awk -F' ' '{ if ($8 == \"" .. ifdev .. "\" && $1 == \"0.0.0.0\") print $2 }'"))
|
||||
if gateway ~= "" then
|
||||
if alt == "gateway" then
|
||||
local cmd = "ping -c 3 -W 2 -I " .. ifdev .. " " .. gateway
|
||||
res = cmd .. "\n\n" .. sys.exec(cmd)
|
||||
else
|
||||
local str = ut.trim(sys.exec("uci get -p /var/state mwan3." .. iface .. ".track_ip"))
|
||||
if str ~= "" then
|
||||
for z in str:gmatch("[^ ]+") do
|
||||
local cmd = "ping -c 3 -W 2 -I " .. ifdev .. " " .. z
|
||||
res = res .. cmd .. "\n\n" .. sys.exec(cmd) .. "\n\n"
|
||||
end
|
||||
else
|
||||
res = "No tracking IP addresses configured on " .. iface
|
||||
end
|
||||
end
|
||||
else
|
||||
res = "No default gateway for " .. iface .. " found. Default route does not exist or is configured incorrectly"
|
||||
end
|
||||
elseif tool == "rulechk" then
|
||||
get_ifnum()
|
||||
local rule1 = sys.exec("ip rule | grep $(echo $((" .. ifnum .. " + 1000)))")
|
||||
local rule2 = sys.exec("ip rule | grep $(echo $((" .. ifnum .. " + 2000)))")
|
||||
if rule1 ~= "" and rule2 ~= "" then
|
||||
res = "All required interface IP rules found:\n\n" .. rule1 .. rule2
|
||||
elseif rule1 ~= "" or rule2 ~= "" then
|
||||
res = "Missing 1 of the 2 required interface IP rules\n\n\nRules found:\n\n" .. rule1 .. rule2
|
||||
else
|
||||
res = "Missing both of the required interface IP rules"
|
||||
end
|
||||
elseif tool == "routechk" then
|
||||
get_ifnum()
|
||||
local table = sys.exec("ip route list table " .. ifnum)
|
||||
if table ~= "" then
|
||||
res = "Interface routing table " .. ifnum .. " was found:\n\n" .. table
|
||||
else
|
||||
res = "Missing required interface routing table " .. ifnum
|
||||
end
|
||||
elseif tool == "hotplug" then
|
||||
if alt == "ifup" then
|
||||
os.execute("mwan3 ifup " .. iface)
|
||||
res = "Hotplug ifup sent to interface " .. iface .. "..."
|
||||
else
|
||||
os.execute("mwan3 ifdown " .. iface)
|
||||
res = "Hotplug ifdown sent to interface " .. iface .. "..."
|
||||
end
|
||||
end
|
||||
else
|
||||
res = "Unable to perform diagnostic tests on " .. iface .. ". There is no physical or virtual device associated with this interface"
|
||||
end
|
||||
end
|
||||
if res ~= "" then
|
||||
res = ut.trim(res)
|
||||
rv.diagres = { }
|
||||
dres = {}
|
||||
dres[res] = #rv.diagres + 1
|
||||
rv.diagres[dres[res]] = { diagresult = res }
|
||||
end
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(rv)
|
||||
end
|
||||
|
||||
function mwan3_tshoot_data()
|
||||
local rv = { }
|
||||
|
||||
-- software versions
|
||||
local wrtrelease = ut.trim(luci.version.distversion)
|
||||
if wrtrelease ~= "" then
|
||||
wrtrelease = "OpenWrt - " .. wrtrelease
|
||||
else
|
||||
wrtrelease = "OpenWrt - unknown"
|
||||
end
|
||||
local lucirelease = ut.trim(luci.version.luciversion)
|
||||
if lucirelease ~= "" then
|
||||
lucirelease = "\nLuCI - " .. lucirelease
|
||||
else
|
||||
lucirelease = "\nLuCI - unknown"
|
||||
end
|
||||
local mwan3version = ut.trim(sys.exec("opkg info mwan3 | grep Version | awk -F' ' '{ print $2 }'"))
|
||||
if mwan3version ~= "" then
|
||||
mwan3version = "\n\nmwan3 - " .. mwan3version
|
||||
else
|
||||
mwan3version = "\nmwan3 - unknown"
|
||||
end
|
||||
local mwan3lversion = ut.trim(sys.exec("opkg info luci-app-mwan3 | grep Version | awk -F' ' '{ print $2 }'"))
|
||||
if mwan3lversion ~= "" then
|
||||
mwan3lversion = "\nluci-app-mwan3 - " .. mwan3lversion
|
||||
else
|
||||
mwan3lversion = "\nluci-app-mwan3 - unknown"
|
||||
end
|
||||
local softrev = wrtrelease .. lucirelease .. mwan3version .. mwan3lversion
|
||||
rv.mw3ver = { }
|
||||
mwv = {}
|
||||
mwv[softrev] = #rv.mw3ver + 1
|
||||
rv.mw3ver[mwv[softrev]] = { mwan3v = softrev }
|
||||
|
||||
-- mwan3 config
|
||||
local mwcg = ut.trim(sys.exec("cat /etc/config/mwan3"))
|
||||
if mwcg == "" then
|
||||
mwcg = "No data found"
|
||||
end
|
||||
rv.mwan3config = { }
|
||||
mwan3cfg = {}
|
||||
mwan3cfg[mwcg] = #rv.mwan3config + 1
|
||||
rv.mwan3config[mwan3cfg[mwcg]] = { mwn3cfg = mwcg }
|
||||
|
||||
-- network config
|
||||
local netcg = ut.trim(sys.exec("cat /etc/config/network | sed -e 's/.*username.*/ USERNAME HIDDEN/' -e 's/.*password.*/ PASSWORD HIDDEN/'"))
|
||||
if netcg == "" then
|
||||
netcg = "No data found"
|
||||
end
|
||||
rv.netconfig = { }
|
||||
ncfg = {}
|
||||
ncfg[netcg] = #rv.netconfig + 1
|
||||
rv.netconfig[ncfg[netcg]] = { netcfg = netcg }
|
||||
|
||||
-- ifconfig
|
||||
local ifcg = ut.trim(sys.exec("ifconfig"))
|
||||
if ifcg == "" then
|
||||
ifcg = "No data found"
|
||||
end
|
||||
rv.ifconfig = { }
|
||||
icfg = {}
|
||||
icfg[ifcg] = #rv.ifconfig + 1
|
||||
rv.ifconfig[icfg[ifcg]] = { ifcfg = ifcg }
|
||||
|
||||
-- route -n
|
||||
local routeshow = ut.trim(sys.exec("route -n"))
|
||||
if routeshow == "" then
|
||||
routeshow = "No data found"
|
||||
end
|
||||
rv.rtshow = { }
|
||||
rshw = {}
|
||||
rshw[routeshow] = #rv.rtshow + 1
|
||||
rv.rtshow[rshw[routeshow]] = { iprtshow = routeshow }
|
||||
|
||||
-- ip rule show
|
||||
local ipr = ut.trim(sys.exec("ip rule show"))
|
||||
if ipr == "" then
|
||||
ipr = "No data found"
|
||||
end
|
||||
rv.iprule = { }
|
||||
ipruleid = {}
|
||||
ipruleid[ipr] = #rv.iprule + 1
|
||||
rv.iprule[ipruleid[ipr]] = { rule = ipr }
|
||||
|
||||
-- ip route list table 1-250
|
||||
local routelisting, rlstr = ut.trim(sys.exec("ip rule | sed 's/://g' | awk -F' ' '$1>=2001 && $1<=2250' | awk -F' ' '{ print $NF }'")), ""
|
||||
if routelisting ~= "" then
|
||||
for line in routelisting:gmatch("[^\r\n]+") do
|
||||
rlstr = rlstr .. line .. "\n" .. sys.exec("ip route list table " .. line)
|
||||
end
|
||||
rlstr = ut.trim(rlstr)
|
||||
else
|
||||
rlstr = "No data found"
|
||||
end
|
||||
rv.routelist = { }
|
||||
rtlist = {}
|
||||
rtlist[rlstr] = #rv.routelist + 1
|
||||
rv.routelist[rtlist[rlstr]] = { iprtlist = rlstr }
|
||||
|
||||
-- default firewall output policy
|
||||
local defout = ut.trim(sys.exec("uci get -p /var/state firewall.@defaults[0].output"))
|
||||
if defout == "" then
|
||||
defout = "No data found"
|
||||
end
|
||||
rv.fidef = { }
|
||||
fwdf = {}
|
||||
fwdf[defout] = #rv.fidef + 1
|
||||
rv.fidef[fwdf[defout]] = { firedef = defout }
|
||||
|
||||
-- iptables
|
||||
local iptbl = ut.trim(sys.exec("iptables -L -t mangle -v -n"))
|
||||
if iptbl == "" then
|
||||
iptbl = "No data found"
|
||||
end
|
||||
rv.iptables = { }
|
||||
tables = {}
|
||||
tables[iptbl] = #rv.iptables + 1
|
||||
rv.iptables[tables[iptbl]] = { iptbls = iptbl }
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(rv)
|
||||
end
|
||||
@@ -0,0 +1,55 @@
|
||||
-- ------ hotplug script configuration ------ --
|
||||
|
||||
fs = require "nixio.fs"
|
||||
sys = require "luci.sys"
|
||||
ut = require "luci.util"
|
||||
|
||||
script = "/etc/hotplug.d/iface/16-mwan3custom"
|
||||
scriptbak = "/etc/hotplug.d/iface/16-mwan3custombak"
|
||||
|
||||
if luci.http.formvalue("cbid.luci.1._restorebak") then -- restore button has been clicked
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin/network/mwan3/advanced/hotplug") .. "?restore=yes")
|
||||
elseif luci.http.formvalue("restore") == "yes" then -- restore script from backup
|
||||
os.execute("cp -f " .. scriptbak .. " " .. script)
|
||||
end
|
||||
|
||||
|
||||
m5 = SimpleForm("luci", nil)
|
||||
m5:append(Template("mwan3/mwan3_adv_hotplug")) -- highlight current tab
|
||||
|
||||
f = m5:section(SimpleSection, nil,
|
||||
translate("This section allows you to modify the contents of /etc/hotplug.d/iface/16-mwan3custom<br />" ..
|
||||
"This is useful for running system commands and/or scripts based on interface ifup or ifdown hotplug events<br /><br />" ..
|
||||
"Notes:<br />" ..
|
||||
"The first line of the script must be "#!/bin/sh" without quotes<br />" ..
|
||||
"Lines beginning with # are comments and are not executed<br /><br />" ..
|
||||
"Available variables:<br />" ..
|
||||
"$ACTION is the hotplug event (ifup, ifdown)<br />" ..
|
||||
"$INTERFACE is the interface name (wan1, wan2, etc.)<br />" ..
|
||||
"$DEVICE is the device name attached to the interface (eth0.1, eth1, etc.)"))
|
||||
|
||||
|
||||
restore = f:option(Button, "_restorebak", translate("Restore default hotplug script"))
|
||||
restore.inputtitle = translate("Restore...")
|
||||
restore.inputstyle = "apply"
|
||||
|
||||
t = f:option(TextValue, "lines")
|
||||
t.rmempty = true
|
||||
t.rows = 20
|
||||
|
||||
function t.cfgvalue()
|
||||
local hps = fs.readfile(script)
|
||||
if not hps or hps == "" then -- if script does not exist or is blank restore from backup
|
||||
sys.call("cp -f " .. scriptbak .. " " .. script)
|
||||
return fs.readfile(script)
|
||||
else
|
||||
return hps
|
||||
end
|
||||
end
|
||||
|
||||
function t.write(self, section, data) -- format and write new data to script
|
||||
return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n")
|
||||
end
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1,32 @@
|
||||
-- ------ mwan3 configuration ------ --
|
||||
|
||||
ut = require "luci.util"
|
||||
|
||||
mwan3file = "/etc/config/mwan3"
|
||||
|
||||
|
||||
m5 = SimpleForm("luci", nil)
|
||||
m5:append(Template("mwan3/mwan3_adv_mwan3")) -- highlight current tab
|
||||
|
||||
|
||||
f = m5:section(SimpleSection, nil,
|
||||
translate("This section allows you to modify the contents of /etc/config/mwan3"))
|
||||
|
||||
t = f:option(TextValue, "lines")
|
||||
t.rmempty = true
|
||||
t.rows = 20
|
||||
|
||||
function t.cfgvalue()
|
||||
return nixio.fs.readfile(mwan3file) or ""
|
||||
end
|
||||
|
||||
function t.write(self, section, data) -- format and write new data to script
|
||||
return nixio.fs.writefile(mwan3file, "\n" .. ut.trim(data:gsub("\r\n", "\n")) .. "\n")
|
||||
end
|
||||
|
||||
function f.handle(self, state, data)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1,32 @@
|
||||
-- ------ network configuration ------ --
|
||||
|
||||
ut = require "luci.util"
|
||||
|
||||
netfile = "/etc/config/network"
|
||||
|
||||
|
||||
m5 = SimpleForm("networkconf", nil)
|
||||
m5:append(Template("mwan3/mwan3_adv_network")) -- highlight current tab
|
||||
|
||||
|
||||
f = m5:section(SimpleSection, nil,
|
||||
translate("This section allows you to modify the contents of /etc/config/network"))
|
||||
|
||||
t = f:option(TextValue, "lines")
|
||||
t.rmempty = true
|
||||
t.rows = 20
|
||||
|
||||
function t.cfgvalue()
|
||||
return nixio.fs.readfile(netfile) or ""
|
||||
end
|
||||
|
||||
function t.write(self, section, data) -- format and write new data to script
|
||||
return nixio.fs.writefile(netfile, "\n" .. ut.trim(data:gsub("\r\n", "\n")) .. "\n")
|
||||
end
|
||||
|
||||
function f.handle(self, state, data)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1,266 @@
|
||||
-- ------ extra functions ------ --
|
||||
|
||||
function iface_check() -- find issues with too many interfaces, reliability and metric
|
||||
uci.cursor():foreach("mwan3", "interface",
|
||||
function (section)
|
||||
local ifname = section[".name"]
|
||||
ifnum = ifnum+1 -- count number of mwan3 interfaces configured
|
||||
-- create list of metrics for none and duplicate checking
|
||||
local metlkp = ut.trim(sys.exec("uci get -p /var/state network." .. ifname .. ".metric"))
|
||||
if metlkp == "" then
|
||||
err_found = 1
|
||||
err_nomet_list = err_nomet_list .. ifname .. " "
|
||||
else
|
||||
metric_list = metric_list .. ifname .. " " .. metlkp .. "\n"
|
||||
end
|
||||
-- check if any interfaces have a higher reliability requirement than tracking IPs configured
|
||||
local tipnum = tonumber(ut.trim(sys.exec("echo $(uci get -p /var/state mwan3." .. ifname .. ".track_ip) | wc -w")))
|
||||
if tipnum > 0 then
|
||||
local relnum = tonumber(ut.trim(sys.exec("uci get -p /var/state mwan3." .. ifname .. ".reliability")))
|
||||
if relnum and relnum > tipnum then
|
||||
err_found = 1
|
||||
err_rel_list = err_rel_list .. ifname .. " "
|
||||
end
|
||||
end
|
||||
-- check if any interfaces are not properly configured in /etc/config/network or have no default route in main routing table
|
||||
if ut.trim(sys.exec("uci get -p /var/state network." .. ifname)) == "interface" then
|
||||
local ifdev = ut.trim(sys.exec("uci get -p /var/state network." .. ifname .. ".ifname"))
|
||||
if ifdev == "uci: Entry not found" or ifdev == "" then
|
||||
err_found = 1
|
||||
err_netcfg_list = err_netcfg_list .. ifname .. " "
|
||||
err_route_list = err_route_list .. ifname .. " "
|
||||
else
|
||||
local rtcheck = ut.trim(sys.exec("route -n | awk -F' ' '{ if ($8 == \"" .. ifdev .. "\" && $1 == \"0.0.0.0\") print $1 }'"))
|
||||
if rtcheck == "" then
|
||||
err_found = 1
|
||||
err_route_list = err_route_list .. ifname .. " "
|
||||
end
|
||||
end
|
||||
else
|
||||
err_found = 1
|
||||
err_netcfg_list = err_netcfg_list .. ifname .. " "
|
||||
err_route_list = err_route_list .. ifname .. " "
|
||||
end
|
||||
end
|
||||
)
|
||||
-- check if any interfaces have duplicate metrics
|
||||
local metric_dupnums = sys.exec("echo '" .. metric_list .. "' | awk -F' ' '{ print $2 }' | uniq -d")
|
||||
if metric_dupnums ~= "" then
|
||||
err_found = 1
|
||||
local metric_dupes = ""
|
||||
for line in metric_dupnums:gmatch("[^\r\n]+") do
|
||||
metric_dupes = sys.exec("echo '" .. metric_list .. "' | grep '" .. line .. "' | awk -F' ' '{ print $1 }'")
|
||||
err_dupmet_list = err_dupmet_list .. metric_dupes
|
||||
end
|
||||
err_dupmet_list = sys.exec("echo '" .. err_dupmet_list .. "' | tr '\n' ' '")
|
||||
end
|
||||
end
|
||||
|
||||
function iface_warn() -- display status and warning messages at the top of the page
|
||||
local warns = ""
|
||||
if ifnum <= 250 then
|
||||
warns = "<strong>There are currently " .. ifnum .. " of 250 supported interfaces configured</strong>"
|
||||
else
|
||||
warns = "<font color=\"ff0000\"><strong>WARNING: " .. ifnum .. " interfaces are configured exceeding the maximum of 250!</strong></font>"
|
||||
end
|
||||
if err_rel_list ~= " " then
|
||||
warns = warns .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have a higher reliability requirement than there are tracking IP addresses!</strong></font>"
|
||||
end
|
||||
if err_route_list ~= " " then
|
||||
warns = warns .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have no default route in the main routing table!</strong></font>"
|
||||
end
|
||||
if err_netcfg_list ~= " " then
|
||||
warns = warns .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces are configured incorrectly or not at all in /etc/config/network!</strong></font>"
|
||||
end
|
||||
if err_nomet_list ~= " " then
|
||||
warns = warns .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have no metric configured in /etc/config/network!</strong></font>"
|
||||
end
|
||||
if err_dupmet_list ~= " " then
|
||||
warns = warns .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have duplicate metrics configured in /etc/config/network!</strong></font>"
|
||||
end
|
||||
return warns
|
||||
end
|
||||
|
||||
-- ------ interface configuration ------ --
|
||||
|
||||
dsp = require "luci.dispatcher"
|
||||
sys = require "luci.sys"
|
||||
ut = require "luci.util"
|
||||
|
||||
ifnum = 0
|
||||
metric_list = ""
|
||||
err_found = 0
|
||||
err_dupmet_list = " "
|
||||
err_netcfg_list = " "
|
||||
err_nomet_list = " "
|
||||
err_rel_list = " "
|
||||
err_route_list = " "
|
||||
iface_check()
|
||||
|
||||
|
||||
m5 = Map("mwan3", translate("MWAN3 Multi-WAN Interface Configuration"),
|
||||
translate(iface_warn()))
|
||||
m5:append(Template("mwan3/mwan3_config_css"))
|
||||
|
||||
|
||||
mwan_interface = m5:section(TypedSection, "interface", translate("Interfaces"),
|
||||
translate("MWAN3 supports up to 250 physical and/or logical interfaces<br />" ..
|
||||
"MWAN3 requires that all interfaces have a unique metric configured in /etc/config/network<br />" ..
|
||||
"Names must match the interface name found in /etc/config/network (see advanced tab)<br />" ..
|
||||
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" ..
|
||||
"Interfaces may not share the same name as configured members, policies or rules"))
|
||||
mwan_interface.addremove = true
|
||||
mwan_interface.dynamic = false
|
||||
mwan_interface.sectionhead = "Interface"
|
||||
mwan_interface.sortable = true
|
||||
mwan_interface.template = "cbi/tblsection"
|
||||
mwan_interface.extedit = dsp.build_url("admin", "network", "mwan3", "configuration", "interface", "%s")
|
||||
function mwan_interface.create(self, section)
|
||||
TypedSection.create(self, section)
|
||||
m5.uci:save("mwan3")
|
||||
luci.http.redirect(dsp.build_url("admin", "network", "mwan3", "configuration", "interface", section))
|
||||
end
|
||||
|
||||
|
||||
enabled = mwan_interface:option(DummyValue, "enabled", translate("Enabled"))
|
||||
enabled.rawhtml = true
|
||||
function enabled.cfgvalue(self, s)
|
||||
if self.map:get(s, "enabled") == "1" then
|
||||
return "Yes"
|
||||
else
|
||||
return "No"
|
||||
end
|
||||
end
|
||||
|
||||
track_ip = mwan_interface:option(DummyValue, "track_ip", translate("Tracking IP"))
|
||||
track_ip.rawhtml = true
|
||||
function track_ip.cfgvalue(self, s)
|
||||
local str = ""
|
||||
tracked = self.map:get(s, "track_ip")
|
||||
if tracked then
|
||||
for k,v in pairs(tracked) do
|
||||
str = str .. v .. "<br />"
|
||||
end
|
||||
return str
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
end
|
||||
|
||||
reliability = mwan_interface:option(DummyValue, "reliability", translate("Tracking reliability"))
|
||||
reliability.rawhtml = true
|
||||
function reliability.cfgvalue(self, s)
|
||||
if tracked then
|
||||
return self.map:get(s, "reliability") or "—"
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
end
|
||||
|
||||
count = mwan_interface:option(DummyValue, "count", translate("Ping count"))
|
||||
count.rawhtml = true
|
||||
function count.cfgvalue(self, s)
|
||||
if tracked then
|
||||
return self.map:get(s, "count") or "—"
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
end
|
||||
|
||||
timeout = mwan_interface:option(DummyValue, "timeout", translate("Ping timeout"))
|
||||
timeout.rawhtml = true
|
||||
function timeout.cfgvalue(self, s)
|
||||
if tracked then
|
||||
local tcheck = self.map:get(s, "timeout")
|
||||
if tcheck then
|
||||
return tcheck .. "s"
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
end
|
||||
|
||||
interval = mwan_interface:option(DummyValue, "interval", translate("Ping interval"))
|
||||
interval.rawhtml = true
|
||||
function interval.cfgvalue(self, s)
|
||||
if tracked then
|
||||
local icheck = self.map:get(s, "interval")
|
||||
if icheck then
|
||||
return icheck .. "s"
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
end
|
||||
|
||||
down = mwan_interface:option(DummyValue, "down", translate("Interface down"))
|
||||
down.rawhtml = true
|
||||
function down.cfgvalue(self, s)
|
||||
if tracked then
|
||||
return self.map:get(s, "down") or "—"
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
end
|
||||
|
||||
up = mwan_interface:option(DummyValue, "up", translate("Interface up"))
|
||||
up.rawhtml = true
|
||||
function up.cfgvalue(self, s)
|
||||
if tracked then
|
||||
return self.map:get(s, "up") or "—"
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
end
|
||||
|
||||
metric = mwan_interface:option(DummyValue, "metric", translate("Metric"))
|
||||
metric.rawhtml = true
|
||||
function metric.cfgvalue(self, s)
|
||||
local metcheck = sys.exec("uci get -p /var/state network." .. s .. ".metric")
|
||||
if metcheck ~= "" then
|
||||
return metcheck
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
end
|
||||
|
||||
errors = mwan_interface:option(DummyValue, "errors", translate("Errors"))
|
||||
errors.rawhtml = true
|
||||
function errors.cfgvalue(self, s)
|
||||
if err_found == 1 then
|
||||
local mouseover, linebrk = "", ""
|
||||
if string.find(err_rel_list, " " .. s .. " ") then
|
||||
mouseover = "Higher reliability requirement than there are tracking IP addresses"
|
||||
linebrk = " "
|
||||
end
|
||||
if string.find(err_route_list, " " .. s .. " ") then
|
||||
mouseover = mouseover .. linebrk .. "No default route in the main routing table"
|
||||
linebrk = " "
|
||||
end
|
||||
if string.find(err_netcfg_list, " " .. s .. " ") then
|
||||
mouseover = mouseover .. linebrk .. "Configured incorrectly or not at all in /etc/config/network"
|
||||
linebrk = " "
|
||||
end
|
||||
if string.find(err_nomet_list, " " .. s .. " ") then
|
||||
mouseover = mouseover .. linebrk .. "No metric configured in /etc/config/network"
|
||||
linebrk = " "
|
||||
end
|
||||
if string.find(err_dupmet_list, " " .. s .. " ") then
|
||||
mouseover = mouseover .. linebrk .. "Duplicate metric configured in /etc/config/network"
|
||||
end
|
||||
if mouseover == "" then
|
||||
return ""
|
||||
else
|
||||
return "<span title=\"" .. mouseover .. "\"><img src=\"/luci-static/resources/cbi/reset.gif\" alt=\"error\"></img></span>"
|
||||
end
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1,191 @@
|
||||
-- ------ extra functions ------ --
|
||||
|
||||
function iface_check()
|
||||
metcheck = ut.trim(sys.exec("uci get -p /var/state network." .. arg[1] .. ".metric"))
|
||||
if metcheck == "" then -- no metric
|
||||
err_nomet = 1
|
||||
else -- if metric exists create list of interface metrics to compare against for duplicates
|
||||
uci.cursor():foreach("mwan3", "interface",
|
||||
function (section)
|
||||
local metlkp = ut.trim(sys.exec("uci get -p /var/state network." .. section[".name"] .. ".metric"))
|
||||
metric_list = metric_list .. section[".name"] .. " " .. metlkp .. "\n"
|
||||
end
|
||||
)
|
||||
-- compare metric against list
|
||||
local metric_dupnums, metric_dupes = sys.exec("echo '" .. metric_list .. "' | awk -F' ' '{ print $2 }' | uniq -d"), ""
|
||||
for line in metric_dupnums:gmatch("[^\r\n]+") do
|
||||
metric_dupes = sys.exec("echo '" .. metric_list .. "' | grep '" .. line .. "' | awk -F' ' '{ print $1 }'")
|
||||
err_dupmet_list = err_dupmet_list .. metric_dupes
|
||||
end
|
||||
if sys.exec("echo '" .. err_dupmet_list .. "' | grep -w " .. arg[1]) ~= "" then
|
||||
err_dupmet = 1
|
||||
end
|
||||
end
|
||||
-- check if this interface has a higher reliability requirement than track IPs configured
|
||||
local tipnum = tonumber(ut.trim(sys.exec("echo $(uci get -p /var/state mwan3." .. arg[1] .. ".track_ip) | wc -w")))
|
||||
if tipnum > 0 then
|
||||
local relnum = tonumber(ut.trim(sys.exec("uci get -p /var/state mwan3." .. arg[1] .. ".reliability")))
|
||||
if relnum and relnum > tipnum then
|
||||
err_reliability = 1
|
||||
end
|
||||
end
|
||||
-- check if any interfaces are not properly configured in /etc/config/network or have no default route in main routing table
|
||||
if ut.trim(sys.exec("uci get -p /var/state network." .. arg[1])) == "interface" then
|
||||
local ifdev = ut.trim(sys.exec("uci get -p /var/state network." .. arg[1] .. ".ifname"))
|
||||
if ifdev == "uci: Entry not found" or ifdev == "" then
|
||||
err_netcfg = 1
|
||||
err_route = 1
|
||||
else
|
||||
local rtcheck = ut.trim(sys.exec("route -n | awk -F' ' '{ if ($8 == \"" .. ifdev .. "\" && $1 == \"0.0.0.0\") print $1 }'"))
|
||||
if rtcheck == "" then
|
||||
err_route = 1
|
||||
end
|
||||
end
|
||||
else
|
||||
err_netcfg = 1
|
||||
err_route = 1
|
||||
end
|
||||
end
|
||||
|
||||
function iface_warn() -- display warning messages at the top of the page
|
||||
local warns, linebrk = "", ""
|
||||
if err_reliability == 1 then
|
||||
warns = "<font color=\"ff0000\"><strong>WARNING: this interface has a higher reliability requirement than there are tracking IP addresses!</strong></font>"
|
||||
linebrk = "<br /><br />"
|
||||
end
|
||||
if err_route == 1 then
|
||||
warns = warns .. linebrk .. "<font color=\"ff0000\"><strong>WARNING: this interface has no default route in the main routing table!</strong></font>"
|
||||
linebrk = "<br /><br />"
|
||||
end
|
||||
if err_netcfg == 1 then
|
||||
warns = warns .. linebrk .. "<font color=\"ff0000\"><strong>WARNING: this interface is configured incorrectly or not at all in /etc/config/network!</strong></font>"
|
||||
linebrk = "<br /><br />"
|
||||
end
|
||||
if err_nomet == 1 then
|
||||
warns = warns .. linebrk .. "<font color=\"ff0000\"><strong>WARNING: this interface has no metric configured in /etc/config/network!</strong></font>"
|
||||
elseif err_dupmet == 1 then
|
||||
warns = warns .. linebrk .. "<font color=\"ff0000\"><strong>WARNING: this and other interfaces have duplicate metrics configured in /etc/config/network!</strong></font>"
|
||||
end
|
||||
return warns
|
||||
end
|
||||
|
||||
-- ------ interface configuration ------ --
|
||||
|
||||
dsp = require "luci.dispatcher"
|
||||
sys = require "luci.sys"
|
||||
ut = require "luci.util"
|
||||
arg[1] = arg[1] or ""
|
||||
|
||||
metcheck = ""
|
||||
metric_list = ""
|
||||
err_dupmet_list = ""
|
||||
err_rel_list = ""
|
||||
err_nomet = 0
|
||||
err_dupmet = 0
|
||||
err_route = 0
|
||||
err_netcfg = 0
|
||||
err_reliability = 0
|
||||
iface_check()
|
||||
|
||||
|
||||
m5 = Map("mwan3", translate("MWAN3 Multi-WAN Interface Configuration - " .. arg[1]),
|
||||
translate(iface_warn()))
|
||||
m5.redirect = dsp.build_url("admin", "network", "mwan3", "configuration", "interface")
|
||||
|
||||
|
||||
mwan_interface = m5:section(NamedSection, arg[1], "interface", "")
|
||||
mwan_interface.addremove = false
|
||||
mwan_interface.dynamic = false
|
||||
|
||||
|
||||
enabled = mwan_interface:option(ListValue, "enabled", translate("Enabled"))
|
||||
enabled.default = "1"
|
||||
enabled:value("1", translate("Yes"))
|
||||
enabled:value("0", translate("No"))
|
||||
|
||||
track_ip = mwan_interface:option(DynamicList, "track_ip", translate("Tracking IP"),
|
||||
translate("This IP address will be pinged to dermine if the link is up or down. Leave blank to assume interface is always online"))
|
||||
track_ip.datatype = "ipaddr"
|
||||
|
||||
reliability = mwan_interface:option(Value, "reliability", translate("Tracking reliability"),
|
||||
translate("Acceptable values: 1-100. This many Tracking IP addresses must respond for the link to be deemed up"))
|
||||
reliability.datatype = "range(1, 100)"
|
||||
reliability.default = "1"
|
||||
|
||||
count = mwan_interface:option(ListValue, "count", translate("Ping count"))
|
||||
count.default = "1"
|
||||
count:value("1")
|
||||
count:value("2")
|
||||
count:value("3")
|
||||
count:value("4")
|
||||
count:value("5")
|
||||
|
||||
timeout = mwan_interface:option(ListValue, "timeout", translate("Ping timeout"))
|
||||
timeout.default = "2"
|
||||
timeout:value("1", translate("1 second"))
|
||||
timeout:value("2", translate("2 seconds"))
|
||||
timeout:value("3", translate("3 seconds"))
|
||||
timeout:value("4", translate("4 seconds"))
|
||||
timeout:value("5", translate("5 seconds"))
|
||||
timeout:value("6", translate("6 seconds"))
|
||||
timeout:value("7", translate("7 seconds"))
|
||||
timeout:value("8", translate("8 seconds"))
|
||||
timeout:value("9", translate("9 seconds"))
|
||||
timeout:value("10", translate("10 seconds"))
|
||||
|
||||
interval = mwan_interface:option(ListValue, "interval", translate("Ping interval"))
|
||||
interval.default = "5"
|
||||
interval:value("1", translate("1 second"))
|
||||
interval:value("3", translate("3 seconds"))
|
||||
interval:value("5", translate("5 seconds"))
|
||||
interval:value("10", translate("10 seconds"))
|
||||
interval:value("20", translate("20 seconds"))
|
||||
interval:value("30", translate("30 seconds"))
|
||||
interval:value("60", translate("1 minute"))
|
||||
interval:value("300", translate("5 minutes"))
|
||||
interval:value("600", translate("10 minutes"))
|
||||
interval:value("900", translate("15 minutes"))
|
||||
interval:value("1800", translate("30 minutes"))
|
||||
interval:value("3600", translate("1 hour"))
|
||||
|
||||
down = mwan_interface:option(ListValue, "down", translate("Interface down"),
|
||||
translate("Interface will be deemed down after this many failed ping tests"))
|
||||
down.default = "3"
|
||||
down:value("1")
|
||||
down:value("2")
|
||||
down:value("3")
|
||||
down:value("4")
|
||||
down:value("5")
|
||||
down:value("6")
|
||||
down:value("7")
|
||||
down:value("8")
|
||||
down:value("9")
|
||||
down:value("10")
|
||||
|
||||
up = mwan_interface:option(ListValue, "up", translate("Interface up"),
|
||||
translate("Downed interface will be deemed up after this many successful ping tests"))
|
||||
up.default = "3"
|
||||
up:value("1")
|
||||
up:value("2")
|
||||
up:value("3")
|
||||
up:value("4")
|
||||
up:value("5")
|
||||
up:value("6")
|
||||
up:value("7")
|
||||
up:value("8")
|
||||
up:value("9")
|
||||
up:value("10")
|
||||
|
||||
metric = mwan_interface:option(DummyValue, "metric", translate("Metric"),
|
||||
translate("This displays the metric assigned to this interface in /etc/config/network"))
|
||||
metric.rawhtml = true
|
||||
function metric.cfgvalue(self, s)
|
||||
if err_nomet == 0 then
|
||||
return metcheck
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1,46 @@
|
||||
-- ------ member configuration ------ --
|
||||
|
||||
ds = require "luci.dispatcher"
|
||||
|
||||
|
||||
m5 = Map("mwan3", translate("MWAN3 Multi-WAN Member Configuration"))
|
||||
m5:append(Template("mwan3/mwan3_config_css"))
|
||||
|
||||
|
||||
mwan_member = m5:section(TypedSection, "member", translate("Members"),
|
||||
translate("Members are profiles attaching a metric and weight to an MWAN3 interface<br />" ..
|
||||
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" ..
|
||||
"Members may not share the same name as configured interfaces, policies or rules"))
|
||||
mwan_member.addremove = true
|
||||
mwan_member.dynamic = false
|
||||
mwan_member.sectionhead = "Member"
|
||||
mwan_member.sortable = true
|
||||
mwan_member.template = "cbi/tblsection"
|
||||
mwan_member.extedit = ds.build_url("admin", "network", "mwan3", "configuration", "member", "%s")
|
||||
function mwan_member.create(self, section)
|
||||
TypedSection.create(self, section)
|
||||
m5.uci:save("mwan3")
|
||||
luci.http.redirect(ds.build_url("admin", "network", "mwan3", "configuration", "member", section))
|
||||
end
|
||||
|
||||
|
||||
interface = mwan_member:option(DummyValue, "interface", translate("Interface"))
|
||||
interface.rawhtml = true
|
||||
function interface.cfgvalue(self, s)
|
||||
return self.map:get(s, "interface") or "—"
|
||||
end
|
||||
|
||||
metric = mwan_member:option(DummyValue, "metric", translate("Metric"))
|
||||
metric.rawhtml = true
|
||||
function metric.cfgvalue(self, s)
|
||||
return self.map:get(s, "metric") or "1"
|
||||
end
|
||||
|
||||
weight = mwan_member:option(DummyValue, "weight", translate("Weight"))
|
||||
weight.rawhtml = true
|
||||
function weight.cfgvalue(self, s)
|
||||
return self.map:get(s, "weight") or "1"
|
||||
end
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1,47 @@
|
||||
-- ------ extra functions ------ --
|
||||
|
||||
function cbi_add_interface(field)
|
||||
uci.cursor():foreach("mwan3", "interface",
|
||||
function (section)
|
||||
field:value(section[".name"])
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
-- ------ member configuration ------ --
|
||||
|
||||
dsp = require "luci.dispatcher"
|
||||
arg[1] = arg[1] or ""
|
||||
|
||||
|
||||
m5 = Map("mwan3", translate("MWAN3 Multi-WAN Member Configuration - ") .. arg[1])
|
||||
m5.redirect = dsp.build_url("admin", "network", "mwan3", "configuration", "member")
|
||||
|
||||
|
||||
mwan_member = m5:section(NamedSection, arg[1], "member", "")
|
||||
mwan_member.addremove = false
|
||||
mwan_member.dynamic = false
|
||||
|
||||
|
||||
interface = mwan_member:option(Value, "interface", translate("Interface"))
|
||||
cbi_add_interface(interface)
|
||||
|
||||
metric = mwan_member:option(Value, "metric", translate("Metric"),
|
||||
translate("Acceptable values: 1-1000. Defaults to 1 if not set"))
|
||||
metric.datatype = "range(1, 1000)"
|
||||
|
||||
weight = mwan_member:option(Value, "weight", translate("Weight"),
|
||||
translate("Acceptable values: 1-1000. Defaults to 1 if not set"))
|
||||
weight.datatype = "range(1, 1000)"
|
||||
|
||||
|
||||
-- ------ currently configured interfaces ------ --
|
||||
|
||||
mwan_interface = m5:section(TypedSection, "interface", translate("Currently Configured Interfaces"))
|
||||
mwan_interface.addremove = false
|
||||
mwan_interface.dynamic = false
|
||||
mwan_interface.sortable = false
|
||||
mwan_interface.template = "cbi/tblsection"
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1,82 @@
|
||||
-- ------ extra functions ------ --
|
||||
|
||||
function policy_check() -- check to see if any policy names exceed the maximum of 15 characters
|
||||
uci.cursor():foreach("mwan3", "policy",
|
||||
function (section)
|
||||
if string.len(section[".name"]) > 15 then
|
||||
toolong = 1
|
||||
err_name_list = err_name_list .. section[".name"] .. " "
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function policy_warn() -- display status and warning messages at the top of the page
|
||||
if toolong == 1 then
|
||||
return "<font color=\"ff0000\"><strong>WARNING: Some policies have names exceeding the maximum of 15 characters!</strong></font>"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
-- ------ policy configuration ------ --
|
||||
|
||||
ds = require "luci.dispatcher"
|
||||
sys = require "luci.sys"
|
||||
|
||||
toolong = 0
|
||||
err_name_list = " "
|
||||
policy_check()
|
||||
|
||||
|
||||
m5 = Map("mwan3", translate("MWAN3 Multi-WAN Policy Configuration"),
|
||||
translate(policy_warn()))
|
||||
m5:append(Template("mwan3/mwan3_config_css"))
|
||||
|
||||
|
||||
mwan_policy = m5:section(TypedSection, "policy", translate("Policies"),
|
||||
translate("Policies are profiles grouping one or more members controlling how MWAN3 distributes traffic<br />" ..
|
||||
"Member interfaces with lower metrics are used first. Interfaces with the same metric load-balance<br />" ..
|
||||
"Load-balanced member interfaces distribute more traffic out those with higher weights<br />" ..
|
||||
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces. Names must be 15 characters or less<br />" ..
|
||||
"Policies may not share the same name as configured interfaces, members or rules"))
|
||||
mwan_policy.addremove = true
|
||||
mwan_policy.dynamic = false
|
||||
mwan_policy.sectionhead = "Policy"
|
||||
mwan_policy.sortable = true
|
||||
mwan_policy.template = "cbi/tblsection"
|
||||
mwan_policy.extedit = ds.build_url("admin", "network", "mwan3", "configuration", "policy", "%s")
|
||||
function mwan_policy.create(self, section)
|
||||
TypedSection.create(self, section)
|
||||
m5.uci:save("mwan3")
|
||||
luci.http.redirect(ds.build_url("admin", "network", "mwan3", "configuration", "policy", section))
|
||||
end
|
||||
|
||||
|
||||
use_member = mwan_policy:option(DummyValue, "use_member", translate("Members assigned"))
|
||||
use_member.rawhtml = true
|
||||
function use_member.cfgvalue(self, s)
|
||||
local tab, str = self.map:get(s, "use_member"), ""
|
||||
if tab then
|
||||
for k,v in pairs(tab) do
|
||||
str = str .. v .. "<br />"
|
||||
end
|
||||
return str
|
||||
else
|
||||
return "—"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
errors = mwan_policy:option(DummyValue, "errors", translate("Errors"))
|
||||
errors.rawhtml = true
|
||||
function errors.cfgvalue(self, s)
|
||||
if not string.find(err_name_list, " " .. s .. " ") then
|
||||
return ""
|
||||
else
|
||||
return "<span title=\"Name exceeds 15 characters\"><img src=\"/luci-static/resources/cbi/reset.gif\" alt=\"error\"></img></span>"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1,58 @@
|
||||
-- ------ extra functions ------ --
|
||||
|
||||
function policy_check() -- check to see if this policy's name exceed the maximum of 15 characters
|
||||
polchar = string.len(arg[1])
|
||||
if polchar > 15 then
|
||||
toolong = 1
|
||||
end
|
||||
end
|
||||
|
||||
function policy_warn() -- display status and warning messages at the top of the page
|
||||
if toolong == 1 then
|
||||
return "<font color=\"ff0000\"><strong>WARNING: this policy's name is " .. polchar .. " characters exceeding the maximum of 15!</strong></font>"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
function cbi_add_member(field)
|
||||
uci.cursor():foreach("mwan3", "member",
|
||||
function (section)
|
||||
field:value(section[".name"])
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
-- ------ policy configuration ------ --
|
||||
|
||||
dsp = require "luci.dispatcher"
|
||||
arg[1] = arg[1] or ""
|
||||
|
||||
toolong = 0
|
||||
policy_check()
|
||||
|
||||
|
||||
m5 = Map("mwan3", translate("MWAN3 Multi-WAN Policy Configuration - " .. arg[1]),
|
||||
translate(policy_warn()))
|
||||
m5.redirect = dsp.build_url("admin", "network", "mwan3", "configuration", "policy")
|
||||
|
||||
|
||||
mwan_policy = m5:section(NamedSection, arg[1], "policy", "")
|
||||
mwan_policy.addremove = false
|
||||
mwan_policy.dynamic = false
|
||||
|
||||
|
||||
use_member = mwan_policy:option(DynamicList, "use_member", translate("Member used"))
|
||||
cbi_add_member(use_member)
|
||||
|
||||
|
||||
-- ------ currently configured members ------ --
|
||||
|
||||
mwan_member = m5:section(TypedSection, "member", translate("Currently Configured Members"))
|
||||
mwan_member.addremove = false
|
||||
mwan_member.dynamic = false
|
||||
mwan_member.sortable = false
|
||||
mwan_member.template = "cbi/tblsection"
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1,109 @@
|
||||
-- ------ extra functions ------ --
|
||||
|
||||
function rule_check() -- determine if rules needs a proper protocol configured
|
||||
uci.cursor():foreach("mwan3", "rule",
|
||||
function (section)
|
||||
local sport = ut.trim(sys.exec("uci get -p /var/state mwan3." .. section[".name"] .. ".src_port"))
|
||||
local dport = ut.trim(sys.exec("uci get -p /var/state mwan3." .. section[".name"] .. ".dest_port"))
|
||||
if sport ~= "" or dport ~= "" then -- ports configured
|
||||
local proto = ut.trim(sys.exec("uci get -p /var/state mwan3." .. section[".name"] .. ".proto"))
|
||||
if proto == "" or proto == "all" then -- no or improper protocol
|
||||
err_proto_list = err_proto_list .. section[".name"] .. " "
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function rule_warn() -- display warning messages at the top of the page
|
||||
if err_proto_list ~= " " then
|
||||
return "<font color=\"ff0000\"><strong>WARNING: some rules have a port configured with no or improper protocol specified! Please configure a specific protocol!</strong></font>"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
-- ------ rule configuration ------ --
|
||||
|
||||
dsp = require "luci.dispatcher"
|
||||
sys = require "luci.sys"
|
||||
ut = require "luci.util"
|
||||
|
||||
err_proto = 0
|
||||
err_proto_list = " "
|
||||
rule_check()
|
||||
|
||||
|
||||
m5 = Map("mwan3", translate("MWAN3 Multi-WAN Traffic Rule Configuration"),
|
||||
translate(rule_warn()))
|
||||
m5:append(Template("mwan3/mwan3_config_css"))
|
||||
|
||||
|
||||
mwan_rule = m5:section(TypedSection, "rule", translate("Traffic Rules"),
|
||||
translate("Rules specify which traffic will use a particular MWAN3 policy based on IP address, port or protocol<br />" ..
|
||||
"Rules are matched from top to bottom. Rules below a matching rule are ignored. Traffic not matching any rule is routed using the main routing table<br />" ..
|
||||
"Traffic destined for known (other than default) networks is handled by the main routing table. Traffic matching a rule, but all WAN interfaces for that policy are down will be blackholed<br />" ..
|
||||
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" ..
|
||||
"Rules may not share the same name as configured interfaces, members or policies"))
|
||||
mwan_rule.addremove = true
|
||||
mwan_rule.anonymous = false
|
||||
mwan_rule.dynamic = false
|
||||
mwan_rule.sectionhead = "Rule"
|
||||
mwan_rule.sortable = true
|
||||
mwan_rule.template = "cbi/tblsection"
|
||||
mwan_rule.extedit = dsp.build_url("admin", "network", "mwan3", "configuration", "rule", "%s")
|
||||
function mwan_rule.create(self, section)
|
||||
TypedSection.create(self, section)
|
||||
m5.uci:save("mwan3")
|
||||
luci.http.redirect(dsp.build_url("admin", "network", "mwan3", "configuration", "rule", section))
|
||||
end
|
||||
|
||||
|
||||
src_ip = mwan_rule:option(DummyValue, "src_ip", translate("Source address"))
|
||||
src_ip.rawhtml = true
|
||||
function src_ip.cfgvalue(self, s)
|
||||
return self.map:get(s, "src_ip") or "—"
|
||||
end
|
||||
|
||||
src_port = mwan_rule:option(DummyValue, "src_port", translate("Source port"))
|
||||
src_port.rawhtml = true
|
||||
function src_port.cfgvalue(self, s)
|
||||
return self.map:get(s, "src_port") or "—"
|
||||
end
|
||||
|
||||
dest_ip = mwan_rule:option(DummyValue, "dest_ip", translate("Destination address"))
|
||||
dest_ip.rawhtml = true
|
||||
function dest_ip.cfgvalue(self, s)
|
||||
return self.map:get(s, "dest_ip") or "—"
|
||||
end
|
||||
|
||||
dest_port = mwan_rule:option(DummyValue, "dest_port", translate("Destination port"))
|
||||
dest_port.rawhtml = true
|
||||
function dest_port.cfgvalue(self, s)
|
||||
return self.map:get(s, "dest_port") or "—"
|
||||
end
|
||||
|
||||
proto = mwan_rule:option(DummyValue, "proto", translate("Protocol"))
|
||||
proto.rawhtml = true
|
||||
function proto.cfgvalue(self, s)
|
||||
return self.map:get(s, "proto") or "all"
|
||||
end
|
||||
|
||||
use_policy = mwan_rule:option(DummyValue, "use_policy", translate("Policy assigned"))
|
||||
use_policy.rawhtml = true
|
||||
function use_policy.cfgvalue(self, s)
|
||||
return self.map:get(s, "use_policy") or "—"
|
||||
end
|
||||
|
||||
errors = mwan_rule:option(DummyValue, "errors", translate("Errors"))
|
||||
errors.rawhtml = true
|
||||
function errors.cfgvalue(self, s)
|
||||
if not string.find(err_proto_list, " " .. s .. " ") then
|
||||
return ""
|
||||
else
|
||||
return "<span title=\"No protocol specified\"><img src=\"/luci-static/resources/cbi/reset.gif\" alt=\"error\"></img></span>"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1,99 @@
|
||||
-- ------ extra functions ------ --
|
||||
|
||||
function rule_check() -- determine if rule needs a protocol specified
|
||||
local sport = ut.trim(sys.exec("uci get -p /var/state mwan3." .. arg[1] .. ".src_port"))
|
||||
local dport = ut.trim(sys.exec("uci get -p /var/state mwan3." .. arg[1] .. ".dest_port"))
|
||||
if sport ~= "" or dport ~= "" then -- ports configured
|
||||
local proto = ut.trim(sys.exec("uci get -p /var/state mwan3." .. arg[1] .. ".proto"))
|
||||
if proto == "" or proto == "all" then -- no or improper protocol
|
||||
err_proto = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function rule_warn() -- display warning message at the top of the page
|
||||
if err_proto == 1 then
|
||||
return "<font color=\"ff0000\"><strong>WARNING: this rule is incorrectly configured with no or improper protocol specified! Please configure a specific protocol!</strong></font>"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
function cbi_add_policy(field)
|
||||
uci.cursor():foreach("mwan3", "policy",
|
||||
function (section)
|
||||
field:value(section[".name"])
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function cbi_add_protocol(field)
|
||||
local protos = ut.trim(sys.exec("cat /etc/protocols | grep ' # ' | awk -F' ' '{print $1}' | grep -vw -e 'ip' -e 'tcp' -e 'udp' -e 'icmp' -e 'esp' | grep -v 'ipv6' | sort | tr '\n' ' '"))
|
||||
for p in string.gmatch(protos, "%S+") do
|
||||
field:value(p)
|
||||
end
|
||||
end
|
||||
|
||||
-- ------ rule configuration ------ --
|
||||
|
||||
dsp = require "luci.dispatcher"
|
||||
sys = require "luci.sys"
|
||||
ut = require "luci.util"
|
||||
arg[1] = arg[1] or ""
|
||||
|
||||
err_proto = 0
|
||||
rule_check()
|
||||
|
||||
|
||||
m5 = Map("mwan3", translate("MWAN3 Multi-WAN Rule Configuration - ") .. arg[1],
|
||||
translate(rule_warn()))
|
||||
m5.redirect = dsp.build_url("admin", "network", "mwan3", "configuration", "rule")
|
||||
|
||||
|
||||
mwan_rule = m5:section(NamedSection, arg[1], "rule", "")
|
||||
mwan_rule.addremove = false
|
||||
mwan_rule.dynamic = false
|
||||
|
||||
|
||||
src_ip = mwan_rule:option(Value, "src_ip", translate("Source address"),
|
||||
translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
|
||||
src_ip.datatype = ipaddr
|
||||
|
||||
src_port = mwan_rule:option(Value, "src_port", translate("Source port"),
|
||||
translate("May be entered as a single or multiple port(s) (eg \"22\" or \"80,443\") or as a portrange (eg \"1024:2048\") without quotes"))
|
||||
|
||||
dest_ip = mwan_rule:option(Value, "dest_ip", translate("Destination address"),
|
||||
translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
|
||||
dest_ip.datatype = ipaddr
|
||||
|
||||
dest_port = mwan_rule:option(Value, "dest_port", translate("Destination port"),
|
||||
translate("May be entered as a single or multiple port(s) (eg \"22\" or \"80,443\") or as a portrange (eg \"1024:2048\") without quotes"))
|
||||
|
||||
proto = mwan_rule:option(Value, "proto", translate("Protocol"),
|
||||
translate("View the contents of /etc/protocols for protocol descriptions"))
|
||||
proto.default = "all"
|
||||
proto.rmempty = false
|
||||
proto:value("all")
|
||||
proto:value("ip")
|
||||
proto:value("tcp")
|
||||
proto:value("udp")
|
||||
proto:value("icmp")
|
||||
proto:value("esp")
|
||||
cbi_add_protocol(proto)
|
||||
|
||||
use_policy = mwan_rule:option(Value, "use_policy", translate("Policy assigned"))
|
||||
cbi_add_policy(use_policy)
|
||||
use_policy:value("unreachable")
|
||||
use_policy:value("default")
|
||||
|
||||
|
||||
-- ------ currently configured policies ------ --
|
||||
|
||||
mwan_policy = m5:section(TypedSection, "policy", translate("Currently Configured Policies"))
|
||||
mwan_policy.addremove = false
|
||||
mwan_policy.dynamic = false
|
||||
mwan_policy.sortable = false
|
||||
mwan_policy.template = "cbi/tblsection"
|
||||
|
||||
|
||||
return m5
|
||||
@@ -0,0 +1 @@
|
||||
<%+mwan3/mwan3_status%>
|
||||
@@ -0,0 +1,134 @@
|
||||
<%+header%>
|
||||
|
||||
<ul class="cbi-tabmenu">
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/hotplug")%>"><%:Hotplug Script%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/mwan3")%>"><%:MWAN3 Config%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/network")%>"><%:Network Config%></a></li>
|
||||
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/diag")%>"><%:Diagnostics%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/tshoot")%>"><%:Troubleshooting%></a></li>
|
||||
</ul>
|
||||
|
||||
<%
|
||||
local uci = require "luci.model.uci"
|
||||
|
||||
str = ""
|
||||
uci.cursor():foreach("mwan3", "interface",
|
||||
function (section)
|
||||
str = str .. section[".name"] .. " "
|
||||
end
|
||||
)
|
||||
%>
|
||||
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var stxhr = new XHR();
|
||||
|
||||
function update_status(tool, alt)
|
||||
{
|
||||
var iface = document.getElementById('mwan3iface').value;
|
||||
var output = document.getElementById('diag_output');
|
||||
|
||||
if (tool == "service")
|
||||
{
|
||||
output.innerHTML =
|
||||
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="padding: 20px; vertical-align: middle;" /> ' +
|
||||
"Waiting for MWAN3 to " + alt + "..."
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
output.innerHTML =
|
||||
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="padding: 20px; vertical-align: middle;" /> ' +
|
||||
"Waiting for diagnostic results..."
|
||||
;
|
||||
}
|
||||
|
||||
output.parentNode.style.display = 'block';
|
||||
output.style.display = 'inline';
|
||||
|
||||
stxhr.get('<%=luci.dispatcher.build_url("admin", "network", "mwan3", "advanced")%>/diag_display' + '/' + iface + '/' + tool + '/' + alt, null,
|
||||
function(x, st)
|
||||
{
|
||||
if (st.diagres)
|
||||
{
|
||||
output.innerHTML = String.format('<pre id="diag_output_css">%h</pre>', st.diagres[0].diagresult);
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp = '';
|
||||
var ncint = 'No diagnostic results returned';
|
||||
temp = String.format(
|
||||
'<pre id="diag_output_css"><strong>%s</strong></pre>',
|
||||
ncint
|
||||
);
|
||||
output.innerHTML = temp;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
<div id="mwan3_diagnostics" class="cbi-map">
|
||||
<fieldset id="diag_select" class="cbi-section">
|
||||
<legend><%:MWAN3 Interface Diagnostics%></legend>
|
||||
<select id="mwan3iface">
|
||||
<% for z in str:gmatch("[^ ]+") do -%><option value="<%=z%>"><%=z%></option><%- end %>
|
||||
</select>
|
||||
<div id="buttoncss">
|
||||
<input type="button" value="<%:Ping default gateway%>" class="cbi-button cbi-button-apply" onclick="update_status('ping', 'gateway')" />
|
||||
<input type="button" value="<%:Ping tracking IP%>" class="cbi-button cbi-button-apply" onclick="update_status('ping', 'track_ip')" />
|
||||
<input type="button" value="<%:Check IP rules%>" class="cbi-button cbi-button-apply" onclick="update_status('rulechk', null)" />
|
||||
<input type="button" value="<%:Check routing table%>" class="cbi-button cbi-button-apply" onclick="update_status('routechk', null)" />
|
||||
<input type="button" value="<%:Hotplug ifup%>" class="cbi-button cbi-button-apply" onclick="update_status('hotplug', 'ifup')" />
|
||||
<input type="button" value="<%:Hotplug ifdown%>" class="cbi-button cbi-button-apply" onclick="update_status('hotplug', 'ifdown')" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id="diag_select" class="cbi-section">
|
||||
<legend><%:MWAN3 Service Control%></legend>
|
||||
<div id="buttoncss">
|
||||
<input type="button" value="<%:Restart MWAN3%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'restart')" />
|
||||
<input type="button" value="<%:Stop MWAN3%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'stop')" />
|
||||
<input type="button" value="<%:Start MWAN3%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'start')" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="cbi-section" style="display:none">
|
||||
<legend><%:Diagnostic Results%></legend>
|
||||
<div id="diag_output"></div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<style type="text/css">
|
||||
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
|
||||
max-width: none;
|
||||
margin-left: 30px;
|
||||
padding-right: 30px;
|
||||
width: auto;
|
||||
}
|
||||
#mwan3_diagnostics {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px dotted #555555;
|
||||
padding: 20px;
|
||||
}
|
||||
#diag_select {
|
||||
padding: 12px 20px 20px 20px;
|
||||
}
|
||||
#mwan3iface {
|
||||
float: left;
|
||||
margin: 8px 20px 0px 0px;
|
||||
}
|
||||
#buttoncss {
|
||||
display: table;
|
||||
float: left;
|
||||
text-align: left;
|
||||
}
|
||||
.cbi-button {
|
||||
margin: 8px 20px 0px 0px;
|
||||
min-width: 153px;
|
||||
}
|
||||
#diag_output_css {
|
||||
padding: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
||||
<%+footer%>
|
||||
@@ -0,0 +1,23 @@
|
||||
<ul class="cbi-tabmenu">
|
||||
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/hotplug")%>"><%:Hotplug Script%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/mwan3")%>"><%:MWAN3 Config%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/network")%>"><%:Network Config%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/diag")%>"><%:Diagnostics%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/tshoot")%>"><%:Troubleshooting%></a></li>
|
||||
</ul>
|
||||
|
||||
<style type="text/css">
|
||||
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
|
||||
max-width: none;
|
||||
margin: 0px 0px 0px 30px;
|
||||
padding-right: 30px;
|
||||
width: auto;
|
||||
}
|
||||
.cbi-section-node {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.cbi-section {
|
||||
border: 1px dotted #555555;
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,23 @@
|
||||
<ul class="cbi-tabmenu">
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/hotplug")%>"><%:Hotplug Script%></a></li>
|
||||
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/mwan3")%>"><%:MWAN3 Config%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/network")%>"><%:Network Config%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/diag")%>"><%:Diagnostics%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/tshoot")%>"><%:Troubleshooting%></a></li>
|
||||
</ul>
|
||||
|
||||
<style type="text/css">
|
||||
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
|
||||
max-width: none;
|
||||
margin: 0px 0px 0px 30px;
|
||||
padding-right: 30px;
|
||||
width: auto;
|
||||
}
|
||||
.cbi-section-node {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.cbi-section {
|
||||
border: 1px dotted #555555;
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,23 @@
|
||||
<ul class="cbi-tabmenu">
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/hotplug")%>"><%:Hotplug Script%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/mwan3")%>"><%:MWAN3 Config%></a></li>
|
||||
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/network")%>"><%:Network Config%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/diag")%>"><%:Diagnostics%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/tshoot")%>"><%:Troubleshooting%></a></li>
|
||||
</ul>
|
||||
|
||||
<style type="text/css">
|
||||
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
|
||||
max-width: none;
|
||||
margin: 0px 0px 0px 30px;
|
||||
padding-right: 30px;
|
||||
width: auto;
|
||||
}
|
||||
.cbi-section-node {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.cbi-section {
|
||||
border: 1px dotted #555555;
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,77 @@
|
||||
<%+header%>
|
||||
|
||||
<ul class="cbi-tabmenu">
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/hotplug")%>"><%:Hotplug Script%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/mwan3")%>"><%:MWAN3 Config%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/network")%>"><%:Network Config%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/diag")%>"><%:Diagnostics%></a></li>
|
||||
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/tshoot")%>"><%:Troubleshooting%></a></li>
|
||||
</ul>
|
||||
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(15, '<%=luci.dispatcher.build_url("admin", "network", "mwan3", "advanced", "tshoot_display")%>', null,
|
||||
function(x, st)
|
||||
{
|
||||
var tx = document.getElementById('mwan3_tshoot_text');
|
||||
if (st.mw3ver)
|
||||
{
|
||||
var temp = '';
|
||||
var mwanvers = 'Software versions : <br /><br />';
|
||||
var mwan3cnfg = '<br /><br />Output of "cat /etc/config/mwan3" : <br /><br />';
|
||||
var netcnfg = '<br /><br />Output of "cat /etc/config/network" : <br /><br />';
|
||||
var ifcnfg = '<br /><br />Output of "ifconfig" : <br /><br />';
|
||||
var iproute = '<br /><br />Output of "route -n" : <br /><br />';
|
||||
var iprulesh = '<br /><br />Output of "ip rule show" : <br /><br />';
|
||||
var routelisttbl = '<br /><br />Output of "ip route list table 1-250" : <br /><br />';
|
||||
var firewalldef = '<br /><br />Firewall default output policy (must be ACCEPT) : <br /><br />';
|
||||
var iptable = '<br /><br />Output of "iptables -L -t mangle -v -n" : <br /><br />';
|
||||
|
||||
temp = String.format(
|
||||
'<pre><span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s</pre>',
|
||||
mwanvers, st.mw3ver[0].mwan3v, mwan3cnfg, st.mwan3config[0].mwn3cfg, netcnfg, st.netconfig[0].netcfg, ifcnfg, st.ifconfig[0].ifcfg, iproute, st.rtshow[0].iprtshow, iprulesh, st.iprule[0].rule, routelisttbl, st.routelist[0].iprtlist, firewalldef, st.fidef[0].firedef, iptable, st.iptables[0].iptbls
|
||||
);
|
||||
tx.innerHTML = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp = '';
|
||||
var terror = 'Error collecting troubleshooting information';
|
||||
temp = String.format(
|
||||
'<strong>%s</strong>',
|
||||
terror
|
||||
);
|
||||
tx.innerHTML = temp;
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]></script>
|
||||
|
||||
<div id="tshoot_div">
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Troubleshooting Data%></legend>
|
||||
<div id="mwan3_tshoot_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<style type="text/css">
|
||||
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
|
||||
max-width: none;
|
||||
margin-left: 30px;
|
||||
padding-right: 30px;
|
||||
width: auto;
|
||||
}
|
||||
#tshoot_div {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px dotted #555555;
|
||||
padding: 20px;
|
||||
}
|
||||
#mwan3_tshoot_text {
|
||||
padding: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
.tsht {
|
||||
background-color: rgb(78, 186, 241);
|
||||
}
|
||||
</style>
|
||||
|
||||
<%+footer%>
|
||||
@@ -0,0 +1,34 @@
|
||||
<style type="text/css">
|
||||
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
|
||||
max-width: none;
|
||||
margin-left: 30px;
|
||||
padding-right: 30px;
|
||||
width: auto;
|
||||
}
|
||||
table td { /*cells showing the configuration values*/
|
||||
padding: 0px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
table th { /*column for configuration section name*/
|
||||
padding: 0px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
table tbody th { /*column for configuration section name*/
|
||||
padding: 0px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.cbi-section-node table div { /*rows*/
|
||||
padding-top: 5px;
|
||||
}
|
||||
table.cbi-section-table td.cbi-section-table-cell { /*sort buttons column*/
|
||||
text-align: center;
|
||||
}
|
||||
.cbi-section h3 {
|
||||
color: rgb(85, 85, 85);
|
||||
font-family: Trebuchet MS,Verdana,sans-serif;
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,62 @@
|
||||
<%+header%>
|
||||
|
||||
<ul class="cbi-tabmenu">
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/overview")%>"><%:Interface Status%></a></li>
|
||||
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/overview/over_detail")%>"><%:Detailed Status%></a></li>
|
||||
</ul>
|
||||
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "mwan3", "overview", "detail_status")%>', null,
|
||||
function(x, st)
|
||||
{
|
||||
var tx = document.getElementById('mwan3_detail_text');
|
||||
if (st.mwan3dst)
|
||||
{
|
||||
var temp = '';
|
||||
temp = String.format(
|
||||
'<pre>%s</pre>',
|
||||
st.mwan3dst[0].detailstat
|
||||
);
|
||||
tx.innerHTML = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp = '';
|
||||
var nslg = 'No detailed status information available';
|
||||
temp = String.format(
|
||||
'<strong>%s</strong>',
|
||||
nslg
|
||||
);
|
||||
tx.innerHTML = temp;
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]></script>
|
||||
|
||||
<div id="mwan3_detail_status">
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:MWAN3 Multi-WAN Detailed Status%></legend>
|
||||
<div id="mwan3_detail_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<style type="text/css">
|
||||
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
|
||||
max-width: none;
|
||||
margin-left: 30px;
|
||||
padding-right: 30px;
|
||||
width: auto;
|
||||
}
|
||||
#mwan3_detail_status {
|
||||
border: 1px dotted #555555;
|
||||
background-color: #FFFFFF;
|
||||
padding: 20px;
|
||||
}
|
||||
#mwan3_detail_text {
|
||||
padding: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
||||
<%+footer%>
|
||||
@@ -0,0 +1,146 @@
|
||||
<%+header%>
|
||||
|
||||
<ul class="cbi-tabmenu">
|
||||
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/overview")%>"><%:Interface Status%></a></li>
|
||||
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/overview/over_detail")%>"><%:Detailed Status%></a></li>
|
||||
</ul>
|
||||
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "mwan3", "overview", "iface_status")%>', null,
|
||||
function(x, st)
|
||||
{
|
||||
var tx = document.getElementById('mwan3_status_text');
|
||||
if (st.wans)
|
||||
{
|
||||
var temp = '';
|
||||
|
||||
for( var i = 0; i < st.wans.length; i++ )
|
||||
{
|
||||
var stat = '';
|
||||
var cssc = '';
|
||||
|
||||
switch (st.wans[i].status)
|
||||
{
|
||||
case 'on':
|
||||
stat = 'Online (tracking active)';
|
||||
cssc = 'wanon';
|
||||
break;
|
||||
|
||||
case 'nm':
|
||||
stat = 'Online (tracking off)';
|
||||
cssc = 'wanon';
|
||||
break;
|
||||
|
||||
case 'off':
|
||||
stat = 'Offline';
|
||||
cssc = 'wanoff';
|
||||
break;
|
||||
|
||||
case 'ne':
|
||||
stat = 'Disabled';
|
||||
cssc = 'wanoff';
|
||||
break;
|
||||
}
|
||||
|
||||
temp += String.format(
|
||||
'<span class="%s"><strong>%s (<a href="%q">%s</a>)</strong><br />%s</span>',
|
||||
cssc, st.wans[i].name, st.wans[i].link, st.wans[i].ifname, stat
|
||||
);
|
||||
}
|
||||
tx.innerHTML = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp = '';
|
||||
var ncint = 'No MWAN3 interfaces found';
|
||||
temp = String.format(
|
||||
'<strong>%s</strong>',
|
||||
ncint
|
||||
);
|
||||
tx.innerHTML = temp;
|
||||
}
|
||||
|
||||
var tx = document.getElementById('mwan3_statuslog_text');
|
||||
if (st.mwan3log)
|
||||
{
|
||||
var temp = '';
|
||||
var mwan3lg = 'Last 50 MWAN3 systemlog entries. Newest entries sorted at the top :';
|
||||
|
||||
temp = String.format(
|
||||
'<pre>%s<br /><br />%s</pre>',
|
||||
mwan3lg, st.mwan3log[0].mwanlog
|
||||
);
|
||||
tx.innerHTML = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp = '';
|
||||
var nslg = 'No MWAN3 systemlog history found';
|
||||
temp = String.format(
|
||||
'<strong>%s</strong>',
|
||||
nslg
|
||||
);
|
||||
tx.innerHTML = temp;
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]></script>
|
||||
|
||||
<div id="mwan3_interface_status">
|
||||
<fieldset id="interface_field" class="cbi-section">
|
||||
<legend><%:MWAN3 Multi-WAN Interface Live Status%></legend>
|
||||
<div id="mwan3_status_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
|
||||
</fieldset>
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:MWAN3 Multi-WAN Interface Systemlog%></legend>
|
||||
<div id="mwan3_statuslog_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<style type="text/css">
|
||||
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
|
||||
max-width: none;
|
||||
margin-left: 30px;
|
||||
padding-right: 30px;
|
||||
width: auto;
|
||||
}
|
||||
#mwan3_interface_status {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px dotted #555555;
|
||||
padding: 20px;
|
||||
}
|
||||
#interface_field {
|
||||
padding: 12px 20px 20px 20px;
|
||||
}
|
||||
#mwan3_status_text {
|
||||
display: table;
|
||||
font-size: 14px;
|
||||
margin: auto;
|
||||
max-width: 1044px;
|
||||
min-width: 246px;
|
||||
width: 100%;
|
||||
}
|
||||
.wanon {
|
||||
background-color: rgb(144, 240, 144);
|
||||
}
|
||||
.wanoff {
|
||||
background-color: rgb(240, 144, 144);
|
||||
}
|
||||
.wanon, .wanoff {
|
||||
border-radius: 60px;
|
||||
box-shadow: 0px 2px 5px -3px;
|
||||
float: left;
|
||||
margin: 8px 3px 0px 3px;
|
||||
min-height: 30px;
|
||||
min-width: 235px;
|
||||
padding: 5px 10px 8px 10px;
|
||||
text-align: center;
|
||||
}
|
||||
#mwan3_statuslog_text {
|
||||
padding: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
||||
<%+footer%>
|
||||
@@ -0,0 +1,95 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "mwan3", "overview", "iface_status")%>', null,
|
||||
function(x, st)
|
||||
{
|
||||
var tx = document.getElementById('mwan3_status_text');
|
||||
if (st.wans)
|
||||
{
|
||||
var temp = '';
|
||||
|
||||
for( var i = 0; i < st.wans.length; i++ )
|
||||
{
|
||||
var stat = '';
|
||||
var cssc = '';
|
||||
|
||||
switch (st.wans[i].status)
|
||||
{
|
||||
case 'on':
|
||||
stat = 'Online (tracking active)';
|
||||
cssc = 'wanon';
|
||||
break;
|
||||
|
||||
case 'nm':
|
||||
stat = 'Online (tracking off)';
|
||||
cssc = 'wanon';
|
||||
break;
|
||||
|
||||
case 'off':
|
||||
stat = 'Offline';
|
||||
cssc = 'wanoff';
|
||||
break;
|
||||
|
||||
case 'ne':
|
||||
stat = 'Disabled';
|
||||
cssc = 'wanoff';
|
||||
break;
|
||||
}
|
||||
|
||||
temp += String.format(
|
||||
'<span class="%s"><strong>%s (<a href="%q">%s</a>)</strong><br />%s</span>',
|
||||
cssc, st.wans[i].name, st.wans[i].link, st.wans[i].ifname, stat
|
||||
);
|
||||
}
|
||||
tx.innerHTML = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp = '';
|
||||
var ncint = 'No MWAN3 interfaces found';
|
||||
temp += String.format(
|
||||
'<strong>%s</strong>',
|
||||
ncint
|
||||
);
|
||||
tx.innerHTML = temp;
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]></script>
|
||||
|
||||
<fieldset id="interface_field" class="cbi-section">
|
||||
<legend><%:MWAN3 Multi-WAN Interface Live Status%></legend>
|
||||
<div id="mwan3_status_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
|
||||
</fieldset>
|
||||
|
||||
<style type="text/css">
|
||||
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
|
||||
max-width: 1044px;
|
||||
}
|
||||
#interface_field {
|
||||
padding: 12px 20px 20px 20px;
|
||||
}
|
||||
#mwan3_status_text {
|
||||
display: table;
|
||||
font-size: 14px;
|
||||
margin: auto;
|
||||
max-width: 1044px;
|
||||
min-width: 246px;
|
||||
width: 100%;
|
||||
}
|
||||
.wanon {
|
||||
background-color: rgb(144, 240, 144);
|
||||
}
|
||||
.wanoff {
|
||||
background-color: rgb(240, 144, 144);
|
||||
}
|
||||
.wanon, .wanoff {
|
||||
border-radius: 60px;
|
||||
box-shadow: 0px 2px 5px -3px;
|
||||
float: left;
|
||||
margin: 8px 3px 0px 3px;
|
||||
min-height: 30px;
|
||||
min-width: 235px;
|
||||
padding: 5px 10px 8px 10px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,50 @@
|
||||
#
|
||||
# Copyright (C) 2006-2014 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:=mwan3
|
||||
PKG_VERSION:=1.5
|
||||
PKG_RELEASE:=4
|
||||
PKG_MAINTAINER:=Jeroen Louwes <jeroen.louwes@gmail.com>
|
||||
PKG_LICENSE:=GPLv2
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/mwan3
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
DEPENDS:=+ip +iptables +iptables-mod-conntrack-extra +iptables-mod-ipopt
|
||||
TITLE:=Multiwan hotplug script with connection tracking support
|
||||
MAINTAINER:=Jeroen Louwes <jeroen.louwes@gmail.com>
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/mwan3/description
|
||||
Hotplug script which makes configuration of multiple WAN interfaces simple
|
||||
and manageable. With loadbalancing/failover support for up to 250 wan
|
||||
interfaces, connection tracking and an easy to manage traffic ruleset.
|
||||
endef
|
||||
|
||||
define Package/mwan3/conffiles
|
||||
/etc/config/mwan3
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/mwan3/install
|
||||
$(CP) ./files/* $(1)
|
||||
endef
|
||||
|
||||
define Package/mwan3/postinst
|
||||
[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/mwan3 enable
|
||||
exit 0
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,mwan3))
|
||||
@@ -0,0 +1,79 @@
|
||||
|
||||
config interface 'wan'
|
||||
option enabled '1'
|
||||
list track_ip '8.8.4.4'
|
||||
list track_ip '8.8.8.8'
|
||||
list track_ip '208.67.222.222'
|
||||
list track_ip '208.67.220.220'
|
||||
option reliability '2'
|
||||
option count '1'
|
||||
option timeout '2'
|
||||
option interval '5'
|
||||
option down '3'
|
||||
option up '8'
|
||||
|
||||
config interface 'wan2'
|
||||
option enabled '0'
|
||||
list track_ip '8.8.8.8'
|
||||
list track_ip '208.67.220.220'
|
||||
option reliability '1'
|
||||
option count '1'
|
||||
option timeout '2'
|
||||
option interval '5'
|
||||
option down '3'
|
||||
option up '8'
|
||||
|
||||
config member 'wan_m1_w3'
|
||||
option interface 'wan'
|
||||
option metric '1'
|
||||
option weight '3'
|
||||
|
||||
config member 'wan_m2_w3'
|
||||
option interface 'wan'
|
||||
option metric '2'
|
||||
option weight '3'
|
||||
|
||||
config member 'wan2_m1_w2'
|
||||
option interface 'wan2'
|
||||
option metric '1'
|
||||
option weight '2'
|
||||
|
||||
config member 'wan2_m2_w2'
|
||||
option interface 'wan2'
|
||||
option metric '2'
|
||||
option weight '2'
|
||||
|
||||
config policy 'wan_only'
|
||||
list use_member 'wan_m1_w3'
|
||||
|
||||
config policy 'wan2_only'
|
||||
list use_member 'wan2_m1_w2'
|
||||
|
||||
config policy 'balanced'
|
||||
list use_member 'wan_m1_w3'
|
||||
list use_member 'wan2_m1_w2'
|
||||
|
||||
config policy 'wan_wan2'
|
||||
list use_member 'wan_m1_w3'
|
||||
list use_member 'wan2_m2_w2'
|
||||
|
||||
config policy 'wan2_wan'
|
||||
list use_member 'wan_m2_w3'
|
||||
list use_member 'wan2_m1_w2'
|
||||
|
||||
config rule 'sticky_even'
|
||||
option src_ip '0.0.0.0/0.0.0.1'
|
||||
option dest_port '443'
|
||||
option proto 'tcp'
|
||||
option use_policy 'wan_wan2'
|
||||
|
||||
config rule 'sticky_odd'
|
||||
option src_ip '0.0.0.1/0.0.0.1'
|
||||
option dest_port '443'
|
||||
option proto 'tcp'
|
||||
option use_policy 'wan2_wan'
|
||||
|
||||
config rule 'default_rule'
|
||||
option dest_ip '0.0.0.0/0'
|
||||
option use_policy 'balanced'
|
||||
|
||||
@@ -0,0 +1,327 @@
|
||||
#!/bin/sh
|
||||
|
||||
mwan3_get_iface_id()
|
||||
{
|
||||
let iface_count++
|
||||
[ "$1" == "$INTERFACE" ] && iface_id=$iface_count
|
||||
}
|
||||
|
||||
mwan3_set_general_iptables()
|
||||
{
|
||||
if ! $IPT -S mwan3_ifaces &> /dev/null; then
|
||||
$IPT -N mwan3_ifaces
|
||||
fi
|
||||
|
||||
if ! $IPT -S mwan3_rules &> /dev/null; then
|
||||
$IPT -N mwan3_rules
|
||||
fi
|
||||
|
||||
if ! $IPT -S mwan3_connected &> /dev/null; then
|
||||
$IPT -N mwan3_connected
|
||||
fi
|
||||
|
||||
if ! $IPT -S mwan3_hook &> /dev/null; then
|
||||
$IPT -N mwan3_hook
|
||||
$IPT -A mwan3_hook -j CONNMARK --restore-mark --nfmask 0xff00 --ctmask 0xff00
|
||||
$IPT -A mwan3_hook -m mark --mark 0x0/0xff00 -j mwan3_ifaces
|
||||
$IPT -A mwan3_hook -m mark --mark 0x0/0xff00 -j mwan3_connected
|
||||
$IPT -A mwan3_hook -m mark --mark 0x0/0xff00 -j mwan3_rules
|
||||
$IPT -A mwan3_hook -j CONNMARK --save-mark --nfmask 0xff00 --ctmask 0xff00
|
||||
$IPT -A mwan3_hook -m mark ! --mark 0xff00/0xff00 -j mwan3_connected
|
||||
fi
|
||||
|
||||
if ! $IPT -S mwan3_output_hook &> /dev/null; then
|
||||
$IPT -N mwan3_output_hook
|
||||
fi
|
||||
|
||||
if ! $IPT -S PREROUTING | grep mwan3_hook &> /dev/null; then
|
||||
$IPT -A PREROUTING -j mwan3_hook
|
||||
fi
|
||||
|
||||
if ! $IPT -S OUTPUT | grep mwan3_hook &> /dev/null; then
|
||||
$IPT -A OUTPUT -j mwan3_hook
|
||||
fi
|
||||
|
||||
if ! $IPT -S OUTPUT | grep mwan3_output_hook &> /dev/null; then
|
||||
$IPT -A OUTPUT -j mwan3_output_hook
|
||||
fi
|
||||
|
||||
$IPT -F mwan3_rules
|
||||
}
|
||||
|
||||
mwan3_set_connected_iptables()
|
||||
{
|
||||
local connected_networks
|
||||
|
||||
if $IPT -S mwan3_connected &> /dev/null; then
|
||||
$IPT -F mwan3_connected
|
||||
|
||||
for connected_networks in $($IP route | awk '{print $1}' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}'); do
|
||||
$IPT -A mwan3_connected -d $connected_networks -j MARK --set-xmark 0xff00/0xff00
|
||||
done
|
||||
|
||||
$IPT -I mwan3_connected -d 224.0.0.0/3 -j MARK --set-xmark 0xff00/0xff00
|
||||
$IPT -I mwan3_connected -d 127.0.0.0/8 -j MARK --set-xmark 0xff00/0xff00
|
||||
fi
|
||||
}
|
||||
|
||||
mwan3_set_iface_iptables()
|
||||
{
|
||||
local local_net local_nets
|
||||
|
||||
local_net=$($IP route list dev $DEVICE scope link | awk '{print $1}' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}')
|
||||
|
||||
if ! $IPT -S mwan3_iface_$INTERFACE &> /dev/null; then
|
||||
$IPT -N mwan3_iface_$INTERFACE
|
||||
fi
|
||||
|
||||
$IPT -F mwan3_iface_$INTERFACE
|
||||
$IPT -D mwan3_ifaces -i $DEVICE -m mark --mark 0x0/0xff00 -j mwan3_iface_$INTERFACE &> /dev/null
|
||||
|
||||
if [ $ACTION == "ifup" ]; then
|
||||
if [ -n "$local_net" ]; then
|
||||
for local_nets in $local_net ; do
|
||||
if [ $ACTION == "ifup" ]; then
|
||||
$IPT -I mwan3_iface_$INTERFACE -s $local_net -m mark --mark 0x0/0xff00 -m comment --comment "$INTERFACE" -j MARK --set-xmark 0xff00/0xff00
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
$IPT -A mwan3_iface_$INTERFACE -m mark --mark 0x0/0xff00 -m comment --comment "$INTERFACE" -j MARK --set-xmark $(($iface_id*256))/0xff00
|
||||
$IPT -A mwan3_ifaces -i $DEVICE -m mark --mark 0x0/0xff00 -j mwan3_iface_$INTERFACE
|
||||
fi
|
||||
|
||||
if [ $ACTION == "ifdown" ]; then
|
||||
$IPT -X mwan3_iface_$INTERFACE
|
||||
fi
|
||||
}
|
||||
|
||||
mwan3_set_iface_route()
|
||||
{
|
||||
$IP route flush table $iface_id
|
||||
[ $ACTION == "ifup" ] && $IP route add table $iface_id default $route_args
|
||||
}
|
||||
|
||||
mwan3_set_iface_rules()
|
||||
{
|
||||
while [ -n "$($IP rule list | awk '$1 == "'$(($iface_id+1000)):'"')" ]; do
|
||||
$IP rule del pref $(($iface_id+1000))
|
||||
done
|
||||
|
||||
while [ -n "$($IP rule list | awk '$1 == "'$(($iface_id+2000)):'"')" ]; do
|
||||
$IP rule del pref $(($iface_id+2000))
|
||||
done
|
||||
|
||||
while [ -n "$($IP rule list | awk '$1 == "2254:"')" ]; do
|
||||
$IP rule del pref 2254
|
||||
done
|
||||
|
||||
[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+1000)) iif $DEVICE lookup main
|
||||
[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+2000)) fwmark $(($iface_id*256))/0xff00 lookup $iface_id
|
||||
$IP rule add pref 2254 fwmark 0xfe00/0xff00 unreachable
|
||||
}
|
||||
|
||||
mwan3_track()
|
||||
{
|
||||
local track_ip track_ips reliability count timeout interval down up
|
||||
|
||||
mwan3_list_track_ips()
|
||||
{
|
||||
track_ips="$1 $track_ips"
|
||||
}
|
||||
config_list_foreach $INTERFACE track_ip mwan3_list_track_ips
|
||||
|
||||
if [ -n "$track_ips" ]; then
|
||||
config_get reliability $INTERFACE reliability 1
|
||||
config_get count $INTERFACE count 1
|
||||
config_get timeout $INTERFACE timeout 4
|
||||
config_get interval $INTERFACE interval 10
|
||||
config_get down $INTERFACE down 5
|
||||
config_get up $INTERFACE up 5
|
||||
|
||||
if ! $IPT -S mwan3_track_$INTERFACE &> /dev/null; then
|
||||
$IPT -N mwan3_track_$INTERFACE
|
||||
$IPT -A mwan3_output_hook -p icmp -m icmp --icmp-type 8 -m length --length 32 -j mwan3_track_$INTERFACE
|
||||
fi
|
||||
|
||||
$IPT -F mwan3_track_$INTERFACE
|
||||
|
||||
for track_ip in $track_ips; do
|
||||
$IPT -A mwan3_track_$INTERFACE -d $track_ip -j MARK --set-xmark 0xff00/0xff00
|
||||
done
|
||||
|
||||
[ -x /usr/sbin/mwan3track ] && /usr/sbin/mwan3track $INTERFACE $DEVICE $reliability $count $timeout $interval $down $up $track_ips &
|
||||
else
|
||||
$IPT -D mwan3_output_hook -p icmp -m icmp --icmp-type 8 -m length --length 32 -j mwan3_track_$INTERFACE &> /dev/null
|
||||
$IPT -F mwan3_track_$INTERFACE &> /dev/null
|
||||
$IPT -X mwan3_track_$INTERFACE &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
mwan3_set_policy()
|
||||
{
|
||||
local iface_count iface_id INTERFACE metric probability weight
|
||||
|
||||
config_get INTERFACE $1 interface
|
||||
config_get metric $1 metric 1
|
||||
config_get weight $1 weight 1
|
||||
|
||||
[ -n "$INTERFACE" ] || return 0
|
||||
|
||||
config_foreach mwan3_get_iface_id interface
|
||||
|
||||
[ -n "$iface_id" ] || return 0
|
||||
|
||||
if $IPT -S mwan3_iface_$INTERFACE &> /dev/null; then
|
||||
if [ "$metric" -lt "$lowest_metric" ]; then
|
||||
|
||||
total_weight=$weight
|
||||
$IPT -F mwan3_policy_$policy
|
||||
$IPT -A mwan3_policy_$policy -m mark --mark 0x0/0xff00 -m comment --comment "$INTERFACE $weight $weight" -j MARK --set-xmark $(($iface_id*256))/0xff00
|
||||
|
||||
lowest_metric=$metric
|
||||
|
||||
elif [ "$metric" -eq "$lowest_metric" ]; then
|
||||
|
||||
total_weight=$(($total_weight+$weight))
|
||||
probability=$(($weight*1000/$total_weight))
|
||||
|
||||
if [ "$probability" -lt 10 ]; then
|
||||
probability="0.00$probability"
|
||||
elif [ $probability -lt 100 ]; then
|
||||
probability="0.0$probability"
|
||||
elif [ $probability -lt 1000 ]; then
|
||||
probability="0.$probability"
|
||||
else
|
||||
probability="1"
|
||||
fi
|
||||
|
||||
probability="-m statistic --mode random --probability $probability"
|
||||
|
||||
$IPT -I mwan3_policy_$policy -m mark --mark 0x0/0xff00 $probability -m comment --comment "$INTERFACE $weight $total_weight" -j MARK --set-xmark $(($iface_id*256))/0xff00
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
mwan3_set_policies_iptables()
|
||||
{
|
||||
local lowest_metric policy total_weight
|
||||
|
||||
policy=$1
|
||||
|
||||
if [ "$policy" != $(echo "$policy" | cut -c1-15) ]; then
|
||||
$LOG warn "Policy $policy exceeds max of 15 chars. Not setting policy" && return 0
|
||||
fi
|
||||
|
||||
if ! $IPT -S mwan3_policy_$policy &> /dev/null; then
|
||||
$IPT -N mwan3_policy_$policy
|
||||
fi
|
||||
|
||||
$IPT -F mwan3_policy_$policy
|
||||
$IPT -A mwan3_policy_$policy -m mark --mark 0x0/0xff00 -m comment --comment "unreachable" -j MARK --set-xmark 0xfe00/0xff00
|
||||
|
||||
lowest_metric=256
|
||||
total_weight=0
|
||||
|
||||
config_list_foreach $policy use_member mwan3_set_policy
|
||||
}
|
||||
|
||||
mwan3_set_user_rules_iptables()
|
||||
{
|
||||
local proto src_ip src_port dest_ip dest_port use_policy
|
||||
|
||||
config_get proto $1 proto all
|
||||
config_get src_ip $1 src_ip 0.0.0.0/0
|
||||
config_get src_port $1 src_port 0:65535
|
||||
config_get dest_ip $1 dest_ip 0.0.0.0/0
|
||||
config_get dest_port $1 dest_port 0:65535
|
||||
config_get use_policy $1 use_policy
|
||||
|
||||
if [ -n "$use_policy" ]; then
|
||||
if [ "$use_policy" == "default" ]; then
|
||||
use_policy="MARK --set-xmark 0xff00/0xff00"
|
||||
elif [ "$use_policy" == "unreachable" ]; then
|
||||
use_policy="MARK --set-xmark 0xfe00/0xff00"
|
||||
else
|
||||
use_policy="mwan3_policy_$use_policy"
|
||||
fi
|
||||
|
||||
case $proto in
|
||||
tcp|udp)
|
||||
$IPT -A mwan3_rules -p $proto -s $src_ip -d $dest_ip -m multiport --sports $src_port -m multiport --dports $dest_port -m mark --mark 0/0xff00 -m comment --comment "$1" -j $use_policy &> /dev/null
|
||||
;;
|
||||
*)
|
||||
$IPT -A mwan3_rules -p $proto -s $src_ip -d $dest_ip -m mark --mark 0/0xff00 -m comment --comment "$1" -j $use_policy &> /dev/null
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
mwan3_ifupdown()
|
||||
{
|
||||
local counter enabled iface_count iface_id route_args wan_metric
|
||||
|
||||
config_load mwan3
|
||||
config_foreach mwan3_get_iface_id interface
|
||||
|
||||
[ -n "$iface_id" ] || return 0
|
||||
[ "$iface_count" -le 250 ] || return 0
|
||||
unset iface_count
|
||||
|
||||
config_get enabled $INTERFACE enabled 0
|
||||
|
||||
counter=0
|
||||
|
||||
if [ $ACTION == "ifup" ]; then
|
||||
[ "$enabled" -eq 1 ] || return 0
|
||||
|
||||
while [ -z "$($IP route list dev $DEVICE default | head -1)" -a "$counter" -lt 10 ]; do
|
||||
sleep 1
|
||||
let counter++
|
||||
if [ "$counter" -ge 10 ]; then
|
||||
$LOG warn "Could not find gateway for interface $INTERFACE ($DEVICE)" && return 0
|
||||
fi
|
||||
done
|
||||
|
||||
route_args=$($IP route list dev $DEVICE default | head -1 | sed '/.*via \([^ ]*\) .*$/!d;s//via \1/;q' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}')
|
||||
route_args="nexthop $route_args dev $DEVICE"
|
||||
fi
|
||||
|
||||
while [ "$(pgrep -f -o hotplug-call)" -ne $$ -a "$counter" -lt 60 ]; do
|
||||
sleep 1
|
||||
let counter++
|
||||
if [ "$counter" -ge 60 ]; then
|
||||
$LOG warn "Timeout waiting for older hotplug processes to finish. $ACTION interface $INTERFACE ($DEVICE) aborted" && return 0
|
||||
fi
|
||||
done
|
||||
|
||||
$LOG notice "$ACTION interface $INTERFACE ($DEVICE)"
|
||||
|
||||
mwan3_set_general_iptables
|
||||
mwan3_set_iface_iptables
|
||||
mwan3_set_iface_route
|
||||
mwan3_set_iface_rules
|
||||
|
||||
[ $ACTION == "ifup" ] && mwan3_track
|
||||
|
||||
config_foreach mwan3_set_policies_iptables policy
|
||||
config_foreach mwan3_set_user_rules_iptables rule
|
||||
}
|
||||
|
||||
[ -n "$DEVICE" ] || exit 0
|
||||
[ -n "$INTERFACE" ] || exit 0
|
||||
|
||||
local IP IPT LOG
|
||||
|
||||
IP="/usr/sbin/ip -4"
|
||||
IPT="/usr/sbin/iptables -t mangle -w"
|
||||
LOG="/usr/bin/logger -t mwan3 -p"
|
||||
|
||||
case "$ACTION" in
|
||||
ifup|ifdown)
|
||||
mwan3_ifupdown
|
||||
mwan3_set_connected_iptables
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
START=99
|
||||
|
||||
start() {
|
||||
/usr/sbin/mwan3 start
|
||||
}
|
||||
|
||||
stop() {
|
||||
/usr/sbin/mwan3 stop
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
boot() {
|
||||
return 0
|
||||
}
|
||||
Executable
+205
@@ -0,0 +1,205 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
. /lib/network/config.sh
|
||||
|
||||
extra_help() {
|
||||
cat <<EOF
|
||||
|
||||
ifup <iface> Start service on interface
|
||||
ifdown <iface> Stop service on interface
|
||||
interfaces Show interfaces status
|
||||
policies Show policies status
|
||||
rules Show rules status
|
||||
status Show all status
|
||||
EOF
|
||||
}
|
||||
|
||||
EXTRA_COMMANDS="ifdown ifup interfaces policies rules status"
|
||||
EXTRA_HELP="$(extra_help)"
|
||||
IP="/usr/sbin/ip -4"
|
||||
IPT="/usr/sbin/iptables -t mangle -w"
|
||||
|
||||
ifdown()
|
||||
{
|
||||
local device
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: Expecting interface. Usage: mwan3 ifdown <interface>" && exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
echo "Error: Too many arguments. Usage: mwan3 ifdown <interface>" && exit 0
|
||||
fi
|
||||
|
||||
device=$(uci get -p /var/state network.$1.ifname) &> /dev/null
|
||||
|
||||
if [ -e /var/run/mwan3track-$1.pid ] ; then
|
||||
kill $(cat /var/run/mwan3track-$1.pid)
|
||||
rm /var/run/mwan3track-$1.pid
|
||||
fi
|
||||
|
||||
if [ -n "$device" ] ; then
|
||||
ACTION=ifdown INTERFACE=$1 DEVICE=$device /sbin/hotplug-call iface
|
||||
fi
|
||||
}
|
||||
|
||||
ifup()
|
||||
{
|
||||
local device enabled
|
||||
|
||||
config_load mwan3
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Expecting interface. Usage: mwan3 ifup <interface>" && exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
echo "Too many arguments. Usage: mwan3 ifup <interface>" && exit 0
|
||||
fi
|
||||
|
||||
config_get enabled "$1" enabled 0
|
||||
|
||||
device=$(uci get -p /var/state network.$1.ifname) &> /dev/null
|
||||
|
||||
if [ -n "$device" ] ; then
|
||||
[ "$enabled" -eq 1 ] && ACTION=ifup INTERFACE=$1 DEVICE=$device /sbin/hotplug-call iface
|
||||
fi
|
||||
}
|
||||
|
||||
interfaces()
|
||||
{
|
||||
local device enabled iface_id tracking
|
||||
|
||||
config_load mwan3
|
||||
|
||||
echo "Interface status:"
|
||||
|
||||
check_iface_status()
|
||||
{
|
||||
device=$(uci get -p /var/state network.$1.ifname) &> /dev/null
|
||||
|
||||
if [ -z "$device" ]; then
|
||||
echo "Interface $1 is unknown"
|
||||
return 0
|
||||
fi
|
||||
|
||||
config_get enabled "$1" enabled 0
|
||||
let iface_id++
|
||||
|
||||
if [ -n "$(ps -w | grep mwan3track | grep -v grep | sed '/.*\/usr\/sbin\/mwan3track \([^ ]*\) .*$/!d;s//\1/' | awk '$1 == "'$1'"')" ]; then
|
||||
tracking="active"
|
||||
else
|
||||
tracking="down"
|
||||
fi
|
||||
|
||||
if [ -n "$($IP rule | awk '$5 == "'$device'"')" -a -n "$($IPT -S mwan3_iface_$1 2> /dev/null)" -a -n "$($IP route list table $iface_id default dev $device 2> /dev/null)" ]; then
|
||||
if [ -n "$(uci get -p /var/state mwan3.$1.track_ip 2> /dev/null)" ]; then
|
||||
echo "Interface $1 is online (tracking $tracking)"
|
||||
else
|
||||
echo "Interface $1 is online"
|
||||
fi
|
||||
elif [ -n "$($IP rule | awk '$5 == "'$device'"')" -o -n "$($IPT -S mwan3_iface_$1 2> /dev/null)" -o -n "$($IP route list table $iface_id default dev $device 2> /dev/null)" ]; then
|
||||
echo "Interface $1 error"
|
||||
else
|
||||
if [ "$enabled" -eq 1 ]; then
|
||||
if [ -n "$(uci get -p /var/state mwan3.$1.track_ip 2> /dev/null)" ]; then
|
||||
echo "Interface $1 is offline (tracking $tracking)"
|
||||
else
|
||||
echo "Interface $1 is offline"
|
||||
fi
|
||||
else
|
||||
echo "Interface $1 is disabled"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
config_foreach check_iface_status interface
|
||||
echo -e
|
||||
}
|
||||
|
||||
policies()
|
||||
{
|
||||
local percent policy share total_weight weight iface
|
||||
|
||||
for policy in $($IPT -S | awk '{print $2}' | grep mwan3_policy_ | sort -u); do
|
||||
echo "Policy $policy:" | sed 's/mwan3_policy_//g'
|
||||
|
||||
[ -n "$total_weight" ] || total_weight=$($IPT -S $policy | cut -s -d'"' -f2 | head -1 | awk '{print $3}')
|
||||
|
||||
if [ ! -z "${total_weight##*[!0-9]*}" ]; then
|
||||
for iface in $($IPT -S $policy | cut -s -d'"' -f2 | awk '{print $1}'); do
|
||||
weight=$($IPT -S $policy | cut -s -d'"' -f2 | awk '$1 == "'$iface'"' | awk '{print $2}')
|
||||
percent=$(($weight*100/$total_weight))
|
||||
echo " $iface ($percent%)"
|
||||
done
|
||||
else
|
||||
echo " $($IPT -S $policy | sed '/.*--comment \([^ ]*\) .*$/!d;s//\1/;q')"
|
||||
fi
|
||||
|
||||
echo -e
|
||||
|
||||
unset iface
|
||||
unset total_weight
|
||||
done
|
||||
}
|
||||
rules()
|
||||
{
|
||||
if [ -n "$($IPT -S mwan3_connected 2> /dev/null)" ]; then
|
||||
echo "Known networks:"
|
||||
echo "destination policy hits" | awk '{ printf "%-19s%-19s%-9s%s\n",$1,$2,$3}' | awk '1; {gsub(".","-")}1'
|
||||
$IPT -L mwan3_connected -n -v 2> /dev/null | tail -n+3 | sed 's/mark.*//' | sed 's/mwan3_policy_//' | awk '{printf "%-19s%-19s%-9s%s\n",$9,"default",$1}'
|
||||
echo -e
|
||||
fi
|
||||
|
||||
if [ -n "$($IPT -S mwan3_rules 2> /dev/null)" ]; then
|
||||
echo "Active rules:"
|
||||
echo "source destination proto src-port dest-port policy hits" | awk '{ printf "%-19s%-19s%-7s%-14s%-14s%-16s%-9s%s\n",$1,$2,$3,$4,$5,$6,$7}' | awk '1; {gsub(".","-")}1'
|
||||
$IPT -L mwan3_rules -n -v 2> /dev/null | tail -n+3 | sed 's/mark.*//' | sed 's/mwan3_policy_//' | awk '{ printf "%-19s%-19s%-7s%-14s%-14s%-16s%-9s%s\n",$8,$9,$4,$12,$15,$3,$1}'
|
||||
echo -e
|
||||
fi
|
||||
}
|
||||
|
||||
status()
|
||||
{
|
||||
interfaces
|
||||
policies
|
||||
rules
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
config_load mwan3
|
||||
config_foreach ifup interface
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
local route rule table
|
||||
|
||||
killall mwan3track &> /dev/null
|
||||
rm /var/run/mwan3track-* &> /dev/null
|
||||
|
||||
for route in $($IP route list table all | sed 's/.*table \([^ ]*\) .*/\1/' | awk '{print $1}' | awk '{for(i=1;i<=NF;i++) if($i+0>0) if($i+0<255) {print;break}}'); do
|
||||
$IP route flush table $route &> /dev/null
|
||||
done
|
||||
|
||||
for rule in $($IP rule list | egrep '^[1-2][0-9]{3}\:' | cut -d ':' -f 1); do
|
||||
$IP rule del pref $rule &> /dev/null
|
||||
done
|
||||
|
||||
$IPT -D PREROUTING -j mwan3_hook &> /dev/null
|
||||
$IPT -D OUTPUT -j mwan3_hook &> /dev/null
|
||||
$IPT -D OUTPUT -j mwan3_output_hook &> /dev/null
|
||||
|
||||
for table in $($IPT -S | awk '{print $2}' | grep mwan3 | sort -u); do
|
||||
$IPT -F $table &> /dev/null
|
||||
done
|
||||
|
||||
for table in $($IPT -S | awk '{print $2}' | grep mwan3 | sort -u); do
|
||||
$IPT -X $table &> /dev/null
|
||||
done
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -z "$9" ] && echo "Error: should not be started manually" && exit 0
|
||||
|
||||
if [ -e /var/run/mwan3track-$1.pid ] ; then
|
||||
kill $(cat /var/run/mwan3track-$1.pid) &> /dev/null
|
||||
rm /var/run/mwan3track-$1.pid &> /dev/null
|
||||
fi
|
||||
|
||||
echo "$$" > /var/run/mwan3track-$1.pid
|
||||
|
||||
score=$(($7+$8))
|
||||
track_ips=$(echo $* | cut -d ' ' -f 9-99)
|
||||
host_up_count=0
|
||||
lost=0
|
||||
|
||||
while true; do
|
||||
|
||||
for track_ip in $track_ips; do
|
||||
ping -I $2 -c $4 -W $5 -s 4 -q $track_ip &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
let host_up_count++
|
||||
else
|
||||
let lost++
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $host_up_count -lt $3 ]; then
|
||||
let score--
|
||||
|
||||
if [ $score -lt $8 ]; then score=0 ; fi
|
||||
if [ $score -eq $8 ]; then
|
||||
|
||||
logger -t mwan3track -p notice "Interface $1 ($2) is offline"
|
||||
env -i ACTION=ifdown INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface
|
||||
score=0
|
||||
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
if [ $score -lt $(($7+$8)) ] && [ $lost -gt 0 ]; then
|
||||
|
||||
logger -t mwan3track -p info "Lost $(($lost*$4)) ping(s) on interface $1 ($2)"
|
||||
|
||||
fi
|
||||
|
||||
let score++
|
||||
lost=0
|
||||
|
||||
if [ $score -gt $8 ]; then score=$(($7+$8)); fi
|
||||
if [ $score -eq $8 ]; then
|
||||
|
||||
logger -t mwan3track -p notice "Interface $1 ($2) is online"
|
||||
env -i ACTION=ifup INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface
|
||||
rm /var/run/mwan3track-$1.pid
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
host_up_count=0
|
||||
sleep $6
|
||||
done
|
||||
|
||||
exit 1
|
||||
@@ -0,0 +1,86 @@
|
||||
#
|
||||
# Copyright (C) 2009-2013 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:=netatalk
|
||||
PKG_VERSION:=2.2.4
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=@SF/netatalk
|
||||
PKG_MD5SUM:=40753a32340c24e4ec395aeb55ef056e
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/netatalk
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Filesystem
|
||||
DEPENDS:=+attr +libdb47 +libgcrypt +libopenssl $(LIBRPC_DEPENDS)
|
||||
TITLE:=netatalk
|
||||
URL:=http://netatalk.sourceforge.net
|
||||
MAINTAINER:=W. Michael Petullo <mike@flyn.org>
|
||||
endef
|
||||
|
||||
define Package/netatalk/decription
|
||||
Netatalk is a freely-available Open Source AFP fileserver.
|
||||
It also provides a kernel level implementation of the AppleTalk
|
||||
Protocol Suite.
|
||||
endef
|
||||
|
||||
define Package/netatalk/conffiles
|
||||
/etc/netatalk/afpd.conf
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += -std=gnu99
|
||||
TARGET_LDFLAGS += $(LIBRPC)
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--disable-afs \
|
||||
--enable-hfs \
|
||||
--disable-debugging \
|
||||
--disable-shell-check \
|
||||
--disable-timelord \
|
||||
--disable-a2boot \
|
||||
--disable-cups \
|
||||
--disable-tcp-wrappers \
|
||||
--with-cnid-default-backend=dbd \
|
||||
--with-bdb="$(STAGING_DIR)/usr/" \
|
||||
--with-libgcrypt-dir="$(STAGING_DIR)/usr" \
|
||||
--with-ssl-dir="$(STAGING_DIR)/usr" \
|
||||
--with-uams-path="/usr/lib/uams" \
|
||||
--without-acls \
|
||||
--without-pam \
|
||||
--disable-admin-group \
|
||||
--disable-srvloc \
|
||||
--disable-zeroconf \
|
||||
$(if $(CONFIG_SHADOW_PASSWORDS),--with-shadow,--without-shadow) \
|
||||
--without-ldap
|
||||
|
||||
define Package/netatalk/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/usr/lib/uams
|
||||
$(INSTALL_DIR) $(1)/etc/netatalk
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/bin/afppasswd $(1)/usr/bin/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/afpd $(1)/usr/sbin/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/cnid_dbd $(1)/usr/sbin/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/cnid_metad $(1)/usr/sbin/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/uams/*.so $(1)/usr/lib/uams/
|
||||
$(CP) ./files/AppleVolumes.default $(1)/etc/netatalk/
|
||||
$(CP) $(PKG_INSTALL_DIR)/etc/netatalk/AppleVolumes.system $(1)/etc/netatalk/
|
||||
$(INSTALL_CONF) ./files/afpd.conf $(1)/etc/netatalk/
|
||||
$(INSTALL_BIN) ./files/afpd.init $(1)/etc/init.d/afpd
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,netatalk))
|
||||
@@ -0,0 +1,2 @@
|
||||
-
|
||||
/tmp Temp allow:root,nobody cnidscheme:dbd
|
||||
@@ -0,0 +1 @@
|
||||
- -noddp -uampath /usr/lib/uams -uamlist uams_guest.so,uams_passwd.so,uams_dhx_passwd.so,uams_randnum.so,uams_dhx2.so -passwdfile /etc/netatalk/afppasswd -savepassword -passwdminlen 0 -nosetpassword -defaultvol /etc/netatalk/AppleVolumes.default -systemvol /etc/netatalk/AppleVolumes.system -nouservol -guestname "nobody" -sleep 1 -icon
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2010-2012 OpenWrt.org
|
||||
|
||||
START=70
|
||||
|
||||
MAXCONS="7"
|
||||
|
||||
start()
|
||||
{
|
||||
service_start /usr/sbin/cnid_metad
|
||||
service_start /usr/sbin/afpd -c ${MAXCONS}
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
service_stop /usr/sbin/afpd
|
||||
service_stop /usr/sbin/cnid_metad
|
||||
}
|
||||
|
||||
reload()
|
||||
{
|
||||
service_reload /usr/sbin/afpd
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
--- a/macros/iconv.m4
|
||||
+++ b/macros/iconv.m4
|
||||
@@ -114,6 +114,5 @@ int main() {
|
||||
|
||||
CFLAGS="$savedcflags"
|
||||
LDFLAGS="$savedldflags"
|
||||
- CPPFLAGS="$saved_CPPFLAGS"
|
||||
|
||||
])
|
||||
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# Copyright (C) 2006-2014 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:=ntpclient
|
||||
PKG_VERSION:=2010_365
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://doolittle.icarus.com/ntpclient/
|
||||
PKG_MD5SUM:=a64689398f2df8933ee0d8da246e9eaa
|
||||
|
||||
PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-2010
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ntpclient
|
||||
SUBMENU:=Time Synchronization
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=NTP (Network Time Protocol) client
|
||||
URL:=http://doolittle.icarus.com/ntpclient/
|
||||
DEPENDS:=+librt
|
||||
endef
|
||||
|
||||
define Package/ntpclient/description
|
||||
NTP client for setting system time from NTP servers.
|
||||
endef
|
||||
|
||||
define Package/ntpclient/conffiles
|
||||
/etc/config/ntpclient
|
||||
endef
|
||||
|
||||
MAKE_FLAGS += \
|
||||
all adjtimex
|
||||
|
||||
define Package/ntpclient/install
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_DATA) ./files/ntpclient.hotplug $(1)/etc/hotplug.d/iface/20-ntpclient
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/ntpclient.config $(1)/etc/config/ntpclient
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ntpclient $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/adjtimex $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/rate.awk $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ntpclient))
|
||||
@@ -0,0 +1,23 @@
|
||||
config ntpserver
|
||||
option hostname '0.openwrt.pool.ntp.org'
|
||||
option port '123'
|
||||
|
||||
config ntpserver
|
||||
option hostname '1.openwrt.pool.ntp.org'
|
||||
option port '123'
|
||||
|
||||
config ntpserver
|
||||
option hostname '2.openwrt.pool.ntp.org'
|
||||
option port '123'
|
||||
|
||||
config ntpserver
|
||||
option hostname '3.openwrt.pool.ntp.org'
|
||||
option port '123'
|
||||
|
||||
config ntpdrift
|
||||
option freq '0'
|
||||
|
||||
config ntpclient
|
||||
option interval 600
|
||||
#option count 10
|
||||
#option interface wan
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006-2014 OpenWrt.org
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
unset SERVER
|
||||
unset PORT
|
||||
unset INTERVAL
|
||||
unset COUNT
|
||||
unset INTERFACE_GLOBAL
|
||||
|
||||
NTPC=`which ntpclient`
|
||||
|
||||
check_server() {
|
||||
local hostname
|
||||
local port
|
||||
local interface
|
||||
[ -n "$SERVER" ] && return
|
||||
config_get hostname $1 hostname
|
||||
config_get port $1 port
|
||||
config_get interface $1 interface
|
||||
|
||||
[ -z "$interface" ] && interface=$INTERFACE_GLOBAL
|
||||
|
||||
[ -n "$interface" ] && {
|
||||
# $INTERFACE is passed from hotplug event
|
||||
[ "$interface" = "$INTERFACE" ] || return
|
||||
}
|
||||
|
||||
[ -z "$hostname" ] && return
|
||||
$NTPC -c 1 -p ${port:-123} -i 2 -h $hostname > /dev/null && { SERVER=$hostname; PORT=${port:-123}; }
|
||||
}
|
||||
|
||||
set_drift() {
|
||||
config_get freq $1 freq
|
||||
[ -n "$freq" ] && adjtimex -f $freq >/dev/null
|
||||
}
|
||||
|
||||
start_ntpclient() {
|
||||
config_foreach set_drift ntpdrift
|
||||
config_foreach check_server ntpserver
|
||||
[ -z "$SERVER" ] && exit 0
|
||||
logger starting ntpclient
|
||||
$NTPC ${COUNT:+-c $COUNT} ${INTERVAL:+-i $INTERVAL} -s -l -D -p $PORT -h $SERVER 2> /dev/null
|
||||
}
|
||||
|
||||
stop_ntpclient() {
|
||||
logger stopping ntpclient
|
||||
killall ntpclient
|
||||
}
|
||||
|
||||
load_settings() {
|
||||
local interval
|
||||
local count
|
||||
local iface
|
||||
|
||||
config_get interval $1 interval
|
||||
config_get count $1 count
|
||||
config_get interface $1 interface
|
||||
|
||||
[ -n "$count" ] && COUNT=$count
|
||||
[ -n "$interval" ] && INTERVAL=$interval
|
||||
[ -n "$interface" ] && INTERFACE_GLOBAL=$interface
|
||||
}
|
||||
|
||||
config_load ntpclient
|
||||
config_foreach load_settings ntpclient
|
||||
|
||||
NTP_RUNNING=`ps | grep $NTPC | grep -v grep`
|
||||
|
||||
case "${ACTION:-ifup}" in
|
||||
ifup)
|
||||
[ -z "$NTP_RUNNING" ] && start_ntpclient
|
||||
;;
|
||||
ifdown)
|
||||
[ -n "$NTP_RUNNING" ] && stop_ntpclient
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/ntpclient.c
|
||||
+++ b/ntpclient.c
|
||||
@@ -611,7 +611,7 @@ int main(int argc, char *argv[]) {
|
||||
ntpc.cross_check=1;
|
||||
|
||||
for (;;) {
|
||||
- c = getopt( argc, argv, "c:" DEBUG_OPTION "f:g:h:i:lp:q:" REPLAY_OPTION "st");
|
||||
+ c = getopt( argc, argv, "c:" DEBUG_OPTION "f:g:h:i:lp:q:" REPLAY_OPTION "stD");
|
||||
if (c == EOF) break;
|
||||
switch (c) {
|
||||
case 'c':
|
||||
@@ -660,6 +660,10 @@ int main(int argc, char *argv[]) {
|
||||
(ntpc.cross_check)=0;
|
||||
break;
|
||||
|
||||
+ case 'D':
|
||||
+ daemon(0, 0);
|
||||
+ break;
|
||||
+
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
@@ -9,6 +9,6 @@ config OCSERV_PAM
|
||||
|
||||
config OCSERV_PROTOBUF
|
||||
bool "use external libprotobuf"
|
||||
default n
|
||||
default y
|
||||
|
||||
endmenu
|
||||
|
||||
+2
-2
@@ -8,13 +8,13 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ocserv
|
||||
PKG_VERSION:=0.8.2
|
||||
PKG_VERSION:=0.8.4
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_BUILD_DIR :=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL :=ftp://ftp.infradead.org/pub/ocserv/
|
||||
PKG_MD5SUM:=fd890e121445dfe8bb514da67c91c675
|
||||
PKG_MD5SUM:=3eb452fddebda887eaa5f6412dab634c
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#
|
||||
# Copyright (C) 2009-2011 OpenWrt.org
|
||||
# Copyright (C) 2009 Jakob Pfeiffer
|
||||
# Copyright (C) 2014 Artem Makhutov
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=opennhrp
|
||||
PKG_VERSION:=0.14.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER:=Artem Makhutov <artem@makhutov.org>
|
||||
PKG_LICENSE:=MIT License
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=@SF/opennhrp
|
||||
PKG_MD5SUM:=eb42ddb13e07ceb415b9ebb8eaca28ee
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/opennhrp
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=VPN
|
||||
DEPENDS:=+libcares +ipsec-tools +ip +kmod-gre
|
||||
KCONFIG:=CONFIG_ARPD=y
|
||||
TITLE:=NBMA Next Hop Resolution Protocol
|
||||
URL:=http://opennhrp.sourceforge.net/
|
||||
endef
|
||||
|
||||
define Package/opennhrp/description
|
||||
OpenNHRP implements NBMA Next Hop Resolution Protocol (as defined in RFC 2332).
|
||||
It makes it possible to create dynamic multipoint VPN Linux router using NHRP,
|
||||
GRE and IPsec. It aims to be Cisco DMVPN compatible.
|
||||
endef
|
||||
|
||||
define Package/opennhrp/conffiles
|
||||
/etc/opennhrp/opennhrp.conf
|
||||
endef
|
||||
|
||||
define Package/opennhrp/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/opennhrp{,ctl} $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc/opennhrp
|
||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/opennhrp/opennhrp.conf $(1)/etc/opennhrp/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/etc/opennhrp/opennhrp-script $(1)/etc/opennhrp/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/etc/opennhrp/racoon-ph1down.sh $(1)/etc/opennhrp/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/etc/opennhrp/racoon-ph1dead.sh $(1)/etc/opennhrp/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/opennhrp.init $(1)/etc/init.d/opennhrp
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,opennhrp))
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2009-2011 OpenWrt.org
|
||||
# Copyright (C) 2009 Jakob Pfeiffer
|
||||
|
||||
START=50
|
||||
|
||||
SERVICE_USE_PID=1
|
||||
|
||||
start() {
|
||||
service_start /usr/sbin/opennhrp -d
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /usr/sbin/opennhrp
|
||||
}
|
||||
@@ -12,12 +12,13 @@ PKG_VERSION:=6.6p1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/ \
|
||||
ftp://openbsd.wiretapped.net/pub/OpenBSD/OpenSSH/portable/ \
|
||||
ftp://ftp.belnet.be/packages/openbsd/OpenSSH/portable/ \
|
||||
ftp://ftp.de.openbsd.org/pub/unix/OpenBSD/OpenSSH/portable/
|
||||
PKG_SOURCE_URL:=http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/ \
|
||||
http://ftp.belnet.be/pub/OpenBSD/OpenSSH/portable/
|
||||
PKG_MD5SUM:=3e9800e6bca1fbac0eea4d41baa7f239
|
||||
|
||||
PKG_LICENSE:=BSD ISC
|
||||
PKG_LICENSE_FILE:=LICENCE
|
||||
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ PKG_VERSION:=20130804
|
||||
PKG_RELEASE:=1
|
||||
PKG_REV:=954f5029dfa17734dc408336ef710c192268e8a4
|
||||
PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
|
||||
PKG_LICENSE:=Beerware
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=git://erdgeist.org/opentracker
|
||||
|
||||
@@ -14,7 +14,10 @@ PKG_RELEASE:=1
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://rsync.samba.org/ftp/rsync/src
|
||||
PKG_MD5SUM:=43bd6676f0b404326eee2d63be3cdcfe
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
PKG_MAINTAINER:=Maxim Storchak <m.storchak@gmail.com>
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
#
|
||||
# Copyright (C) 2014 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:=smartsnmpd
|
||||
PKG_VERSION:=2014-08-13
|
||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/credosemi/smartsnmp.git
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=fb93473d895f058b2d8975d3cfa280ae2a8ae98d
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_MD5SUM:=
|
||||
|
||||
|
||||
PKG_MAINTAINER:=Xiongfei Guo <xfguo@credosemi.com>
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/scons.mk
|
||||
|
||||
define Package/smartsnmpd
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS+=+lua +liblua +libubox +libuci-lua +libubus-lua
|
||||
TITLE:=Smart-SNMP (Agent)
|
||||
URL:=https://github.com/credosemi/smartsnmp
|
||||
endef
|
||||
|
||||
define Package/smartsnmpd/description
|
||||
smartsnmpd is an implementation of SNMP Agent. Its goal is "Easily
|
||||
writing boring SNMP MIB with Lua". This package add native support
|
||||
for OpenWrt. Include using ubus and uci to get system info/status.
|
||||
And, it use libubox/uloop as low level event-driven library.
|
||||
endef
|
||||
|
||||
SCONS_OPTIONS += --transport=uloop
|
||||
|
||||
define Build/Configure
|
||||
(cd $(PKG_BUILD_DIR); \
|
||||
$(SCONS_VARS) \
|
||||
scons \
|
||||
prefix=/usr \
|
||||
$(SCONS_OPTIONS) \
|
||||
)
|
||||
endef
|
||||
|
||||
define Package/smartsnmpd/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/smartsnmpd $(1)/usr/sbin/smartsnmpd
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/smartsnmp
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/build/smartsnmp/core.so $(1)/usr/lib/lua/smartsnmp/core.so
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lualib/smartsnmp/*.lua $(1)/usr/lib/lua/smartsnmp/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/smartsnmp/mibs
|
||||
$(INSTALL_BIN) ./files/mibs/*.lua $(1)/usr/lib/lua/smartsnmp/mibs/
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/smartsnmpd.conf $(1)/etc/config/smartsnmpd
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/smartsnmpd.init $(1)/etc/init.d/smartsnmpd
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,smartsnmpd))
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
--
|
||||
-- This file is part of SmartSNMP
|
||||
-- Copyright (C) 2014, Credo Semiconductor Inc.
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License along
|
||||
-- with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
--
|
||||
|
||||
local mib = require "smartsnmp"
|
||||
|
||||
local dummy = {}
|
||||
|
||||
return dummy
|
||||
@@ -0,0 +1,125 @@
|
||||
--
|
||||
-- This file is part of SmartSNMP
|
||||
-- Copyright (C) 2014, Credo Semiconductor Inc.
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License along
|
||||
-- with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
--
|
||||
|
||||
local mib = require "smartsnmp"
|
||||
require "ubus"
|
||||
require "uloop"
|
||||
|
||||
uloop.init()
|
||||
|
||||
local conn = ubus.connect()
|
||||
if not conn then
|
||||
error("Failed to connect to ubusd")
|
||||
end
|
||||
|
||||
local if_cache = {}
|
||||
local if_status_cache = {}
|
||||
local if_index_cache = {}
|
||||
|
||||
local last_load_time = os.time()
|
||||
local function need_to_reload()
|
||||
if os.time() - last_load_time >= 3 then
|
||||
last_load_time = os.time()
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function load_config()
|
||||
if need_to_reload() == true then
|
||||
if_cache = {}
|
||||
if_status_cache = {}
|
||||
if_index_cache = {}
|
||||
|
||||
-- if description
|
||||
for k, v in pairs(conn:call("network.device", "status", {})) do
|
||||
if_status_cache[k] = {}
|
||||
end
|
||||
|
||||
for name_ in pairs(if_status_cache) do
|
||||
for k, v in pairs(conn:call("network.device", "status", { name = name_ })) do
|
||||
if k == 'mtu' then
|
||||
if_status_cache[name_].mtu = v
|
||||
elseif k == 'macaddr' then
|
||||
if_status_cache[name_].macaddr = v
|
||||
elseif k == 'up' then
|
||||
if v == true then
|
||||
if_status_cache[name_].up = 1
|
||||
else
|
||||
if_status_cache[name_].up = 2
|
||||
end
|
||||
elseif k == 'statistics' then
|
||||
for item, stat in pairs(v) do
|
||||
if item == 'rx_bytes' then
|
||||
if_status_cache[name_].in_octet = stat
|
||||
elseif item == 'tx_bytes' then
|
||||
if_status_cache[name_].out_octet = stat
|
||||
elseif item == 'rx_errors' then
|
||||
if_status_cache[name_].in_errors = stat
|
||||
elseif item == 'tx_errors' then
|
||||
if_status_cache[name_].out_errors = stat
|
||||
elseif item == 'rx_dropped' then
|
||||
if_status_cache[name_].in_discards = stat
|
||||
elseif item == 'tx_dropped' then
|
||||
if_status_cache[name_].out_discards = stat
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if_cache['desc'] = {}
|
||||
for name, status in pairs(if_status_cache) do
|
||||
table.insert(if_cache['desc'], name)
|
||||
for k, v in pairs(status) do
|
||||
if if_cache[k] == nil then if_cache[k] = {} end
|
||||
table.insert(if_cache[k], v)
|
||||
end
|
||||
end
|
||||
|
||||
-- if index
|
||||
for i in ipairs(if_cache['desc']) do
|
||||
table.insert(if_index_cache, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mib.module_methods.or_table_reg("1.3.6.1.2.1.2", "The MIB module for managing Interfaces implementations")
|
||||
|
||||
local ifGroup = {
|
||||
[1] = mib.ConstInt(function () load_config() return #if_index_cache end),
|
||||
[2] = {
|
||||
[1] = {
|
||||
[1] = mib.ConstIndex(function () load_config() return if_index_cache end),
|
||||
[2] = mib.ConstString(function (i) load_config() return if_cache['desc'][i] end),
|
||||
[4] = mib.ConstInt(function (i) load_config() return if_cache['mtu'][i] end),
|
||||
[6] = mib.ConstString(function (i) load_config() return if_cache['macaddr'][i] end),
|
||||
[8] = mib.ConstInt(function (i) load_config() return if_cache['up'][i] end),
|
||||
[10] = mib.ConstCount(function (i) load_config() return if_cache['in_octet'][i] end),
|
||||
[13] = mib.ConstCount(function (i) load_config() return if_cache['in_discards'][i] end),
|
||||
[14] = mib.ConstCount(function (i) load_config() return if_cache['in_errors'][i] end),
|
||||
[16] = mib.ConstCount(function (i) load_config() return if_cache['out_octet'][i] end),
|
||||
[19] = mib.ConstCount(function (i) load_config() return if_cache['out_discards'][i] end),
|
||||
[20] = mib.ConstCount(function (i) load_config() return if_cache['out_errors'][i] end),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ifGroup
|
||||
@@ -0,0 +1,176 @@
|
||||
--
|
||||
-- This file is part of SmartSNMP
|
||||
-- Copyright (C) 2014, Credo Semiconductor Inc.
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License along
|
||||
-- with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
--
|
||||
|
||||
local mib = require "smartsnmp"
|
||||
local uci = require "uci"
|
||||
|
||||
-- System config
|
||||
local context = uci.cursor("/etc/config", "/tmp/.uci")
|
||||
|
||||
-- scalar index
|
||||
local sysDesc = 1
|
||||
local sysObjectID = 2
|
||||
local sysUpTime = 3
|
||||
local sysContact = 4
|
||||
local sysName = 5
|
||||
local sysLocation = 6
|
||||
local sysServices = 7
|
||||
local sysORLastChange = 8
|
||||
|
||||
-- table index
|
||||
local sysORTable = 9
|
||||
|
||||
-- entry index
|
||||
local sysOREntry = 1
|
||||
|
||||
-- list index
|
||||
local sysORIndex = 1
|
||||
local sysORID = 2
|
||||
local sysORDesc = 3
|
||||
local sysORUpTime = 4
|
||||
|
||||
local startup_time = 0
|
||||
local or_last_changed_time = 0
|
||||
|
||||
local function mib_system_startup(time)
|
||||
startup_time = time
|
||||
or_last_changed_time = time
|
||||
end
|
||||
|
||||
mib_system_startup(os.time())
|
||||
|
||||
local sysGroup = {}
|
||||
local or_oid_cache = {}
|
||||
local or_index_cache = {}
|
||||
local or_table_cache = {}
|
||||
|
||||
local or_table_reg = function (oid, desc)
|
||||
local row = {}
|
||||
row['oid'] = {}
|
||||
for i in string.gmatch(oid, "%d") do
|
||||
table.insert(row['oid'], tonumber(i))
|
||||
end
|
||||
row['desc'] = desc
|
||||
row['uptime'] = os.time()
|
||||
table.insert(or_table_cache, row)
|
||||
|
||||
or_last_changed_time = os.time()
|
||||
|
||||
or_oid_cache[oid] = #or_table_cache
|
||||
|
||||
or_index_cache = {}
|
||||
for i in ipairs(or_table_cache) do
|
||||
table.insert(or_index_cache, i)
|
||||
end
|
||||
end
|
||||
|
||||
local or_table_unreg = function (oid)
|
||||
local or_idx = or_oid_cache[oid]
|
||||
|
||||
if or_table_cache[or_idx] ~= nil then
|
||||
table.remove(or_table_cache, or_idx)
|
||||
or_last_changed_time = os.time()
|
||||
|
||||
or_index_cache = {}
|
||||
for i in ipairs(or_table_cache) do
|
||||
table.insert(or_index_cache, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local last_load_time = os.time()
|
||||
local function need_to_reload()
|
||||
if os.difftime(os.time(), last_load_time) < 3 then
|
||||
return false
|
||||
else
|
||||
last_load_time = os.time()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local function load_config()
|
||||
if need_to_reload() == true then
|
||||
context:load("smartsnmpd")
|
||||
end
|
||||
end
|
||||
|
||||
context:load("smartsnmpd")
|
||||
|
||||
local sysMethods = {
|
||||
["or_table_reg"] = or_table_reg,
|
||||
["or_table_unreg"] = or_table_unreg
|
||||
}
|
||||
mib.module_method_register(sysMethods)
|
||||
|
||||
sysGroup = {
|
||||
rocommunity = 'public',
|
||||
[sysDesc] = mib.ConstString(function () load_config() return mib.sh_call("uname -a") end),
|
||||
[sysObjectID] = mib.ConstOid(function ()
|
||||
load_config()
|
||||
local oid
|
||||
local objectid
|
||||
context:foreach("smartsnmpd", "smartsnmpd", function (s)
|
||||
objectid = s.objectid
|
||||
end)
|
||||
if objectid ~= nil then
|
||||
oid = {}
|
||||
for i in string.gmatch(objectid, "%d+") do
|
||||
table.insert(oid, tonumber(i))
|
||||
end
|
||||
end
|
||||
return oid
|
||||
end),
|
||||
[sysUpTime] = mib.ConstTimeticks(function () load_config() return os.difftime(os.time(), startup_time) * 100 end),
|
||||
[sysContact] = mib.ConstString(function ()
|
||||
load_config()
|
||||
local contact
|
||||
context:foreach("smartsnmpd", "smartsnmpd", function (s)
|
||||
contact = s.contact
|
||||
end)
|
||||
return contact
|
||||
end),
|
||||
[sysName] = mib.ConstString(function () load_config() return mib.sh_call("uname -n") end),
|
||||
[sysLocation] = mib.ConstString(function ()
|
||||
load_config()
|
||||
local location
|
||||
context:foreach("smartsnmpd", "smartsnmpd", function (s)
|
||||
location = s.location
|
||||
end)
|
||||
return location
|
||||
end),
|
||||
[sysServices] = mib.ConstInt(function ()
|
||||
load_config()
|
||||
local services
|
||||
context:foreach("smartsnmpd", "smartsnmpd", function (s)
|
||||
services = tonumber(s.services)
|
||||
end)
|
||||
return services
|
||||
end),
|
||||
[sysORLastChange] = mib.ConstTimeticks(function () load_config() return os.difftime(os.time(), or_last_changed_time) * 100 end),
|
||||
[sysORTable] = {
|
||||
[sysOREntry] = {
|
||||
[sysORIndex] = mib.UnaIndex(function () load_config() return or_index_cache end),
|
||||
[sysORID] = mib.ConstOid(function (i) load_config() return or_table_cache[i].oid end),
|
||||
[sysORDesc] = mib.ConstString(function (i) load_config() return or_table_cache[i].desc end),
|
||||
[sysORUpTime] = mib.ConstTimeticks(function (i) load_config() return os.difftime(os.time(), or_table_cache[i].uptime) * 100 end),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sysGroup
|
||||
@@ -0,0 +1,21 @@
|
||||
config smartsnmpd
|
||||
option port '161'
|
||||
option ro_community 'public'
|
||||
option rw_community 'private'
|
||||
option mib_module_path 'mibs'
|
||||
option objectid '1.2.3.4'
|
||||
option contact 'Me <me@example.org>'
|
||||
option location 'Shanghai'
|
||||
option services '72'
|
||||
|
||||
config smartsnmpd_module
|
||||
option oid "1.3.6.1.2.1.1"
|
||||
option module 'system'
|
||||
|
||||
config smartsnmpd_module
|
||||
option oid "1.3.6.1.2.1.2"
|
||||
option module 'interfaces'
|
||||
|
||||
config smartsnmpd_module
|
||||
option oid "1.3.6.1.1"
|
||||
option module 'dummy'
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2014 OpenWrt.org
|
||||
|
||||
START=97
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/smartsnmpd
|
||||
CONFIGFILE=/etc/smartsnmpd.conf
|
||||
|
||||
smartsnmpd_mib_module() {
|
||||
local cfg="$1"
|
||||
config_get OID "$cfg" oid
|
||||
config_get MODULE "$cfg" module
|
||||
echo " ['$OID'] = '$MODULE'," >> $CONFIGFILE
|
||||
}
|
||||
|
||||
start_service() {
|
||||
include /lib/functions
|
||||
|
||||
config_load smartsnmpd
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command $PROG -c $CONFIGFILE
|
||||
procd_set_param file $CONFIGFILE
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
|
||||
# before we can call xappend
|
||||
mkdir -p $(dirname $CONFIGFILE)
|
||||
|
||||
echo "-- auto-generated config file from /etc/config/smartsnmpd" > $CONFIGFILE
|
||||
|
||||
config_get PORT smartsnmpd port 161
|
||||
echo "port = $PORT" >> $CONFIGFILE
|
||||
|
||||
config_get RO_COMMUNITY smartsnmpd ro_community 'public'
|
||||
config_get RW_COMMUNITY smartsnmpd rw_community 'private'
|
||||
echo "ro_community = '$RO_COMMUNITY'" >> $CONFIGFILE
|
||||
echo "rw_community = '$RW_COMMUNITY'" >> $CONFIGFILE
|
||||
|
||||
config_get MIB_MODULE_PATH smartsnmpd mib_module_path '/usr/lib/lua/smartsnmp/mibs/'
|
||||
echo "mib_module_path = '$MIB_MODULE_PATH'" >> $CONFIGFILE
|
||||
|
||||
echo "mib_modules = {" >> $CONFIGFILE
|
||||
config_foreach smartsnmpd_mib_module smartsnmpd_module
|
||||
echo "}" >> $CONFIGFILE
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#
|
||||
# Copyright (C) 2006-2014 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:=socat
|
||||
PKG_VERSION:=1.7.2.4
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=http://www.dest-unreach.org/socat/download
|
||||
PKG_MD5SUM:=69b8155dd442a6f24e28ef5407d868eb
|
||||
|
||||
PKG_MAINTAINER:= Ted Hess <thess@kitschensync.net>
|
||||
|
||||
PKG_LICENSE:=GPL-2.0 OpenSSL
|
||||
PKG_LICENSE_FILE:=COPYING COPYING.OpenSSL
|
||||
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/socat
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+libpthread +SOCAT_SSL:libopenssl
|
||||
TITLE:=A multipurpose relay (SOcket CAT)
|
||||
URL:=http://www.dest-unreach.org/socat/
|
||||
endef
|
||||
|
||||
define Package/socat/description
|
||||
SoCat (for SOcket CAT) establishes two bidirectional byte streams and
|
||||
transfers data between them.
|
||||
Data channels may be files, pipes, devices (terminal or modem, etc.), or
|
||||
sockets (Unix, IPv4, IPv6, raw, UDP, TCP, SSL). It provides forking,
|
||||
logging and tracing, different modes for interprocess communication and
|
||||
many more options.
|
||||
endef
|
||||
|
||||
define Package/socat/config
|
||||
config SOCAT_SSL
|
||||
bool "SSL support"
|
||||
depends on PACKAGE_socat
|
||||
default n
|
||||
help
|
||||
Implements SSL support in socat (using libopenssl).
|
||||
endef
|
||||
|
||||
define Package/socat/conffiles
|
||||
/etc/config/socat
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--disable-libwrap \
|
||||
--disable-readline \
|
||||
--enable-termios
|
||||
|
||||
ifneq ($(CONFIG_SOCAT_SSL),y)
|
||||
CONFIGURE_ARGS+= --disable-openssl
|
||||
endif
|
||||
|
||||
CONFIGURE_VARS += \
|
||||
sc_cv_termios_ispeed="no" \
|
||||
sc_cv_sys_crdly_shift=9 \
|
||||
sc_cv_sys_tabdly_shift=11 \
|
||||
sc_cv_sys_csize_shift=4
|
||||
|
||||
define Package/socat/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/socat $(1)/usr/bin/
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/socat.config $(1)/etc/config/socat
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/socat.init $(1)/etc/init.d/socat
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,socat))
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user