trojan: reduce size

This commit is contained in:
LEAN-ESX 2019-12-14 06:44:27 -08:00
parent 87ddda1137
commit 6c4ccc65fc
3 changed files with 5 additions and 51 deletions

View File

@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=trojan
PKG_VERSION:=1.13.0
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/trojan-gfw/trojan.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=842ad5bb07eb8bce035fb274571e586629a97c99
PKG_SOURCE_VERSION:=98533aa1003979862763f4225266de78581e40bc
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
CMAKE_INSTALL:=1
@ -45,8 +45,8 @@ CMAKE_OPTIONS += \
-DENABLE_NAT=ON \
-DFORCE_TCP_FASTOPEN=OFF \
-DSYSTEMD_SERVICE=OFF \
-DOPENSSL_USE_STATIC_LIBS=TRUE \
-DBoost_DEBUG=ON \
-DOPENSSL_USE_STATIC_LIBS=FALSE \
-DBoost_DEBUG=OFF \
-DBoost_NO_BOOST_CMAKE=ON
define Package/trojan
@ -54,18 +54,13 @@ define Package/trojan
CATEGORY:=Network
TITLE:=An unidentifiable mechanism that helps you bypass GFW
URL:=https://github.com/trojan-gfw/trojan
DEPENDS:=+libpthread +libstdcpp \
DEPENDS:=+libpthread +libstdcpp +libopenssl \
+boost +boost-system +boost-program_options +boost-date_time
endef
define Package/trojan/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/trojan $(1)/usr/sbin/trojan
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/trojan.config $(1)/etc/config/trojan
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/trojan.init $(1)/etc/init.d/trojan
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/trojan/config.json $(1)/etc/trojan.json
endef
$(eval $(call BuildPackage,trojan))

View File

@ -1,4 +0,0 @@
config trojan
option enabled '0'

View File

@ -1,37 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2018 wongsyrone
. /lib/functions.sh
START=95
USE_PROCD=1
#PROCD_DEBUG=1
PROG=/usr/sbin/trojan
CONF=/etc/trojan.json
config_load "trojan"
parse_trojan() {
config_get ENABLED "$section" "enabled"
}
config_foreach parse_trojan 'trojan'
start_service() {
if [ "1" = "$ENABLED" ] || [ "on" = "$ENABLED" ] || [ "true" = "$ENABLED" ]; then
procd_open_instance
procd_set_param command $PROG --config $CONF
procd_set_param user root # run service as user root
procd_set_param stdout 1 # forward stdout of the command to logd
procd_set_param stderr 1 # same for stderr
procd_set_param limits nofile="1048576 1048576" # max allowed value can be fetched via /proc/sys/fs/nr_open
[ -e /proc/sys/kernel/core_pattern ] && {
procd_append_param limits core="unlimited"
}
procd_close_instance
else
echo "trojan is disabled"
fi
}