1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00
This commit is contained in:
suyuan 2023-05-23 00:01:23 +08:00
parent a2f92ecce2
commit 5210d2b2d6
10 changed files with 439 additions and 0 deletions

28
frp/files/frpc.config Normal file
View file

@ -0,0 +1,28 @@
config init
option stdout 1
option stderr 1
option user frpc
option group frpc
option respawn 1
config conf 'common'
option server_addr routev2.55860.com
option server_port 4443
option token daf96d69f52ec4aef2ac6abcf363fc41
option authentication_method token
option admin_addr 0.0.0.0
option admin_port 7400
option admin_user admin
option admin_pwd 17603766659
config conf '60230200115'
option type http
option local_port 80
option subdomain 60230200115
config conf 'ssh_random'
option type tcp
option local_ip 127.0.0.1
option local_port 22
option remote_port 0
option bandwidth_limit 1MB

80
frp/files/frpc.init Normal file
View file

@ -0,0 +1,80 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
NAME=frpc
PROG=/usr/bin/$NAME
_err() {
echo "$*" >&2
logger -p daemon.err -t "$NAME" "$*"
}
config_cb() {
[ $# -eq 0 ] && return
local type="$1"
local name="$2"
if [ "$type" = "conf" ]; then
echo "[$name]" >> "$conf_file"
option_cb() {
local option="$1"
local value="$2"
[ "$option" = "name" ] && \
sed -i "s/$CONFIG_SECTION/$value/g" "$conf_file" || \
echo "$option = $value" >> "$conf_file";
}
list_cb() {
local name="$1"
local value="$2"
[ "$name" = "_" ] && echo "$value" >> "$conf_file"
}
else
[ "$type" = "init" ] && init_cfg="$name"
option_cb() { return 0; }
list_cb() { return 0; }
fi
}
service_triggers()
{
procd_add_reload_trigger "$NAME"
}
start_service() {
local init_cfg=" "
local conf_file="/var/etc/$NAME.ini"
> "$conf_file"
config_load "$NAME"
local stdout stderr user group respawn env conf_inc
uci_validate_section "$NAME" init "$init_cfg" \
'stdout:bool:1' \
'stderr:bool:1' \
'user:string' \
'group:string' \
'respawn:bool:1' \
'env:list(string)' \
'conf_inc:list(string)'
local err=$?
[ $err -ne 0 ] && {
_err "uci_validate_section returned $err"
return 1
}
[ -n "$conf_inc" ] && config_list_foreach "$init_cfg" conf_inc cat >> "$conf_file"
procd_open_instance
procd_set_param command "$PROG" -c "$conf_file"
procd_set_param file $conf_file
procd_set_param stdout $stdout
procd_set_param stderr $stderr
[ -n "$user" ] && procd_set_param user "$user"
[ -n "$group" ] && procd_set_param group "$group"
[ $respawn -eq 1 ] && procd_set_param respawn
[ -n "$env" ] && config_list_foreach "$init_cfg" env "procd_append_param env"
procd_close_instance
}

View file

@ -0,0 +1,19 @@
#!/bin/sh
. /lib/functions.sh
upgrade() {
local section=$1
local name
[ "$section" != "common" ] || return 0
config_get name $section name
if [ -z "$name" ]; then
uci_set frpc "$section" name "$section"
uci_commit frpc
fi
}
config_load frpc
config_foreach upgrade conf
exit 0

16
frp/files/frps.config Normal file
View file

@ -0,0 +1,16 @@
config init
option stdout 1
option stderr 1
option user frps
option group frps
option respawn 1
# OS environments pass to frp for config file template, see
# https://github.com/fatedier/frp#configuration-file-template
# list env 'ENV_NAME=value'
# Config files include in temporary config file.
# list conf_inc '/etc/frp/frps.d/frps_full.ini'
config conf 'common'
option bind_port 7000
# List options with name="_" will be directly appended to config file
# list _ '# Key-A=Value-A'

78
frp/files/frps.init Normal file
View file

@ -0,0 +1,78 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
NAME=frps
PROG=/usr/bin/$NAME
_err() {
echo "$*" >&2
logger -p daemon.err -t "$NAME" "$*"
}
config_cb() {
[ $# -eq 0 ] && return
local type="$1"
local name="$2"
if [ "$type" = "conf" ]; then
echo "[$name]" >> "$conf_file"
option_cb() {
local option="$1"
local value="$2"
echo "$option = $value" >> "$conf_file"
}
list_cb() {
local name="$1"
local value="$2"
[ "$name" = "_" ] && echo "$value" >> "$conf_file"
}
else
[ "$type" = "init" ] && init_cfg="$name"
option_cb() { return 0; }
list_cb() { return 0; }
fi
}
service_triggers()
{
procd_add_reload_trigger "$NAME"
}
start_service() {
local init_cfg=" "
local conf_file="/var/etc/$NAME.ini"
> "$conf_file"
config_load "$NAME"
local stdout stderr user group respawn env conf_inc
uci_validate_section "$NAME" init "$init_cfg" \
'stdout:bool:1' \
'stderr:bool:1' \
'user:string' \
'group:string' \
'respawn:bool:1' \
'env:list(string)' \
'conf_inc:list(string)'
local err=$?
[ $err -ne 0 ] && {
_err "uci_validate_section returned $err"
return 1
}
[ -n "$conf_inc" ] && config_list_foreach "$init_cfg" conf_inc cat >> "$conf_file"
procd_open_instance
procd_set_param command "$PROG" -c "$conf_file"
procd_set_param file $conf_file
procd_set_param stdout $stdout
procd_set_param stderr $stderr
[ -n "$user" ] && procd_set_param user "$user"
[ -n "$group" ] && procd_set_param group "$group"
[ $respawn -eq 1 ] && procd_set_param respawn
[ -n "$env" ] && config_list_foreach "$init_cfg" env "procd_append_param env"
procd_close_instance
}