hev-socks5-server: add new package
authorRay Wang <r@hev.cc>
Thu, 25 Apr 2024 13:36:14 +0000 (21:36 +0800)
committerTianling Shen <cnsztl@gmail.com>
Fri, 3 May 2024 18:26:54 +0000 (02:26 +0800)
HevSocks5Server is a high-performance socks5 server for Unix.

More details: https://github.com/heiher/hev-socks5-server

Signed-off-by: Ray Wang <r@hev.cc>
(cherry picked from commit 8d36908aead7a37416ff4ac74d7c6ff59ded505e)

net/hev-socks5-server/Makefile [new file with mode: 0644]
net/hev-socks5-server/files/hev-socks5-server.config [new file with mode: 0644]
net/hev-socks5-server/files/hev-socks5-server.init [new file with mode: 0644]
net/hev-socks5-server/test.sh [new file with mode: 0755]

diff --git a/net/hev-socks5-server/Makefile b/net/hev-socks5-server/Makefile
new file mode 100644 (file)
index 0000000..c307b0e
--- /dev/null
@@ -0,0 +1,49 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=hev-socks5-server
+PKG_VERSION:=2.6.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/heiher/hev-socks5-server/releases/download/$(PKG_VERSION)
+PKG_HASH:=07d3297483cc624464eec424f7dd27f2028f4f56c70c2c9d0b6902e181a32ccb
+
+PKG_MAINTAINER:=Ray Wang <r@hev.cc>
+PKG_LICENSE:=GPL-3.0-only
+PKG_LICENSE_FILES:=License
+
+PKG_BUILD_FLAGS:=no-mips16
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/hev-socks5-server
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=A high-performance socks5 server for Unix
+  URL:=https://github.com/heiher/hev-socks5-server
+endef
+
+MAKE_FLAGS += REV_ID="$(PKG_VERSION)"
+
+define Package/hev-socks5-server/conffiles
+/etc/config/hev-socks5-server
+/etc/hev-socks5-server/
+endef
+
+define Package/hev-socks5-server/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/hev-socks5-server $(1)/usr/bin/
+
+       $(INSTALL_DIR) $(1)/etc/hev-socks5-server/
+       $(INSTALL_CONF) $(PKG_BUILD_DIR)/conf/main.yml $(1)/etc/hev-socks5-server/main.yml
+       $(INSTALL_CONF) $(PKG_BUILD_DIR)/conf/auth.txt $(1)/etc/hev-socks5-server/auth.txt
+
+       $(INSTALL_DIR) $(1)/etc/config/
+       $(INSTALL_CONF) ./files/hev-socks5-server.config $(1)/etc/config/hev-socks5-server
+
+       $(INSTALL_DIR) $(1)/etc/init.d/
+       $(INSTALL_BIN) ./files/hev-socks5-server.init $(1)/etc/init.d/hev-socks5-server
+endef
+
+$(eval $(call BuildPackage,hev-socks5-server))
diff --git a/net/hev-socks5-server/files/hev-socks5-server.config b/net/hev-socks5-server/files/hev-socks5-server.config
new file mode 100644 (file)
index 0000000..0df231a
--- /dev/null
@@ -0,0 +1,3 @@
+config hev-socks5-server 'config'
+       option enabled '0'
+       option conffile '/etc/hev-socks5-server/main.yml'
diff --git a/net/hev-socks5-server/files/hev-socks5-server.init b/net/hev-socks5-server/files/hev-socks5-server.init
new file mode 100644 (file)
index 0000000..671870c
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+START=99
+
+CONF="hev-socks5-server"
+PROG="/usr/bin/hev-socks5-server"
+
+start_service() {
+       config_load "$CONF"
+
+       local enabled
+       config_get_bool enabled "config" "enabled" "0"
+       [ "$enabled" -eq "1" ] || return 1
+
+       local conffile
+       config_get conffile "config" "conffile"
+
+       procd_open_instance "$CONF"
+       procd_set_param command "$PROG" "$conffile"
+       procd_set_param file "$conffile"
+
+       procd_set_param limits core="unlimited"
+       procd_set_param limits nofile="1000000 1000000"
+       procd_set_param stdout 1
+       procd_set_param stderr 1
+       procd_set_param respawn
+
+       procd_close_instance
+}
+
+service_triggers() {
+       procd_add_reload_trigger "$CONF"
+}
diff --git a/net/hev-socks5-server/test.sh b/net/hev-socks5-server/test.sh
new file mode 100755 (executable)
index 0000000..9ae615c
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+"$1" 2>&1 | grep "$2"