应用入口
应用入口配置大概这样,省略了一些无关的配置
port为空则跳转飞牛端口,比如默认的5666,不为空则跳转填写的端口,比如填写的8080,再拼上url,最后大概是 http://192.168.1.2:8080/aaa/bbb
我们会发现,链接的大多数地方都可以填写,但是ip不行,因为内网大概的飞牛会用内网ip,fn connect 大概的会用域名
如果,我是说如果,如果我想跳转到一个飞牛以外的ip咋办,比如局域网的其它IP,或者一个公网的网站
{
".url": {
"appname.Application": {
"protocol": "http",
"port": "8080",
"url": "/aaa/bbb"
}
}
}
302跳转
想要跳转到一个自定义的地址,其中一个办法是可以借助CGI输出302跳转
以下是一个示例
- 新建app/ui/index.cgi,TARGET_URL可以填写自己任意的地址
#!/bin/bash
TARGET_URL="https://fnpackup.snltty.com/"
cat << EOF
Status: 302 Moved Temporarily
Location: $TARGET_URL
Content-Type: text/html
<!DOCTYPE html>
<html>
<head><meta http-equiv="refresh" content="0;url=$TARGET_URL"></head>
<body>Redirecting to <a href="$TARGET_URL">$TARGET_URL</a></body>
</html>
EOF
- 入口配置,依然省略无关配置,appname就是你manifest中配置的appname
{
".url": {
"appname.Application": {
"protocol": "http",
"port": "",
"url": "/cgi/ThirdParty/appname/index.cgi/"
}
}
}
再升级
如果我希望在fpk安装的时候用户填写一个URL呢,我们可以在向导中让用户输入,然后在 install_callback 替换调index.cgi中的内容
以下是一个示例
- wizard/install,安装向导
[
{
"stepTitle": "欢迎使用",
"items": [
{
"type": "text",
"field": "wizard_url",
"label": "跳转地址",
"rules": [],
"options": [],
"initValue": "https://fnpackup.snltty.com"
}
]
}
]
- app/ui/index.cgi,我们可以搞个占位,方便替换
#!/bin/bash
TARGET_URL="{target}"
cat << EOF
Status: 302 Moved Temporarily
Location: $TARGET_URL
Content-Type: text/html
<!DOCTYPE html>
<html>
<head><meta http-equiv="refresh" content="0;url=$TARGET_URL"></head>
<body>Redirecting to <a href="$TARGET_URL">$TARGET_URL</a></body>
</html>
EOF
- cmd/install_callback,安装后回调,替换内容
#!/bin/bash
sed -i "s|{target}|${wizard_url}|g" ${TRIM_APPDEST}/ui/index.cgi
exit 0