├── README.md ├── libcron └── Makefile ├── quickjspp ├── Makefile └── patches │ └── 001-quickjs-support-soft-float.diff ├── rapidjson └── Makefile ├── subconverter ├── Makefile └── files │ └── subconverter.init └── toml11 └── Makefile /README.md: -------------------------------------------------------------------------------- 1 | # openwrt-subconverter 2 | 3 | Usage 4 | --- 5 | 6 | 1. Copy these folders to ```/package```. 7 | 8 | 2. Install feeds from openwrt official package repository. 9 | ``` 10 | ./scripts/feeds update -a 11 | ./scripts/feeds install -a 12 | ``` 13 | 3. Use 'make menuconfig' to select subconverter package. 14 | 15 | 4. You may use 'make package/subconverter/compile V=99' to 16 | compile subconverter and its dependencies. 17 | -------------------------------------------------------------------------------- /libcron/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-3.0-only 2 | # 3 | # Copyright (C) 2021 ImmortalWrt.org 4 | 5 | include $(TOPDIR)/rules.mk 6 | 7 | PKG_NAME:=libcron 8 | PKG_BASE_VERSION:=1.3.0 9 | PKG_RELEASE:=1 10 | 11 | PKG_SOURCE_PROTO:=git 12 | PKG_SOURCE_URL:=https://github.com/PerMalmberg/libcron.git 13 | PKG_SOURCE_DATE:=2022-08-27 14 | PKG_SOURCE_VERSION:=0dd9df49d7833a2d2119e4a6ff8282df58b12d5d 15 | PKG_MIRROR_HASH:=1a0f0524437a1a0c0a3a222dbdf073d3d9643049ef0475a308670c2cc55e6e84 16 | PKG_VERSION:=$(PKG_BASE_VERSION)-$(PKG_SOURCE_DATE)-$(call version_abbrev,$(PKG_SOURCE_VERSION)) 17 | 18 | PKG_LICENSE:=MIT 19 | PKG_LICENSE_FILES:=LICENSE 20 | PKG_MAINTAINER:=Tianling Shen 21 | 22 | PKG_BUILD_PARALLEL:=1 23 | CMAKE_INSTALL:=1 24 | 25 | include $(INCLUDE_DIR)/package.mk 26 | include $(INCLUDE_DIR)/cmake.mk 27 | 28 | define Package/libcron 29 | SECTION:=lib 30 | CATEGORY:=Libraries 31 | URL:=https://github.com/PerMalmberg/libcron 32 | TITLE:=A C++ scheduling library using cron formatting 33 | endef 34 | 35 | define Package/libcron/description 36 | Libcron offers an easy to use API to add callbacks with corresponding cron-formatted strings. 37 | endef 38 | 39 | define Build/Install 40 | $(INSTALL_DIR) $(PKG_INSTALL_DIR)/usr/lib/ 41 | $(CP) $(PKG_BUILD_DIR)/libcron/out/Release/liblibcron.a $(PKG_INSTALL_DIR)/usr/lib/ 42 | $(INSTALL_DIR) $(PKG_INSTALL_DIR)/usr/include/libcron/ 43 | $(CP) $(PKG_BUILD_DIR)/libcron/include/* $(PKG_INSTALL_DIR)/usr/include/ 44 | $(CP) $(PKG_BUILD_DIR)/libcron/externals/date/include/* $(PKG_INSTALL_DIR)/usr/include/ 45 | endef 46 | 47 | $(eval $(call BuildPackage,libcron)) 48 | -------------------------------------------------------------------------------- /quickjspp/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-3.0-only 2 | # 3 | # Copyright (C) 2021 ImmortalWrt.org 4 | 5 | include $(TOPDIR)/rules.mk 6 | 7 | PKG_NAME:=quickjspp 8 | PKG_RELEASE:=2 9 | 10 | PKG_SOURCE_PROTO:=git 11 | PKG_SOURCE_URL:=https://github.com/ftk/quickjspp.git 12 | PKG_SOURCE_DATE:=2022-07-22 13 | PKG_SOURCE_VERSION:=9cee4b4d27271d54b95f6f42bfdc534ebeaaeb72 14 | PKG_MIRROR_HASH:=1d23111923565d8f125ca52386299d7e497328765a30d677f9437687470c89a4 15 | 16 | PKG_MAINTAINER:=Tianling Shen 17 | 18 | PKG_BUILD_PARALLEL:=1 19 | CMAKE_INSTALL:=1 20 | 21 | include $(INCLUDE_DIR)/package.mk 22 | include $(INCLUDE_DIR)/cmake.mk 23 | 24 | define Package/quickjspp 25 | SECTION:=lib 26 | CATEGORY:=Libraries 27 | URL:=https://github.com/ftk/quickjspp 28 | TITLE:=QuickJS wrapper for C++ 29 | DEPENDS:=+libatomic +libpthread 30 | PROVIDES:=quickjs 31 | endef 32 | 33 | define Package/quickjspp/description 34 | QuickJSPP is QuickJS wrapper for C++. It allows you to easily embed 35 | Javascript engine into your program. 36 | endef 37 | 38 | TARGET_CFLAGS += -DONLY_FE_TONEAREST 39 | define Build/Install 40 | $(INSTALL_DIR) $(PKG_INSTALL_DIR)/usr/lib/ 41 | $(CP) $(PKG_BUILD_DIR)/quickjs/libquickjs.a $(PKG_INSTALL_DIR)/usr/lib/ 42 | $(INSTALL_DIR) $(PKG_INSTALL_DIR)/usr/include/quickjs/ 43 | $(CP) $(PKG_BUILD_DIR)/quickjspp.hpp $(PKG_INSTALL_DIR)/usr/include/ 44 | $(CP) $(PKG_BUILD_DIR)/quickjs/quickjs*.h $(PKG_INSTALL_DIR)/usr/include/quickjs/ 45 | endef 46 | 47 | $(eval $(call BuildPackage,quickjspp)) 48 | -------------------------------------------------------------------------------- /quickjspp/patches/001-quickjs-support-soft-float.diff: -------------------------------------------------------------------------------- 1 | quickjs/quickjs.c | 36 +++++++++++++++++++++++++++++++++--- 2 | 1 file changed, 33 insertions(+), 3 deletions(-) 3 | 4 | diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c 5 | index 1984561..6ea01a1 100644 6 | --- a/quickjs/quickjs.c 7 | +++ b/quickjs/quickjs.c 8 | @@ -11358,12 +11358,27 @@ static int js_ecvt(double d, int n_digits, int *decpt, int *sign, char *buf, 9 | rounding_mode = FE_TONEAREST; 10 | #ifdef CONFIG_PRINTF_RNDN 11 | { 12 | - char buf1[JS_DTOA_BUF_SIZE], buf2[JS_DTOA_BUF_SIZE]; 13 | - int decpt1, sign1, decpt2, sign2; 14 | /* The JS rounding is specified as round to nearest ties away 15 | from zero (RNDNA), but in printf the "ties" case is not 16 | specified (for example it is RNDN for glibc, RNDNA for 17 | Windows), so we must round manually. */ 18 | + #ifdef ONLY_FE_TONEAREST 19 | + char buf1[JS_DTOA_BUF_SIZE]; 20 | + int decpt1, sign1; 21 | + double d1; 22 | + js_ecvt1(d, n_digits, decpt, sign, buf, FE_TONEAREST, buf_tmp, sizeof(buf_tmp)); 23 | + js_ecvt1(d, n_digits + 1, &decpt1, &sign1, buf1, FE_TONEAREST, buf_tmp, sizeof(buf_tmp)); 24 | + if (buf1[n_digits] == '5' && buf1[n_digits - 1] == buf[n_digits - 1]) { 25 | + if (strtod(buf_tmp, NULL) == d) { // atof(buf_tmp) 26 | + buf_tmp[n_digits + 2]++; // = '6'; 27 | + d1 = strtod(buf_tmp, NULL); // atof(buf_tmp); 28 | + js_ecvt1(d, n_digits, decpt, sign, buf, FE_TONEAREST, buf_tmp, sizeof(buf_tmp)); 29 | + } 30 | + } 31 | + return n_digits; 32 | + #else 33 | + char buf1[JS_DTOA_BUF_SIZE], buf2[JS_DTOA_BUF_SIZE]; 34 | + int decpt1, sign1, decpt2, sign2; 35 | js_ecvt1(d, n_digits + 1, &decpt1, &sign1, buf1, FE_TONEAREST, 36 | buf_tmp, sizeof(buf_tmp)); 37 | /* XXX: could use 2 digits to reduce the average running time */ 38 | @@ -11380,6 +11395,7 @@ static int js_ecvt(double d, int n_digits, int *decpt, int *sign, char *buf, 39 | rounding_mode = FE_UPWARD; 40 | } 41 | } 42 | + #endif /* ONLY_FE_TONEAREST */ 43 | } 44 | #endif /* CONFIG_PRINTF_RNDN */ 45 | } 46 | @@ -11409,12 +11425,25 @@ static void js_fcvt(char *buf, int buf_size, double d, int n_digits) 47 | { 48 | int n1, n2; 49 | char buf1[JS_DTOA_BUF_SIZE]; 50 | - char buf2[JS_DTOA_BUF_SIZE]; 51 | 52 | /* The JS rounding is specified as round to nearest ties away from 53 | zero (RNDNA), but in printf the "ties" case is not specified 54 | (for example it is RNDN for glibc, RNDNA for Windows), so we 55 | must round manually. */ 56 | + #ifdef ONLY_FE_TONEAREST 57 | + double d1; 58 | + n1 = js_fcvt1(buf1, sizeof(buf1), d, n_digits + 1, FE_TONEAREST); 59 | + n2 = js_fcvt1(buf, buf_size, d, n_digits, FE_TONEAREST); 60 | + if (buf1[n1 - 1] == '5' && buf1[n1 - 2] == buf[n2 - 1]) { 61 | + if (strtod(buf1, NULL) == d) { // atof(buf1) 62 | + buf1[n1 - 1]++; 63 | + d1 = strtod(buf1, NULL); // atof(buf1); 64 | + js_fcvt1(buf, buf_size, d1, n_digits, FE_TONEAREST); 65 | + } 66 | + } 67 | + return; 68 | + #else 69 | + char buf2[JS_DTOA_BUF_SIZE]; 70 | n1 = js_fcvt1(buf1, sizeof(buf1), d, n_digits + 1, FE_TONEAREST); 71 | rounding_mode = FE_TONEAREST; 72 | /* XXX: could use 2 digits to reduce the average running time */ 73 | @@ -11429,6 +11458,7 @@ static void js_fcvt(char *buf, int buf_size, double d, int n_digits) 74 | rounding_mode = FE_UPWARD; 75 | } 76 | } 77 | + #endif /* ONLY_FE_TONEAREST */ 78 | } 79 | #endif /* CONFIG_PRINTF_RNDN */ 80 | js_fcvt1(buf, buf_size, d, n_digits, rounding_mode); -------------------------------------------------------------------------------- /rapidjson/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-3.0-only 2 | # 3 | # Copyright (C) 2021 ImmortalWrt.org 4 | 5 | include $(TOPDIR)/rules.mk 6 | 7 | PKG_NAME:=rapidjson 8 | PKG_RELEASE:=1 9 | 10 | PKG_SOURCE_PROTO:=git 11 | PKG_SOURCE_URL:=https://github.com/Tencent/rapidjson.git 12 | PKG_SOURCE_DATE:=2023-01-12 13 | PKG_SOURCE_VERSION:=012be8528783cdbf4b7a9e64f78bd8f056b97e24 14 | PKG_MIRROR_HASH:=c0ac2890f68335c3001154082687c5dc9bcf91767ff9b4cdb590107a6f0a2a26 15 | 16 | PKG_LICENSE:=BSD 3-Clause 17 | PKG_LICENSE_FILES:=LICENSE 18 | PKG_MAINTAINER:=Tianling Shen 19 | 20 | PKG_BUILD_PARALLEL:=1 21 | CMAKE_INSTALL:=1 22 | 23 | include $(INCLUDE_DIR)/package.mk 24 | include $(INCLUDE_DIR)/cmake.mk 25 | 26 | CMAKE_OPTIONS+= -DRAPIDJSON_BUILD_DOC=OFF \ 27 | -DRAPIDJSON_BUILD_EXAMPLES=OFF \ 28 | -DRAPIDJSON_BUILD_TESTS=OFF 29 | 30 | define Package/rapidjson 31 | SECTION:=lib 32 | CATEGORY:=Libraries 33 | URL:=https://github.com/Tencent/rapidjson 34 | TITLE:=rapidjson JSON parser/generator for C++ 35 | endef 36 | 37 | define Package/rapidjson/description 38 | A fast JSON parser/generator for C++ with both SAX/DOM style API 39 | endef 40 | 41 | $(eval $(call BuildPackage,rapidjson)) 42 | -------------------------------------------------------------------------------- /subconverter/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-3.0-only 2 | # 3 | # Copyright (C) 2021 ImmortalWrt.org 4 | 5 | include $(TOPDIR)/rules.mk 6 | 7 | PKG_NAME:=subconverter 8 | PKG_BASE_VERSION:=0.7.2 9 | PKG_RELEASE:=1 10 | 11 | PKG_SOURCE_PROTO:=git 12 | PKG_SOURCE_URL:=https://github.com/tindy2013/subconverter.git 13 | PKG_SOURCE_DATE:=2023-01-13 14 | PKG_SOURCE_VERSION:=3813c3925357abca7f5009d69f07281e738d837f 15 | PKG_MIRROR_HASH:=c305e704e9af3a50f073a20d9e44091a47c7d3e2bc1ad586964e2dfdaa8e8c38 16 | 17 | PKG_VERSION:=$(PKG_BASE_VERSION)-$(PKG_SOURCE_DATE)-$(call version_abbrev,$(PKG_SOURCE_VERSION)) 18 | 19 | PKG_LICENSE:=GPL-3.0 20 | PKG_LICENSE_FILES:=LICENSE 21 | PKG_MAINTAINER:=Tianling Shen 22 | 23 | PKG_BUILD_DEPENDS:=rapidjson toml11 quickjspp libcron 24 | PKG_BUILD_PARALLEL:=1 25 | 26 | include $(INCLUDE_DIR)/package.mk 27 | include $(INCLUDE_DIR)/cmake.mk 28 | 29 | define Package/subconverter 30 | SECTION:=utils 31 | CATEGORY:=Utilities 32 | TITLE:=Proxy subscription formats converter 33 | URL:=https://github.com/tindy2013/subconverter 34 | DEPENDS:=+libpthread +libstdcpp +libevent2 +libyaml-cpp +libpcre2 +libcurl 35 | endef 36 | 37 | define Package/subconverter/description 38 | subconverter is a utility to convert between various proxy subscription formats. 39 | endef 40 | 41 | TARGET_CXXFLAGS := $(FPIC) $(filter-out -O%,$(TARGET_CXXFLAGS)) -O3 42 | TARGET_CXXFLAGS += -Wall -Wextra -ffunction-sections -fdata-sections -flto 43 | TARGET_LDFLAGS += -Wl,--gc-sections -flto 44 | 45 | CMAKE_OPTIONS += -DCMAKE_BUILD_TYPE=Release 46 | 47 | define Package/subconverter/install 48 | $(INSTALL_DIR) $(1)/usr/bin 49 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/subconverter $(1)/usr/bin/subconverter 50 | $(INSTALL_DIR) $(1)/etc/subconverter 51 | $(CP) $(PKG_BUILD_DIR)/base/* $(1)/etc/subconverter/ 52 | $(CP) $(PKG_BUILD_DIR)/base/pref.example.ini $(1)/etc/subconverter/pref.ini 53 | $(INSTALL_DIR) $(1)/etc/init.d 54 | $(INSTALL_BIN) ./files/subconverter.init $(1)/etc/init.d/subconverter 55 | endef 56 | 57 | $(eval $(call BuildPackage,subconverter)) 58 | -------------------------------------------------------------------------------- /subconverter/files/subconverter.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=99 4 | USE_PROCD=1 5 | 6 | BIN="/usr/bin/subconverter" 7 | CONF="/etc/subconverter/pref.ini" 8 | LOG_FILE="/var/log/subconverter.log" 9 | 10 | start_service() { 11 | procd_open_instance 12 | procd_set_param command "$BIN" 13 | procd_append_param command -f "$CONF" 14 | procd_append_param command -l "$LOG_FILE" 15 | procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5} 16 | procd_set_param limits core="unlimited" 17 | procd_set_param stdout 1 18 | procd_set_param stderr 1 19 | procd_close_instance 20 | logger -t Subconverter 'Starting Subconverter service' 21 | } 22 | 23 | stop_service() { 24 | rm -f "$LOG_FILE" 25 | logger -t Subconverter 'Shutting down Subconverter service' 26 | } 27 | 28 | reload_service() { 29 | logger -t Subconverter 'Restarting Subconverter service' 30 | stop 31 | sleep 2s 32 | start 33 | } 34 | -------------------------------------------------------------------------------- /toml11/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-3.0-only 2 | # 3 | # Copyright (C) 2021 ImmortalWrt.org 4 | 5 | include $(TOPDIR)/rules.mk 6 | 7 | PKG_NAME:=toml11 8 | PKG_VERSION:=3.7.1 9 | PKG_RELEASE:=1 10 | 11 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 12 | PKG_SOURCE_URL:=https://codeload.github.com/ToruNiina/toml11/tar.gz/v$(PKG_VERSION)? 13 | PKG_HASH:=afeaa9aa0416d4b6b2cd3897ca55d9317084103077b32a852247d8efd4cf6068 14 | 15 | PKG_LICENSE:=MIT 16 | PKG_LICENSE_FILES:=LICENSE 17 | 18 | PKG_BUILD_PARALLEL:=1 19 | CMAKE_INSTALL:=1 20 | 21 | include $(INCLUDE_DIR)/package.mk 22 | include $(INCLUDE_DIR)/cmake.mk 23 | 24 | define Package/toml11 25 | SECTION:=lib 26 | CATEGORY:=Libraries 27 | TITLE:=C++11 header-only toml parser/encoder 28 | URL:=https://github.com/ToruNiina/toml11 29 | endef 30 | 31 | define Package/toml11/description 32 | toml11 is a C++11 (or later) header-only toml parser/encoder 33 | depending only on C++ standard library. 34 | endef 35 | 36 | $(eval $(call BuildPackage,toml11)) 37 | --------------------------------------------------------------------------------