Skip to content

Commit

Permalink
luci-app-ssr-plus: use ipt2socks to support trojan UDP relay
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsnowwolf committed Dec 8, 2019
1 parent fee61c8 commit d7e1d8f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
46 changes: 46 additions & 0 deletions package/lean/ipt2socks/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=ipt2socks
PKG_VERSION:=1.0.2
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/zfl9/ipt2socks.git
PKG_SOURCE_VERSION:=e6c9b60444bfe2f30830619aacbc67d26ee1015e
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION)

PKG_BUILD_PARALLEL:=1
PKG_BUILD_DEPENDS:=libuv
PKG_USE_MIPS16:=0

PKG_LICENSE:=GPLv3
PKG_LICENSE_FILES:=LICENSE


include $(INCLUDE_DIR)/package.mk

define Package/ipt2socks
SECTION:=net
CATEGORY:=Network
TITLE:=Utility for converting iptables (REDIRECT/TPROXY) to SOCKS5
URL:=https://github.com/zfl9/ipt2socks.git
endef

define Package/ipt2socks/description
Utility for converting iptables (REDIRECT/TPROXY) to SOCKS5.
endef

define Package/ipt2socks/conffiles
/etc/config/ipt2socks
endef

MAKE_FLAGS += LIBS="-l:libuv_a.a"

define Package/ipt2socks/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ipt2socks $(1)/usr/bin
endef

$(eval $(call BuildPackage,ipt2socks))
3 changes: 2 additions & 1 deletion package/lean/luci-app-ssr-plus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-ssr-plus
PKG_VERSION:=1
PKG_RELEASE:=129
PKG_RELEASE:=130

PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks \
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \
Expand Down Expand Up @@ -49,6 +49,7 @@ define Package/luci-app-ssr-plus
+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-redir \
+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:v2ray \
+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:trojan \
+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:ipt2socks \
+PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun:kcptun-client \
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server:shadowsocksr-libev-server \
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks:shadowsocksr-libev-ssr-local
Expand Down
9 changes: 6 additions & 3 deletions package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ start_redir() {
$sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 &
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) Started!" >> /tmp/ssrplus.log
elif [ "$stype" == "trojan" ] ;then
$sscmd --config /var/etc/trojan-ssr-retcp.json >> /tmp/ssrplus.log 2>&1 &
$sscmd --config /var/etc/trojan-ssr-retcp.json >/dev/null 2>&1 &
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd --version 2>&1 | head -1) Started!" >> /tmp/ssrplus.log
fi

Expand All @@ -358,8 +358,10 @@ start_redir() {
sed -i 's/\\//g' /var/etc/v2-ssr-reudp.json
$ucmd -config /var/etc/v2-ssr-reudp.json >/dev/null 2>&1 &
elif [ "$stype" == "trojan" ] ;then
gen_config_file $UDP_RELAY_SERVER 1
$ucmd --config /var/etc/trojan-ssr-retcp.json >> /tmp/ssrplus.log 2>&1 &
lua /usr/share/shadowsocksr/gentrojanconfig.lua $GLOBAL_SERVER client 10801 > /var/etc/trojan-ssr-reudp.json
sed -i 's/\\//g' /var/etc/trojan-ssr-reudp.json
$ucmd --config /var/etc/trojan-ssr-reudp.json >/dev/null 2>&1 &
ipt2socks -U -4 -b 0.0.0.0 -s 127.0.0.1 -p 10801 -l $(uci_get_by_name $UDP_RELAY_SERVER local_port) >/dev/null 2>&1
fi
fi

Expand Down Expand Up @@ -553,6 +555,7 @@ stop() {
killall -q -9 ssr-redir
killall -q -9 v2ray
killall -q -9 trojan
killall -q -9 ipt2socks
killall -q -9 ssr-server
killall -q -9 kcptun-client
killall -q -9 ssr-local
Expand Down

0 comments on commit d7e1d8f

Please sign in to comment.