Skip to content

Commit f33a89d

Browse files
authored
支持快捷修改密码和开放公网web ui 访问功能
1 parent 389bfd5 commit f33a89d

6 files changed

Lines changed: 79 additions & 47 deletions

File tree

app/www/mefrpc

-4 KB
Binary file not shown.

cmd/main

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ PID_FILE="${TRIM_PKGVAR}/app.pid"
55
MEFRPC_LOG="${TRIM_PKGVAR}/mefrpc.log"
66
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
77
PKG_DIR="${TRIM_APPDEST:-$(cd "${SCRIPT_DIR}/.." && pwd)}"
8+
MEFRPC_HOME="${TRIM_PKGVAR}"
9+
mkdir -p "${MEFRPC_HOME}" >> ${LOG_FILE} 2>&1
10+
export HOME="${MEFRPC_HOME}"
811
MEFRPC_BIN=""
912
for p in "${PKG_DIR}/www/mefrpc" "${PKG_DIR}/app/www/mefrpc" "${PKG_DIR}/mefrpc" "${PKG_DIR}/target/mefrpc" "${PKG_DIR}/app/mefrpc" "${PKG_DIR}/app/bin/mefrpc" "${SCRIPT_DIR}/../mefrpc"; do
1013
if [ -f "${p}" ]; then
@@ -16,11 +19,21 @@ if [ -z "${MEFRPC_BIN}" ]; then
1619
MEFRPC_BIN="${PKG_DIR}/mefrpc"
1720
fi
1821
MEFRPC_BIND_HOST="${MEFRPC_BIND_HOST:-0.0.0.0}"
22+
MEFRPC_WEBUI_PORT="${MEFRPC_WEBUI_PORT:-1201}"
23+
MEFRPC_START_RETRY_MAX="${MEFRPC_START_RETRY_MAX:-6}"
24+
MEFRPC_START_RETRY_DELAY="${MEFRPC_START_RETRY_DELAY:-5}"
25+
MEFRPC_ALLOW_PUBLIC_ACCESS_RAW="${WIZARD_CONFIG_WEBUI_PUBLIC_ACCESS:-${wizard_config_webui_public_access:-}}"
26+
if [ "${MEFRPC_ALLOW_PUBLIC_ACCESS_RAW}" = "true" ] || [ "${MEFRPC_ALLOW_PUBLIC_ACCESS_RAW}" = "1" ]; then
27+
MEFRPC_ALLOW_PUBLIC_ACCESS="--webui-allow-public-access"
28+
else
29+
MEFRPC_ALLOW_PUBLIC_ACCESS=""
30+
fi
31+
MEFRPC_WEBUI_PASS="${WIZARD_CONFIG_WEBUI_PASS:-${wizard_config_webui_pass:-${WIZARD_WEBUI_PASS:-${wizard_webui_pass:-admin}}}}"
1932
MEFRPC_RUN="\"${MEFRPC_BIN}\""
2033
if command -v stdbuf >/dev/null 2>&1; then
2134
MEFRPC_RUN="stdbuf -oL -eL ${MEFRPC_RUN}"
2235
fi
23-
CMD="cd \"${PKG_DIR}\" && exec ${MEFRPC_RUN} --webui-addr \"${MEFRPC_BIND_HOST}\" >> \"${MEFRPC_LOG}\" 2>&1"
36+
CMD="cd \"${PKG_DIR}\" && exec ${MEFRPC_RUN} ${MEFRPC_ALLOW_PUBLIC_ACCESS} --webui-addr \"${MEFRPC_BIND_HOST}\" --webui-port \"${MEFRPC_WEBUI_PORT}\" --webui-pass \"${MEFRPC_WEBUI_PASS}\" >> \"${MEFRPC_LOG}\" 2>&1"
2437

