From f15e39134e497b46942166a6c917a0eab56ec59a Mon Sep 17 00:00:00 2001 From: Harvey Hu Date: Mon, 1 Dec 2014 10:11:41 -0500 Subject: [PATCH 1/4] Add netifd script to control sstp connections. --- net/sstp-client/Makefile | 8 +- net/sstp-client/files/etc/ppp/chap-secrets | 4 - .../files/lib/netifd/proto/sstp.sh | 130 ++++++++++++++++++ 3 files changed, 135 insertions(+), 7 deletions(-) delete mode 100644 net/sstp-client/files/etc/ppp/chap-secrets create mode 100755 net/sstp-client/files/lib/netifd/proto/sstp.sh diff --git a/net/sstp-client/Makefile b/net/sstp-client/Makefile index feb7df1fe..959e3fec4 100644 --- a/net/sstp-client/Makefile +++ b/net/sstp-client/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sstp-client -PKG_VERSION:=1.0.12 +PKG_VERSION:=1.1.0 PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz @@ -24,7 +24,7 @@ define Package/sstp-client SECTION:=net CATEGORY:=Network SUBMENU:=VPN - DEPENDS=+libevent2 +libopenssl +ppp + DEPENDS=+libevent2 +libopenssl +ppp +resolveip TITLE:=SSTP-Client is a SSTP client for Linux. URL:=http://sstp-client.sourceforge.net/ MAINTAINER:=Federico Di Marco @@ -53,9 +53,11 @@ define Package/sstp-client/install $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/.libs/sstpc $(1)/usr/bin/ $(CP) $(PKG_BUILD_DIR)/src/libsstp-api/.libs/*.so* $(1)/usr/lib/ $(CP) $(PKG_BUILD_DIR)/src/pppd-plugin/.libs/*.so* $(1)/usr/lib/ - + $(INSTALL_DIR) $(1)/etc $(CP) files/etc $(1) + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/lib/netifd/proto/sstp.sh $(1)/lib/netifd/proto endef $(eval $(call BuildPackage,sstp-client)) diff --git a/net/sstp-client/files/etc/ppp/chap-secrets b/net/sstp-client/files/etc/ppp/chap-secrets deleted file mode 100644 index 3b937685f..000000000 --- a/net/sstp-client/files/etc/ppp/chap-secrets +++ /dev/null @@ -1,4 +0,0 @@ -# Secrets for authentication using CHAP -# client (domain\\username) server secret (password) acceptable local IP addresses -# SSTP-TEST\\JonDoe sstp-test 'testme1234!' * - diff --git a/net/sstp-client/files/lib/netifd/proto/sstp.sh b/net/sstp-client/files/lib/netifd/proto/sstp.sh new file mode 100755 index 000000000..1419d081f --- /dev/null +++ b/net/sstp-client/files/lib/netifd/proto/sstp.sh @@ -0,0 +1,130 @@ +#!/bin/sh + +[ -x /usr/bin/sstpc ] || exit 0 + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_sstp_init_config() { + proto_config_add_string "server" + proto_config_add_string "username" + proto_config_add_string "password" + proto_config_add_string "pppd_options" + proto_config_add_string "sstp_options" + proto_config_add_int "log_level" + proto_config_add_int "mtu" + proto_config_add_boolean "ipv6" + proto_config_add_boolean "defaultroute" + proto_config_add_boolean "peerdns" + available=1 + no_device=1 +} + +proto_sstp_setup() { + local config="$1"; shift + local iface="$2" + local ifname="sstp-$config" + + local ip serv_addr server ipv6 defaultroute peerdns + json_get_var server server && { + for ip in $(resolveip -t 5 "$server"); do + ( proto_add_host_dependency "$config" "$ip" ) + serv_addr=1 + done + } + [ -n "$serv_addr" ] || { + echo "Could not resolve server address" + sleep 5 + proto_setup_failed "$config" + exit 1 + } + + json_get_vars username password pppd_options sstp_options log_level ipv6 defaultroute peerdns + if [ "$ipv6" = 1 ]; then + ipv6=1 + else + ipv6="" + fi + if [ "$defaultroute" = 0 ]; then + defaultroute="" + else + defaultroute=1 + fi + + if [ "$peerdns" = 0 ]; then + peerdns="" + else + peerdns=1 + fi + + [ -n "$mtu" ] || json_get_var mtu mtu + [ -n "$log_level" ] || log_level=0 + + local load + for module in slhc ppp_generic ppp_async ppp_mppe ip_gre gre pptp; do + grep -q "^$module " /proc/modules && continue + /sbin/insmod $module 2>&- >&- + load=1 + done + [ "$load" = "1" ] && sleep 1 + + proto_init_update "$ifname" 1 + proto_send_update "$config" + + proto_run_command "$config" sstpc \ + --cert-warn \ + --password $password \ + --user $username \ + --log-level $log_level \ + --save-server-route \ + --ipparam $config \ + $sstp_options \ + $server \ + ifname $ifname \ + require-mschap-v2 \ + ${ipv6:++ipv6} \ + refuse-pap \ + noauth \ + ${defaultroute:+replacedefaultroute defaultroute} \ + ${peerdns:+usepeerdns} \ + ip-up-script /lib/netifd/ppp-up \ + ipv6-up-script /lib/netifd/ppp-up \ + ip-down-script /lib/netifd/ppp-down \ + ipv6-down-script /lib/netifd/ppp-down \ + ${mtu:+mtu $mtu mru $mtu} \ + $pppd_options + + # WORKAROUND: Workaround to properly register the sstp interface (As seeen in: https://forum.archive.openwrt.org/viewtopic.php?id=58007) + # WORKAROUND: Start + sleep 10 + proto_init_update "$ifname" 1 + proto_send_update "$config" + # WORKAROUND: End + + # if use pppoe and sstp at same time , firewall need reload . + # but don't konw why + /etc/init.d/firewall reload 2>&- >&- +} + +proto_sstp_teardown() { + local interface="$1" + + case "$ERROR" in + 11|19) + proto_notify_error "$interface" AUTH_FAILED + proto_block_restart "$interface" + ;; + 2) + proto_notify_error "$interface" INVALID_OPTIONS + proto_block_restart "$interface" + ;; + esac + proto_kill_command "$interface" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol sstp +} From 6d6b7beae7dec2f837c3f6c4a6ecbd8a933a44f5 Mon Sep 17 00:00:00 2001 From: Robert Koszewski Date: Tue, 11 Jun 2019 18:44:12 +0200 Subject: [PATCH 2/4] Add workaround to properly register the sstp interface Signed-off-by: Robert Koszewski --- net/sstp-client/files/lib/netifd/proto/sstp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sstp-client/files/lib/netifd/proto/sstp.sh b/net/sstp-client/files/lib/netifd/proto/sstp.sh index 1419d081f..f8cb704c5 100755 --- a/net/sstp-client/files/lib/netifd/proto/sstp.sh +++ b/net/sstp-client/files/lib/netifd/proto/sstp.sh @@ -96,7 +96,7 @@ proto_sstp_setup() { ipv6-down-script /lib/netifd/ppp-down \ ${mtu:+mtu $mtu mru $mtu} \ $pppd_options - + # WORKAROUND: Workaround to properly register the sstp interface (As seeen in: https://forum.archive.openwrt.org/viewtopic.php?id=58007) # WORKAROUND: Start sleep 10 From 29fc709d14a47311f5fbb644088a3deb22ebdeca Mon Sep 17 00:00:00 2001 From: Robert Koszewski Date: Tue, 25 Jun 2019 21:37:38 +0200 Subject: [PATCH 3/4] Readd deleted chap-secrets file --- net/sstp-client/files/etc/ppp/chap-secrets | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 net/sstp-client/files/etc/ppp/chap-secrets diff --git a/net/sstp-client/files/etc/ppp/chap-secrets b/net/sstp-client/files/etc/ppp/chap-secrets new file mode 100644 index 000000000..3b937685f --- /dev/null +++ b/net/sstp-client/files/etc/ppp/chap-secrets @@ -0,0 +1,4 @@ +# Secrets for authentication using CHAP +# client (domain\\username) server secret (password) acceptable local IP addresses +# SSTP-TEST\\JonDoe sstp-test 'testme1234!' * + From 045149cb217452d04c13bf6d1afdfcc388fc52b6 Mon Sep 17 00:00:00 2001 From: Robert Koszewski Date: Tue, 25 Jun 2019 21:38:15 +0200 Subject: [PATCH 4/4] Fix release and package version Signed-off-by: Robert Koszewski --- net/sstp-client/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sstp-client/Makefile b/net/sstp-client/Makefile index 959e3fec4..d4d5d5fa3 100644 --- a/net/sstp-client/Makefile +++ b/net/sstp-client/Makefile @@ -8,8 +8,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sstp-client -PKG_VERSION:=1.1.0 -PKG_RELEASE:=2 +PKG_VERSION:=1.0.12 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/sstp-client/$(PKG_VERSION)