mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-09-10 18:34:09 +08:00
update 2026-05-27 19:55:46
This commit is contained in:
-116
@@ -1,116 +0,0 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/target.mk
|
||||
|
||||
ifeq ($(ARCH),arm)
|
||||
ifneq ($(findstring $(CPU_SUBTYPE), neon neon-vfpv4 vfpv3),)
|
||||
PKG_ARCH_PGYYPN:=arm_$(CPU_TYPE)_$(CPU_SUBTYPE)-$(LIBC)-unknown
|
||||
else ifneq ($(findstring $(CPU_TYPE), cortex-a9),)
|
||||
PKG_ARCH_PGYYPN:=arm_cortex-a9-$(LIBC)-unknown
|
||||
else
|
||||
PKG_ARCH_PGYYPN:=arm_cortex-a7-$(LIBC)-unknown
|
||||
endif
|
||||
endif
|
||||
ifeq ($(ARCH),aarch64)
|
||||
ifneq ($(findstring $(CPU_TYPE), cortex-a53 cortex-a72),)
|
||||
PKG_ARCH_PGYYPN:=aarch64_$(CPU_TYPE)-$(LIBC)-unknown
|
||||
else
|
||||
PKG_ARCH_PGYYPN:=aarch64_generic-$(LIBC)-unknown
|
||||
endif
|
||||
endif
|
||||
ifeq ($(ARCH),mips)
|
||||
PKG_ARCH_PGYYPN:=mips_24kc-$(LIBC)-unknown
|
||||
endif
|
||||
ifeq ($(ARCH),mipsel)
|
||||
ifneq ($(findstring $(CPU_TYPE), 24kec 74kc 1004kc),)
|
||||
PKG_ARCH_PGYYPN:=$(ARCH)_$(CPU_TYPE)-$(LIBC)-unknown
|
||||
else
|
||||
PKG_ARCH_PGYYPN:=mipsel_24kc-$(LIBC)-unknown
|
||||
endif
|
||||
endif
|
||||
ifeq ($(BOARD),x86)
|
||||
ifeq ($(ARCH),x86_64)
|
||||
PKG_ARCH_PGYYPN:=x86_64-$(LIBC)-unknown
|
||||
else
|
||||
PKG_ARCH_PGYYPN:=i386_pentium-mmx-$(LIBC)-unknown
|
||||
endif
|
||||
endif
|
||||
|
||||
PKG_NAME:=pgyvpn
|
||||
PKG_VERSION:=3.1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=pgyvpnsvr
|
||||
PKG_SOURCE_URL:=https://mirrors.oray.com/orayos/packages/$(PKG_NAME)/$(PKG_ARCH_PGYYPN)/$(PKG_VERSION)/bin
|
||||
PKG_HASH:=skip
|
||||
|
||||
PKG_FLAGS:=nonshared
|
||||
PKG_MAINTAINER:=Oray <developer@oray.com>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/pgyvpn
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=VPN
|
||||
DEPENDS:=@(arm||aarch64||mips||mipsel||i386||x86_64) \
|
||||
+iptables +libc +libopenssl +librt \
|
||||
+libpthread +libstdcpp +kmod-tun
|
||||
TITLE:=PuGongYing VPN, Fast networking
|
||||
URL:=https://pgy.oray.com/
|
||||
endef
|
||||
|
||||
define Package/pgyvpn/description
|
||||
PuGongYing VPN is a product of Oray Company, support custom network, account security
|
||||
system, traffic monitoring, cloud application access, virtual serial port, etc.
|
||||
endef
|
||||
|
||||
define Download/extra
|
||||
FILE:=pgyvpn_oraysl
|
||||
URL:=$(PKG_SOURCE_URL)
|
||||
HASH:=skip
|
||||
endef
|
||||
$(eval $(call Download,extra))
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
mv $(DL_DIR)/{pgyvpn_oraysl,pgyvpnsvr} $(PKG_BUILD_DIR)
|
||||
chmod +x $(PKG_BUILD_DIR)/{pgyvpn_oraysl,pgyvpnsvr}
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
true
|
||||
endef
|
||||
|
||||
define Package/pgyvpn/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/usr/share/pgyvpn
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/{pgyvpn_oraysl,pgyvpnsvr} $(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
|
||||
$(INSTALL_BIN) ./files/usr/share/pgyvpn/* $(1)/usr/share/pgyvpn
|
||||
endef
|
||||
|
||||
define Package/pgyvpn/preinst
|
||||
#!/bin/sh
|
||||
[ -z "$${IPKG_INSTROOT}" ] && {
|
||||
pidof pgyvpnsvr > /dev/null && \
|
||||
test -f $${PKG_ROOT}etc/init.d/pgyvpn && \
|
||||
/etc/init.d/pgyvpn stop; true
|
||||
}
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/pgyvpn/postinst
|
||||
#!/bin/sh
|
||||
[ -z "$${IPKG_INSTROOT}" ] && {
|
||||
/etc/init.d/pgyvpn restart; true
|
||||
}
|
||||
exit 0
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,pgyvpn))
|
||||
@@ -1,20 +0,0 @@
|
||||
config base 'base'
|
||||
option filename '/usr/sbin/pgyvpnsvr'
|
||||
option check_route_conflict '1'
|
||||
option script_p2pinit '/usr/share/pgyvpn/p2pinit.sh'
|
||||
option script_vncinit '/usr/share/pgyvpn/vncinit.sh'
|
||||
option script_progress '/usr/share/pgyvpn/vpnprogress.sh'
|
||||
|
||||
config secure 'secure'
|
||||
option encrypt '0'
|
||||
|
||||
config log 'log'
|
||||
option path '/tmp/oray/pgyvpnsvr/log'
|
||||
option mask '7'
|
||||
|
||||
config oraysl 'oraysl'
|
||||
option filename '/usr/sbin/pgyvpn_oraysl'
|
||||
option logpath '/tmp/oray/pgyvpn_oraysl/log'
|
||||
option statusfilename '/tmp/oray/pgyvpn_oraysl/status'
|
||||
option pidfilename '/tmp/oray/pgyvpn_oraysl/pid'
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ "$INTERFACE" == "wan" -a "$ACTION" == "ifup" ] && {
|
||||
/etc/init.d/pgyvpn restart
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
START=62
|
||||
STOP=62
|
||||
USE_PROCD=1
|
||||
|
||||
write_log()
|
||||
{
|
||||
echo $*
|
||||
logger -t pgyvpn "$*"
|
||||
}
|
||||
|
||||
start_service()
|
||||
{
|
||||
local res_def_path='/usr/share/pgyvpn'
|
||||
local pgyvpn_filename
|
||||
local username
|
||||
local password
|
||||
local check_route_conflict
|
||||
local log_path
|
||||
local log_mask
|
||||
local local_ip
|
||||
local local_mask
|
||||
local use_encrypt
|
||||
local script_p2pinit
|
||||
local script_vncinit
|
||||
local script_progress
|
||||
local oraysl_filename
|
||||
local oraysl_logpath
|
||||
local oraysl_statusfilename
|
||||
local oraysl_pidfilename
|
||||
local login_status
|
||||
local enable_status
|
||||
|
||||
#read uci config
|
||||
config_load pgyvpn
|
||||
config_get login_status base login_status
|
||||
config_get enable_status base enable_status
|
||||
|
||||
if [ -z $enable_status ] || [ "$enable_status" == "0" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
config_get pgyvpn_filename base filename '/usr/sbin/pgyvpnsvr'
|
||||
config_get username base user ''
|
||||
config_get password base pwd ''
|
||||
config_get_bool check_route_conflict base check_route_conflict 0
|
||||
config_get log_path log path '/tmp/oray/pgyvpnsvr/log'
|
||||
config_get log_mask log mask '0x77'
|
||||
config_get_bool use_encrypt secure encrypt 0
|
||||
config_get script_p2pinit base script_p2pinit "$res_def_path/p2pinit.sh"
|
||||
config_get script_vncinit base script_vncinit "$res_def_path/vncinit.sh"
|
||||
config_get script_progress base script_progress "$res_def_path/vpnprogress.sh"
|
||||
config_get oraysl_filename oraysl filename '/usr/sbin/pgyvpn_oraysl'
|
||||
config_get oraysl_logpath oraysl logpath '/tmp/oray/pgyvpn_oraysl/log'
|
||||
config_get oraysl_statusfilename oraysl statusfilename '/tmp/oray/pgyvpn_oraysl/status'
|
||||
config_get oraysl_pidfilename oraysl pidfilename '/tmp/oray/pgyvpn_oraysl/pid'
|
||||
local_ip=$(uci get network.lan.ipaddr 2> /dev/null)
|
||||
local_mask=$(uci get network.lan.netmask 2> /dev/null)
|
||||
|
||||
local host_name=$(uci get system.@system[0].hostname 2> /dev/null)
|
||||
|
||||
#print config
|
||||
write_log "pgyvpn app filename is $pgyvpn_filename"
|
||||
write_log "username is $username"
|
||||
write_log "log path is $log_path"
|
||||
write_log "log mask is $log_mask"
|
||||
write_log "local ip is $local_ip"
|
||||
write_log "local mask is $local_mask"
|
||||
write_log "script for p2p init is $script_p2pinit"
|
||||
write_log "script for vnc init is $script_vncinit"
|
||||
write_log "script for progress is $script_progress"
|
||||
write_log "oraysl filename is $oraysl_filename"
|
||||
write_log "oraysl log path is $oraysl_logpath"
|
||||
write_log "oraysl status filename is $oraysl_statusfilename"
|
||||
write_log "oraysl pid filename is $oraysl_pidfilename"
|
||||
[ $use_encrypt -eq 1 ] && write_log 'use encrypt' || write_log 'no use encrypt'
|
||||
|
||||
#make app command args
|
||||
local cmd_arg=''
|
||||
local api_address="pgyapi.oray.net"
|
||||
cmd_arg="$cmd_arg --apiaddress $api_address --usehttps --rpc --autologinAsRpc"
|
||||
#cmd_arg="$cmd_arg --apiaddress $api_address --usehttps --autologinAsRpc"
|
||||
cmd_arg="$cmd_arg --logsize 4194304 --logpath $log_path --logmask $log_mask"
|
||||
cmd_arg="$cmd_arg --orayslpath $oraysl_filename --oraysllogpath $oraysl_logpath --orayslstatusfilename $oraysl_statusfilename --orayslpidfilename $oraysl_pidfilename"
|
||||
[ -n "$script_p2pinit" ] && cmd_arg="$cmd_arg -n $script_p2pinit"
|
||||
[ -n "$script_vncinit" ] && cmd_arg="$cmd_arg -C $script_vncinit"
|
||||
# [ -n "$script_progress" ] && cmd_arg="$cmd_arg -n $script_progress"
|
||||
[ -n "$script_progress" ] && cmd_arg="$cmd_arg -N $script_progress"
|
||||
[ -n "$local_ip" ] && cmd_arg="$cmd_arg --localip $local_ip"
|
||||
[ -n "$local_mask" ] && cmd_arg="$cmd_arg --localmask $local_mask"
|
||||
[ $use_encrypt -eq 1 ] && cmd_arg="$cmd_arg -r"
|
||||
[ $check_route_conflict -ne 0 ] && cmd_arg="$cmd_arg --vipmask 255.255.255.255"
|
||||
[ -n "$host_name" ] && cmd_arg="$cmd_arg --hostname $host_name"
|
||||
|
||||
#start app
|
||||
procd_open_instance
|
||||
procd_set_param command $pgyvpn_filename $cmd_arg
|
||||
[ -n "$username" ] && procd_append_param command --sn "$username"
|
||||
[ -n "$password" ] && procd_append_param command --pwd "$password"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
|
||||
}
|
||||
|
||||
stop_service()
|
||||
{
|
||||
#remove p2p firewall
|
||||
iptables -w -t filter -F oray_vpn_p2p 2> /dev/null
|
||||
while true;
|
||||
do
|
||||
iptables -w -t filter -D INPUT -j oray_vpn_p2p 2>/dev/null
|
||||
[ $? -ne 0 ] && break
|
||||
done
|
||||
iptables -w -t filter -X oray_vpn_p2p 2> /dev/null
|
||||
|
||||
#remove forward firewall
|
||||
iptables -w -t filter -F oray_vpn_vnc 2> /dev/null
|
||||
while true;
|
||||
do
|
||||
iptables -w -t filter -D INPUT -j oray_vpn_vnc 2>/dev/null
|
||||
[ $? -ne 0 ] && break
|
||||
done
|
||||
|
||||
while true;
|
||||
do
|
||||
iptables -w -t filter -D FORWARD -j oray_vpn_vnc 2>/dev/null
|
||||
[ $? -ne 0 ] && break
|
||||
done
|
||||
|
||||
while true;
|
||||
do
|
||||
iptables -w -t filter -D OUTPUT -j oray_vpn_vnc 2>/dev/null
|
||||
[ $? -ne 0 ] && break
|
||||
done
|
||||
iptables -w -t filter -X oray_vpn_vnc 2> /dev/null
|
||||
|
||||
#stop oraysl
|
||||
killall pgyvpn_oraysl 2> /dev/null
|
||||
|
||||
rm /tmp/pgyvpnsvr_mutex 2> /dev/null #delete mutex file
|
||||
rm /tmp/pgyvpnsvr_rpc_mutex 2> /dev/null #delete rpc mutex file
|
||||
|
||||
local oraysl_statusfilename
|
||||
config_load pgyvpn
|
||||
config_get oraysl_statusfilename oraysl statusfilename '/tmp/oray/pgyvpn_oraysl/status'
|
||||
rm oraysl_statusfilename 2> /dev/null #delete oraysl status file
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#删除oray_vpn_p2p表
|
||||
iptables -w -t filter -F oray_vpn_p2p
|
||||
while true;
|
||||
do
|
||||
iptables -w -t filter -D INPUT -j oray_vpn_p2p 2>/dev/null
|
||||
[ $? -ne 0 ] && break
|
||||
done
|
||||
iptables -w -t filter -X oray_vpn_p2p
|
||||
|
||||
#建立oray_vpn_p2p表
|
||||
iptables -w -t filter -N oray_vpn_p2p
|
||||
iptables -w -t filter -I oray_vpn_p2p -p udp --dport $2 -j ACCEPT
|
||||
iptables -w -t filter -I oray_vpn_p2p -p udp --dport 1900 -j ACCEPT
|
||||
iptables -w -t filter -I INPUT 1 -j oray_vpn_p2p
|
||||
@@ -1,31 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#删除oray_vpn_vnc表
|
||||
iptables -w -t filter -F oray_vpn_vnc
|
||||
while true;
|
||||
do
|
||||
iptables -w -t filter -D INPUT -j oray_vpn_vnc 2>/dev/null
|
||||
[ $? -ne 0 ] && break
|
||||
done
|
||||
|
||||
while true;
|
||||
do
|
||||
iptables -w -t filter -D FORWARD -j oray_vpn_vnc 2>/dev/null
|
||||
[ $? -ne 0 ] && break
|
||||
done
|
||||
|
||||
while true;
|
||||
do
|
||||
iptables -w -t filter -D OUTPUT -j oray_vpn_vnc 2>/dev/null
|
||||
[ $? -ne 0 ] && break
|
||||
done
|
||||
iptables -w -t filter -X oray_vpn_vnc
|
||||
|
||||
#建立oray_vpn_vnc表
|
||||
iptables -w -t filter -N oray_vpn_vnc
|
||||
iptables -w -t filter -I oray_vpn_vnc -i oray_vnc -o br-lan -j ACCEPT
|
||||
iptables -w -t filter -I oray_vpn_vnc -o oray_vnc -i br-lan -j ACCEPT
|
||||
iptables -w -t filter -I INPUT 1 -j oray_vpn_vnc
|
||||
iptables -w -t filter -I OUTPUT 1 -j oray_vpn_vnc
|
||||
iptables -w -t filter -I FORWARD 1 -j oray_vpn_vnc
|
||||
iptables -w -t filter -I oray_vpn_vnc -i oray_vnc -j ACCEPT
|
||||
@@ -1,116 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
progress="$1"
|
||||
|
||||
#connect status
|
||||
echo $progress >/tmp/orayboxvpn_connect_status
|
||||
|
||||
logger -t vpnprogress $progress
|
||||
|
||||
#99: 表示 链接中
|
||||
# 1: 表示 已组网
|
||||
# 0: 表示 未组网
|
||||
|
||||
# 显示登录页面
|
||||
#4 -1: 表示 账号错误
|
||||
#-2: 表示 帐号密码为空
|
||||
#6 -3: 表示 成员数不足
|
||||
#5 -4: 表示 登录失败
|
||||
#2 -5: 表示 服务过期
|
||||
#1026 -8: 表示 修改密码
|
||||
#7 -9: 表示 服务被禁
|
||||
#401 -10: 表示 授权被禁
|
||||
#-1 -11: 表示 登录故障 这个要区别一下登录失败(登录成功后断开)
|
||||
|
||||
|
||||
# 显示登录成功 未组网页面
|
||||
#-1 -6: 表示 移除网络
|
||||
#6 -7: 表示 状态关闭
|
||||
|
||||
# err_code=
|
||||
# vpn_status=
|
||||
# login_status=
|
||||
|
||||
if [ "$progress" == "connected" ] ;then ### 已组网
|
||||
vpn_status=1
|
||||
elif [ "$progress" == "tryconnect" ] ;then
|
||||
logger -t vpnprogress $progress
|
||||
elif [ "$progress" == "sn" ] ;then
|
||||
vpn_status=99
|
||||
uci set pgyvpn.base.login_status=1
|
||||
uci set pgyvpn.base.vpnid=$2
|
||||
uci set pgyvpn.base.vpnpwd=$3
|
||||
elif [ "$progress" == "login_err" ] ;then
|
||||
vpn_status=0
|
||||
err_code=$2
|
||||
if [ "$err_code" == "4" ] ;then
|
||||
err_code=-1
|
||||
elif [ "$err_code" == "6" ] ;then
|
||||
err_code=-3
|
||||
elif [ "$err_code" == "5" ] ;then
|
||||
err_code=-4
|
||||
elif [ "$err_code" == "2" ] ;then
|
||||
err_code=-5
|
||||
elif [ "$err_code" == "7" ] ;then
|
||||
err_code=-9
|
||||
elif [ "$err_code" == "401" ] ;then
|
||||
err_code=-10
|
||||
elif [ "$err_code" == "403" ] ;then
|
||||
err_code=-10
|
||||
elif [ "$err_code" == "-1" ] ;then
|
||||
err_code=-11
|
||||
fi
|
||||
### login failed can't disabled vpn service
|
||||
|
||||
if [ "$err_code" == "-11" ] ;then
|
||||
status=`uci get pgyvpn.base.login_status`
|
||||
logger -t errcode $status
|
||||
if [ "$status" != "1" ] ;then
|
||||
uci set pgyvpn.base.enable_status=0 ### 下回不启用
|
||||
/etc/init.d/pgyvpn stop > /dev/null
|
||||
fi
|
||||
elif [ "$err_code" != "-4" ] ;then
|
||||
uci set pgyvpn.base.enable_status=0 ### 下回不启用
|
||||
/etc/init.d/pgyvpn stop > /dev/null
|
||||
fi
|
||||
|
||||
|
||||
uci set pgyvpn.base.err_code=$err_code
|
||||
|
||||
elif [ "$progress" == "not_in_group" ] ;then ### 未组网
|
||||
## not_in_group is not a err
|
||||
vpn_status=0
|
||||
err_code=0
|
||||
uci set pgyvpn.base.login_status=1
|
||||
|
||||
elif [ "$progress" == "disconnected" ] ;then
|
||||
err_code=$2
|
||||
vpn_status=0
|
||||
if [ -n "$err_code" ] ;then
|
||||
vpn_status=0
|
||||
if [ "$err_code" == "-1" ] ;then
|
||||
err_code=-6
|
||||
elif [ "$err_code" == "6" ] ;then
|
||||
err_code=-7
|
||||
elif [ "$err_code" == "1026" ] ;then
|
||||
err_code=-8
|
||||
fi
|
||||
uci set pgyvpn.base.err_code=$err_code
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$vpn_status" ] ;then
|
||||
uci set pgyvpn.base.vpn_status=$vpn_status
|
||||
fi
|
||||
|
||||
if [ "$err_code" == "-5" ] || [ "$err_code" == "-9" ] || [ "$err_code" == "-8" ] ;then
|
||||
uci set pgyvpn.base.login_status=0
|
||||
uci set pgyvpn.base.enable_status=0
|
||||
fi
|
||||
|
||||
if [ "$vpn_status" == "1" ] || [ "$vpn_status" == "0" -a "$err_code" == "0" ] ;then
|
||||
uci set pgyvpn.base.login_status=1
|
||||
uci set pgyvpn.base.enable_status=1
|
||||
fi
|
||||
|
||||
uci commit
|
||||
Reference in New Issue
Block a user