2538
log_msg() {
2639
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> ${LOG_FILE}
@@ -43,19 +56,21 @@ start_process() {
4356
return 1
4457
fi
4558
chmod +x "${MEFRPC_BIN}" >> ${LOG_FILE} 2>&1
46-
# run cmd to start process
47-
bash -c "${CMD}" >> ${LOG_FILE} 2>&1 &
48-
# write pid to pidfile
49-
local start_pid=$!
50-
printf "%s" "${start_pid}" > ${PID_FILE}
51-
sleep 1
52-
if ! check_process "${start_pid}"; then
53-
log_msg "process exited immediately, check ${MEFRPC_LOG}"
54-
return 1
55-
fi
56-
# log_msg "CMD = ${CMD}"
57-
# log_msg "pid = $!"
58-
return 0
59+
local attempt=1
60+
while [ "${attempt}" -le "${MEFRPC_START_RETRY_MAX}" ]; do
61+
bash -c "${CMD}" >> ${LOG_FILE} 2>&1 &
62+
local start_pid=$!
63+
sleep 1
64+
if check_process "${start_pid}"; then
65+
printf "%s" "${start_pid}" > ${PID_FILE}
66+
return 0
67+
fi
68+
log_msg "process exited immediately, retrying (${attempt}/${MEFRPC_START_RETRY_MAX})"
69+
attempt=$((attempt + 1))
70+
sleep "${MEFRPC_START_RETRY_DELAY}"
71+
done
72+
log_msg "process failed after ${MEFRPC_START_RETRY_MAX} attempts, check ${MEFRPC_LOG}"
73+
return 1
5974
}
6075

6176
stop_process() {

config/resource

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
11
{
2-
"data-share":
3-
{
4-
"shares":
5-
[
6-
{
7-
"name": "mefrp",
8-
"permission":
9-
{
10-
"rw":
11-
[
12-
"mefrp"
13-
]
14-
}
15-
},
16-
{
172
"name": "mefrp/data",
183
"permission":
194
{
205
"rw":
216
[
227
"mefrp"
238
]
24-
}
25-
}
26-
]
279
}
2810
}

manifest

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
appname = mefrp
2-
version = 2.0.0
2+
version = 2.0.0-1
33
display_name = ME Frp 内网穿透
4-
desc = 幻缘映射飞牛fnos版WebUI启动器<br>默认密码为 admin,可通过命令行参数 --webui-pass 进行修改<br>📝 <a href="https://magicedge.feishu.cn/share/base/form/shrcndMe3AIHvbEXxxG11SuHw3g">问题反馈问卷</a><br>📖 <a href="https://www.mefrp.com/docs/usage/fnnas">使用方法</a><br>🌐 <a href="https://www.mefrp.com/">官网链接</a><br>👥 <a href="https://qm.qq.com/q/fBtW7lJ1Xa">QQ交流反馈群</a>
4+
desc = 幻缘映射飞牛fnos版WebUI启动器<br>默认密码为 admin,可从”应用设置“进行修改<br>📝 <a href="https://magicedge.feishu.cn/share/base/form/shrcndMe3AIHvbEXxxG11SuHw3g">问题反馈问卷</a><br>📖 <a href="https://www.mefrp.com/docs/usage/fnnas">使用方法</a><br>🌐 <a href="https://www.mefrp.com/">官网链接</a><br>👥 <a href="https://qm.qq.com/q/fBtW7lJ1Xa">QQ交流反馈群</a><br>🐙 <a href="https://github.com/MagicEdgeNet/ME-Frp-fnOS-Client">GitHub 仓库地址</a>
55
arch = x86_64
66
source = thirdparty
77
maintainer = 幻缘网络
88
maintainer_url = https://www.mefrp.com/
99
distributor = sherry
1010
distributor_url = https://club.fnnas.com/home.php?mod=space&uid=16443
11-
os_min_version = 1.1.20
12-
changelog = 1.支持webui,带来全新体验<br>2.支持多隧道启动
11+
os_min_version = 1.1.23
12+
changelog = 本次更新我们带来了新版本frpc的Web UI配置功能,从此隧道配置无需复制启动命令,登录账号即可一键启动,方便又快捷<br><br>更新重要提醒<br>1.本次更新后,docker容器将废弃,请您在更新完成后,自行前往docker中心删除容器<br>2.请您在更新前,务必确保设备1201端口未被占用,如占用,应用将无法启动<br><br>最后,祝你使用愉快呀~
1313
desktop_uidir = ui
1414
desktop_applaunchname = mefrp.Application
1515
service_port = 1201
16-
checkport = true
16+
checkport = true

wizard/config

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
[
22
{
3-
"stepTitle": "修改启动参数",
3+
"stepTitle": "应用配置",
44
"items": [
55
{
6-
"type": "tips",
7-
"helpText": "更改后,请前往docker-compose界面关闭\"my-app\"项目并重新构建"
6+
"type": "switch",
7+
"field": "wizard_config_webui_public_access",
8+
"label": "允许公网访问 WebUI",
9+
"initValue": "false"
810
},
911
{
10-
"type": "text",
11-
"field": "start_cmd",
12-
"label": "启动命令",
13-
"initValue": "start_cmd",
12+
"type": "password",
13+
"field": "wizard_config_webui_pass",
14+
"label": "WebUI 密码",
15+
"initValue": "admin",
1416
"rules": [
15-
{ "required": true, "message": "请输入启动命令" },
16-
{ "pattern": "^-t\\s+\\S+\\s+-p\\s+\\S+$", "message": "格式:-t xxx -p yyy" }
17+
{
18+
"required": true,
19+
"message": "请输入 WebUI 密码"
20+
},
21+
{
22+
"pattern": "^.{5,}$",
23+
"message": "密码长度至少 5 位"
24+
}
1725
]
1826
}
1927
]

wizard/install

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,34 @@
44
"items": [
55
{
66
"type": "tips",
7-
"helpText": "欢迎您使用ME Frp内网穿透服务,在使用之前,请您认真阅读本说明<br>应用默认密钥为:admin(访问webui时需使用)<br>应用默认端口为1201<br>如需要修改密码,请使用命令行参数 --webui-pass 修改"
7+
"helpText": "欢迎您使用 ME Frp 内网穿透服务,在使用之前,请您认真阅读本说明<br>1、应用默认密钥为: admin (访问 WebUI 时需使用)<br>2、应用默认端口为 1201<br>3、如需要修改密码,请从“应用设置”修改"
8+
}
9+
]
10+
},
11+
{
12+
"stepTitle": "应用配置",
13+
"items": [
14+
{
15+
"type": "switch",
16+
"field": "wizard_webui_public_access",
17+
"label": "允许公网访问 WebUI",
18+
"initValue": "false"
19+
},
20+
{
21+
"type": "password",
22+
"field": "wizard_webui_pass",
23+
"label": "WebUI 密码",
24+
"initValue": "admin",
25+
"rules": [
26+
{
27+
"required": true,
28+
"message": "请输入 WebUI 密码"
29+
},
30+
{
31+
"pattern": "^.{5,}$",
32+
"message": "密码长度至少 5 位"
33+
}
34+
]
835
}
936
]
1037
}

0 commit comments

Comments
 (0)