update 2026-09-24 16:56:26

This commit is contained in:
action committed 2026-09-24 16:56:26 +08:00
1 parent b31a5c3878
commit e4cee331e9
6885 files changed
+3240523

No files matched your search

+106
View File
@@ -0,0 +1,106 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/target.mk
ifeq ($(ARCH),arm)
ifneq ($(findstring $(CPU_SUBTYPE), neon neon-vfpv4 vfpv3),)
PKG_ARCH_PHT:=arm_$(CPU_TYPE)_$(CPU_SUBTYPE)-$(LIBC)-unknown
else ifneq ($(findstring $(CPU_TYPE), cortex-a9),)
PKG_ARCH_PHT:=arm_cortex-a9-$(LIBC)-unknown
else
PKG_ARCH_PHT:=arm_cortex-a7-$(LIBC)-unknown
endif
endif
ifeq ($(ARCH),aarch64)
ifneq ($(findstring $(CPU_TYPE), cortex-a53 cortex-a72),)
PKG_ARCH_PHT:=aarch64_$(CPU_TYPE)-$(LIBC)-unknown
else
PKG_ARCH_PHT:=aarch64_generic-$(LIBC)-unknown
endif
endif
ifeq ($(ARCH),mips)
PKG_ARCH_PHT:=mips_24kc-$(LIBC)-unknown
endif
ifeq ($(ARCH),mipsel)
ifneq ($(findstring $(CPU_TYPE), 24kec 74kc 1004kc),)
PKG_ARCH_PHT:=$(ARCH)_$(CPU_TYPE)-$(LIBC)-unknown
else
PKG_ARCH_PHT:=mipsel_24kc-$(LIBC)-unknown
endif
endif
ifeq ($(BOARD),x86)
ifeq ($(ARCH),x86_64)
PKG_ARCH_PHT:=x86_64-$(LIBC)-unknown
else ifeq ($(CPU_TYPE),pentium4)
PKG_ARCH_PHT:=i386_pentium4-$(LIBC)-unknown
else
PKG_ARCH_PHT:=i386_pentium-mmx-$(LIBC)-unknown
endif
endif
PKG_NAME:=phtunnel
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_SOURCE:=phtunnel
PKG_SOURCE_URL:=https://mirrors.oray.com/orayos/packages/$(PKG_NAME)/$(PKG_ARCH_PHT)/$(PKG_VERSION)/bin
PKG_HASH:=skip
PKG_FLAGS:=nonshared
PKG_MAINTAINER:=Oray <developer@oray.com>
include $(INCLUDE_DIR)/package.mk
define Package/phtunnel
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
DEPENDS:=@(arm||aarch64||mips||mipsel||i386||x86_64) \
+libc +libpthread +librt
TITLE:=HSK Intranet penetration
URL:=https://hsk.oray.com/
endef
define Package/phtunnel/description
PHTunnel is the core component of HSK intranet penetration, which can easily implement high-performance
reverse proxy applications, supports TCP, HTTP, HTTPS protocols, end-to-end TLS encrypted communication,
black and white list anti-black verification, etc. Through PHTunnel, external network devices can easily
penetrate various complex routes and firewalls to access devices on the internal network.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
mv $(DL_DIR)/$(PKG_SOURCE) $(PKG_BUILD_DIR)
chmod +x $(PKG_BUILD_DIR)/$(PKG_SOURCE)
endef
define Build/Compile
true
endef
define Package/phtunnel/conffiles
/etc/phtunnel.json
endef
define Package/phtunnel/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_BUILD_DIR)/phtunnel $(1)/usr/sbin
$(INSTALL_BIN) ./files/etc/init.d/* $(1)/etc/init.d
$(INSTALL_CONF) ./files/etc/config/* $(1)/etc/config
$(INSTALL_BIN) ./files/etc/hotplug.d/iface/* $(1)/etc/hotplug.d/iface
endef
define Package/phtunnel/preinst
#!/bin/sh
[ -z "$${IPKG_INSTROOT}" ] && {
pidof phtunnel > /dev/null && \
test -f $${PKG_ROOT}etc/init.d/phtunnel && \
/etc/init.d/phtunnel stop; true
}
exit 0
endef
$(eval $(call BuildPackage,phtunnel))
+6
View File
@@ -0,0 +1,6 @@
config base 'base'
option enabled '0'
config log 'log'
option path '/var/log/phtunnel.log'
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
[ "$INTERFACE" == "wan" -a "$ACTION" == "ifup" ] && {
logger -t oray 'wan interface up and phtunnel restart'
/etc/init.d/phtunnel restart
}
+103
View File
@@ -0,0 +1,103 @@
#!/bin/sh /etc/rc.common
. /lib/functions.sh
START=65
STOP=65
USE_PROCD=1
#退出后清理
exit_clean()
{
[ -f "$1" ] && rm $1
[ -f "$2" ] && rm $2
[ -f "$3" ] && rm $3
}
start_service()
{
local enabled
local config_file
local log_path
local app_id
local app_key
local server_addr
local pid_file
local device_info
local cmd
local log_dir_path
config_load phtunnel
config_get enabled base enabled '0'
[ "$enabled" == "0" ] && {
echo 'phtunnel is not enabled'
exit 1
}
config_get config_file base config_file '/etc/phtunnel.json' #配置文件路径
config_get app_id base app_id '' #appid
config_get app_key base app_key '' #appkey
config_get server_addr base server 'https://hsk-embed.oray.com' #服务器地址
config_get pid_file base pid_file '/tmp/phtunnel.pid' #pid文件位置
config_get log_path log path '/var/log/oraybox/phtunnel.log' #日志位置
echo 'now start phtunnel'
log_dir_path="${log_path%/*}"
[ ! -d "$log_dir_path" ] && mkdir -p $log_dir_path
cmd="phtunnel -R 100 -c $config_file -l $log_path --rpc -p $pid_file"
[ -n "$app_id" -a -n "$app_key" ] && cmd="$cmd --appid "$app_id" --appkey $app_key"
[ -n "$server_addr" ] && cmd="$cmd -s $server_addr"
[ -n "$dev_info" ] && cmd="$cmd --deviceinfo 'mem:32; usb:on; cpu:mipsel'"
#echo $cmd
procd_open_instance
procd_set_param command $cmd
procd_set_param respawn
procd_close_instance
}
stop_service()
{
echo 'now stop phtunnel'
local enabled
local config_file
local pid_file
local log_path
config_load phtunnel
config_get enabled base enabled '0'
config_get config_file base config_file '/etc/phtunnel.json' #配置文件路径
config_get pid_file base pid_file '/tmp/phtunnel.pid'
config_get log_path log path '/var/log/oraybox/phtunnel.log'
#获取程序的pid
local pid=$(cat "$pid_file" 2> /dev/null | grep 'pid=' | cut -d'=' -f2 2> /dev/null)
[ -z "$pid" ] && {
echo 'phtunnel pid is not found'
exit_clean $pid_file $log_path
return 0
}
#如果enabled为0(禁用),则删除配置文件
[ "$enabled" = "0" -a -f "$config_file" ] && rm $config_file
#kill程序
kill "$pid" 2> /dev/null
for i in $(seq 1 4)
do
[ -d "/proc/$pid" ] || {
echo 'phtunnel processor is stopped'
exit_clean $pid_file $log_path
return 0
}
echo "phtunnel processor is still alive(pid is $pid), wait 1 second"
sleep 1
done
echo "phtunnel processor is still alive(pid is $pid), kill it"
kill -9 $pid 2> /dev/null
exit_clean $pid_file $log_path
}