mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 14:27:01 +08:00
Compare commits
15 Commits
e5b0f2c061
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
364c7d697b | ||
|
|
570281b559 | ||
|
|
b672f05c7b | ||
|
|
9cdfa22371 | ||
|
|
1211804e8f | ||
| 1bb3028308 | |||
| cd81e22d53 | |||
| 18792a395c | |||
| 83ad03eca3 | |||
| 91c15936ee | |||
| a37952a292 | |||
| 2ef1bc7469 | |||
| 8a39342519 | |||
|
|
1a7d118119 | ||
|
|
ac42cec025 |
26
README.md
26
README.md
@@ -1,4 +1,4 @@
|
|||||||
# frpc-panel
|
# frpc-panel(支持 FRP >= 0.52.0)
|
||||||
|
|
||||||
[中文文档](README.md) | [README](README_en.md)
|
[中文文档](README.md) | [README](README_en.md)
|
||||||
|
|
||||||
@@ -6,6 +6,8 @@ frpc-panel 是 https://github.com/fatedier/frp 的一个客户端工具,用于
|
|||||||
|
|
||||||
frps-panel 会以一个单独的进程运行,通过后台调用frpc的接口实现对frpc的操作。
|
frps-panel 会以一个单独的进程运行,通过后台调用frpc的接口实现对frpc的操作。
|
||||||
|
|
||||||
|
## 从版本2.0.0开始,本插件只支持版本号大于等于v0.52.0的frp
|
||||||
|
|
||||||
## 功能
|
## 功能
|
||||||
|
|
||||||
+ 展示客户端基础配置信息
|
+ 展示客户端基础配置信息
|
||||||
@@ -17,14 +19,21 @@ frps-panel 会以一个单独的进程运行,通过后台调用frpc的接口
|
|||||||
|
|
||||||
## 使用方法
|
## 使用方法
|
||||||
|
|
||||||
1、frpc的配置文件`frpc.ini`中,增加如下内容:
|
1、frpc的配置文件`frpc.toml`中,增加如下内容:
|
||||||
|
|
||||||
```ini
|
```toml
|
||||||
[common]
|
webServer.addr = "127.0.0.1"
|
||||||
admin_addr = 127.0.0.1
|
webServer.port = 7400
|
||||||
admin_port = 7400
|
webServer.user = "admin"
|
||||||
admin_user = admin
|
webServer.password = "admin"
|
||||||
admin_pwd = admin
|
```
|
||||||
|
或
|
||||||
|
```toml
|
||||||
|
[webServer]
|
||||||
|
addr = "127.0.0.1"
|
||||||
|
port = 7400
|
||||||
|
user = "admin"
|
||||||
|
password = "admin"
|
||||||
```
|
```
|
||||||
|
|
||||||
2、frpc-panel的配置文件`frpc-panel.toml`的配置如下:
|
2、frpc-panel的配置文件`frpc-panel.toml`的配置如下:
|
||||||
@@ -91,3 +100,4 @@ dashboard_pwd = "admin"
|
|||||||
+ [fp-multiuser](https://github.com/gofrp/fp-multiuser)
|
+ [fp-multiuser](https://github.com/gofrp/fp-multiuser)
|
||||||
+ [layui](https://github.com/layui/layui)
|
+ [layui](https://github.com/layui/layui)
|
||||||
+ [layui-theme-dark](https://github.com/Sight-wcg/layui-theme-dark)
|
+ [layui-theme-dark](https://github.com/Sight-wcg/layui-theme-dark)
|
||||||
|
+ 修改过的JavaScript版的[toml](https://github.com/yhl452493373/toml),原始地址[toml](https://github.com/flourd/toml)
|
||||||
|
|||||||
26
README_en.md
26
README_en.md
@@ -1,4 +1,4 @@
|
|||||||
# frpc-panel
|
# frpc-panel(Support FRP >= 0.52.0)
|
||||||
|
|
||||||
[中文文档](README.md) | [README](README_en.md)
|
[中文文档](README.md) | [README](README_en.md)
|
||||||
|
|
||||||
@@ -6,6 +6,8 @@ frpc-panel is a client tool of https://github.com/fatedier/frp , it's used to sh
|
|||||||
|
|
||||||
frps-panel will run as one single process and manage frpc proxy info with frpc's api.
|
frps-panel will run as one single process and manage frpc proxy info with frpc's api.
|
||||||
|
|
||||||
|
## Since version 2.0.0,this plugin only support frp version >= v0.52.0
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
+ Show frpc basic info
|
+ Show frpc basic info
|
||||||
@@ -17,14 +19,21 @@ frps-panel will run as one single process and manage frpc proxy info with frpc's
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
1.add config in frpc's config file '`frpc.ini`:
|
1.add config in frpc's config file '`frpc.toml`:
|
||||||
|
|
||||||
```ini
|
```toml
|
||||||
[common]
|
webServer.addr = "127.0.0.1"
|
||||||
admin_addr = 127.0.0.1
|
webServer.port = 7400
|
||||||
admin_port = 7400
|
webServer.user = "admin"
|
||||||
admin_user = admin
|
webServer.password = "admin"
|
||||||
admin_pwd = admin
|
```
|
||||||
|
or
|
||||||
|
```toml
|
||||||
|
[webServer]
|
||||||
|
addr = "127.0.0.1"
|
||||||
|
port = 7400
|
||||||
|
user = "admin"
|
||||||
|
password = "admin"
|
||||||
```
|
```
|
||||||
|
|
||||||
2.`frpc-panel.toml`:
|
2.`frpc-panel.toml`:
|
||||||
@@ -96,3 +105,4 @@ If you have any issues or ideas, put it on [issues](https://github.com/yhl452493
|
|||||||
+ [fp-multiuser](https://github.com/gofrp/fp-multiuser)
|
+ [fp-multiuser](https://github.com/gofrp/fp-multiuser)
|
||||||
+ [layui](https://github.com/layui/layui)
|
+ [layui](https://github.com/layui/layui)
|
||||||
+ [layui-theme-dark](https://github.com/Sight-wcg/layui-theme-dark)
|
+ [layui-theme-dark](https://github.com/Sight-wcg/layui-theme-dark)
|
||||||
|
+ modified version of [toml](https://github.com/yhl452493373/toml), forked from [toml](https://github.com/flourd/toml)
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"Extra": "Extra Params",
|
"Extra": "Extra Params",
|
||||||
"Proxy Name": "Proxy Name",
|
"Proxy Name": "Proxy Name",
|
||||||
"Custom Domains": "Custom Domains",
|
"Custom Domains": "Custom Domains",
|
||||||
|
"Custom Domains Example": "[\"first.domain.org\",\"second.domain.net\"]",
|
||||||
"Subdomain": "Subdomain",
|
"Subdomain": "Subdomain",
|
||||||
"Remote Port": "Remote Port",
|
"Remote Port": "Remote Port",
|
||||||
"Use Encryption": "Use Encryption",
|
"Use Encryption": "Use Encryption",
|
||||||
@@ -51,8 +52,14 @@
|
|||||||
"Status": "Status",
|
"Status": "Status",
|
||||||
"Info": "Info",
|
"Info": "Info",
|
||||||
"running": "running",
|
"running": "running",
|
||||||
"Local Ip": "Local Ip",
|
"start error": "start error",
|
||||||
|
"new": "new",
|
||||||
|
"Proxy Name Example": "Intranet Penetration",
|
||||||
|
"Local IP": "Local IP",
|
||||||
|
"Local IP Example": "127.0.0.1",
|
||||||
"Local Port": "Local Port",
|
"Local Port": "Local Port",
|
||||||
|
"Local Port Example": "8080",
|
||||||
|
"Remote Port Example": "18080",
|
||||||
"Operation": "Operation",
|
"Operation": "Operation",
|
||||||
"Confirm": "Confirm",
|
"Confirm": "Confirm",
|
||||||
"Cancel": "Cancel",
|
"Cancel": "Cancel",
|
||||||
@@ -66,5 +73,15 @@
|
|||||||
"Frp Client Error": "Frp client error",
|
"Frp Client Error": "Frp client error",
|
||||||
"Proxy Exist,": "Proxy name exist",
|
"Proxy Exist,": "Proxy name exist",
|
||||||
"Proxy Not Exist": "Proxy name not exist",
|
"Proxy Not Exist": "Proxy name not exist",
|
||||||
"Client Tips": "Client tips"
|
"Client Tips": "Client tips",
|
||||||
|
"and": " and ",
|
||||||
|
"Require Not All Empty": " can't be empty at the same time",
|
||||||
|
"Require Not Empty": " can't be empty",
|
||||||
|
"Require Number": " should be a number",
|
||||||
|
"Require Boolean": " should be a boolean",
|
||||||
|
"Require Array": " should be an js array",
|
||||||
|
"Total": "Total ",
|
||||||
|
"Items": " items",
|
||||||
|
"Go to": "Go to",
|
||||||
|
"Per Page": " / page"
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
"Extra": "附加参数",
|
"Extra": "附加参数",
|
||||||
"Proxy Name": "代理名称",
|
"Proxy Name": "代理名称",
|
||||||
"Custom Domains": "自定义域名",
|
"Custom Domains": "自定义域名",
|
||||||
|
"Custom Domains Example": "[\"first.domain.org\",\"second.domain.net\"]",
|
||||||
"Subdomain": "子域名",
|
"Subdomain": "子域名",
|
||||||
"Remote Port": "服务端端口",
|
"Remote Port": "服务端端口",
|
||||||
"Use Encryption": "加密传输",
|
"Use Encryption": "加密传输",
|
||||||
@@ -51,8 +52,14 @@
|
|||||||
"Status": "状态",
|
"Status": "状态",
|
||||||
"Info": "消息",
|
"Info": "消息",
|
||||||
"running": "运行中",
|
"running": "运行中",
|
||||||
"Local Ip": "本地IP",
|
"start error": "错误",
|
||||||
|
"new": "新连接",
|
||||||
|
"Proxy Name Example": "内网穿透",
|
||||||
|
"Local IP": "本地IP",
|
||||||
|
"Local IP Example": "127.0.0.1",
|
||||||
"Local Port": "本地端口",
|
"Local Port": "本地端口",
|
||||||
|
"Local Port Example": "8080",
|
||||||
|
"Remote Port Example": "18080",
|
||||||
"Operation": "操作",
|
"Operation": "操作",
|
||||||
"Confirm": "确定",
|
"Confirm": "确定",
|
||||||
"Cancel": "取消",
|
"Cancel": "取消",
|
||||||
@@ -66,5 +73,15 @@
|
|||||||
"Frp Client Error": "Frp客户端错误",
|
"Frp Client Error": "Frp客户端错误",
|
||||||
"Proxy Exist": "代理名称重复",
|
"Proxy Exist": "代理名称重复",
|
||||||
"Proxy Not Exist": "代理名称不存在",
|
"Proxy Not Exist": "代理名称不存在",
|
||||||
"Client Tips": "客户端提示"
|
"Client Tips": "客户端提示",
|
||||||
|
"and": "和",
|
||||||
|
"Require Not All Empty": "不能同时为空",
|
||||||
|
"Require Not Empty": "不能为空",
|
||||||
|
"Require Number": "应当为数字",
|
||||||
|
"Require Boolean": "应当为布尔值",
|
||||||
|
"Require Array": "应当为JS数组",
|
||||||
|
"Total": "共",
|
||||||
|
"Items": "条记录",
|
||||||
|
"Go to": "到第",
|
||||||
|
"Per Page": "条/页"
|
||||||
}
|
}
|
||||||
@@ -217,12 +217,11 @@ section.client-info .text-row .text-col {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.proxy-popup .extra-param-tab-item .layui-form-item .layui-input-inline:nth-child(1) {
|
.proxy-popup .extra-param-tab-item .layui-form-item .layui-input-inline:nth-child(1) {
|
||||||
width: 150px;
|
width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.proxy-popup .extra-param-tab-item .layui-form-item .layui-input-inline:nth-child(3) {
|
.proxy-popup .extra-param-tab-item .layui-form-item .layui-input-inline:nth-child(3) {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
margin-right: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchForm input {
|
#searchForm input {
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
var loadClientInfo = (function ($) {
|
var loadClientInfo = (function ($) {
|
||||||
var i18n = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get client info
|
* get client info
|
||||||
* @param lang {Map<string,string>} language json
|
|
||||||
* @param title {string} page title
|
* @param title {string} page title
|
||||||
*/
|
*/
|
||||||
function loadClientInfo(lang, title) {
|
function loadClientInfo( title) {
|
||||||
i18n = lang;
|
|
||||||
$("#title").text(title);
|
$("#title").text(title);
|
||||||
$('#content').empty();
|
$('#content').empty();
|
||||||
var loading = layui.layer.load();
|
var loading = layui.layer.load();
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
var loadProxyInfo = (function ($) {
|
var loadProxyInfo = (function ($) {
|
||||||
var i18n = {}, currentProxyType, currentTitle;
|
var currentProxyType, currentTitle;
|
||||||
//param names in Basic tab
|
|
||||||
var basicParamNames = ['name', 'type', 'local_ip', 'local_port', 'custom_domains', 'subdomain', 'remote_port', 'use_encryption', 'use_compression'];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get proxy info
|
* get proxy info
|
||||||
* @param lang {{}} language json
|
|
||||||
* @param title page title
|
* @param title page title
|
||||||
* @param proxyType proxy type
|
* @param proxyType proxy type
|
||||||
*/
|
*/
|
||||||
function loadProxyInfo(lang, title, proxyType) {
|
function loadProxyInfo(title, proxyType) {
|
||||||
if (lang != null)
|
|
||||||
i18n = lang;
|
|
||||||
if (title != null)
|
if (title != null)
|
||||||
currentTitle = title;
|
currentTitle = title;
|
||||||
if (proxyType != null)
|
if (proxyType != null)
|
||||||
@@ -26,6 +21,7 @@ var loadProxyInfo = (function ($) {
|
|||||||
if (result.success) {
|
if (result.success) {
|
||||||
$('#content').html($('#proxyListTableTemplate').html());
|
$('#content').html($('#proxyListTableTemplate').html());
|
||||||
renderProxyListTable(result.data);
|
renderProxyListTable(result.data);
|
||||||
|
loadFrpcConfig();
|
||||||
} else {
|
} else {
|
||||||
layui.layer.msg(result.message);
|
layui.layer.msg(result.message);
|
||||||
}
|
}
|
||||||
@@ -34,50 +30,82 @@ var loadProxyInfo = (function ($) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadFrpcConfig() {
|
||||||
|
$.getJSON('/proxy/api/config', {
|
||||||
|
type: 'none'
|
||||||
|
}).done(function (result) {
|
||||||
|
if (result.success) {
|
||||||
|
var proxies = [];
|
||||||
|
result.data.proxies.forEach(function (proxy) {
|
||||||
|
var items = flatJSON(proxy['ProxyConfigurer']);
|
||||||
|
proxies.push(expandJSON(items))
|
||||||
|
})
|
||||||
|
var visitors = [];
|
||||||
|
result.data.visitors.forEach(function (visitor) {
|
||||||
|
var items = flatJSON(visitor['VisitorConfigurer']);
|
||||||
|
visitors.push(expandJSON(items))
|
||||||
|
});
|
||||||
|
|
||||||
|
window.clientConfig = $.extend(true, {}, result.data);
|
||||||
|
window.clientConfig.proxies = proxies;
|
||||||
|
window.clientConfig.visitors = visitors;
|
||||||
|
} else {
|
||||||
|
window.clientConfig = {};
|
||||||
|
layui.layer.msg(result.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* render proxy list table
|
* render proxy list table
|
||||||
* @param data {Map<string,Map<string,string>>} proxy data
|
* @param data {[Map<string,string>]} proxy data
|
||||||
*/
|
*/
|
||||||
function renderProxyListTable(data) {
|
function renderProxyListTable(data) {
|
||||||
var dataList = [];
|
var proxies = [];
|
||||||
for (var key in data) {
|
data.forEach(function (temp) {
|
||||||
var temp = data[key];
|
var proxy = temp.ProxyConfigurer;
|
||||||
temp.name = key;
|
basicParams.forEach(function (basicParam) {
|
||||||
temp.local_ip = temp.local_ip || '-';
|
var name = basicParam.name;
|
||||||
temp.local_port = temp.local_port || '-';
|
var defaultValue = basicParam.defaultValue;
|
||||||
temp.use_encryption = temp.use_encryption || false;
|
var value = null;
|
||||||
temp.use_compression = temp.use_compression || false;
|
try {
|
||||||
if (currentProxyType === 'http' || currentProxyType === 'https') {
|
value = eval('proxy.' + name);
|
||||||
temp.custom_domains = temp.custom_domains || '-';
|
if (value == null) {
|
||||||
temp.subdomain = temp.subdomain || '-';
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
dataList.push(temp);
|
} catch (e) {
|
||||||
}
|
value = defaultValue;
|
||||||
|
}
|
||||||
|
eval('proxy.' + name + ' = value');
|
||||||
|
|
||||||
|
});
|
||||||
|
proxies.push(proxy);
|
||||||
|
});
|
||||||
|
|
||||||
var $section = $('#content > section');
|
var $section = $('#content > section');
|
||||||
var cols = [
|
var cols = [
|
||||||
{type: 'checkbox'},
|
{type: 'checkbox'},
|
||||||
{field: 'name', title: i18n['Name'], sort: true},
|
{field: 'name', title: i18n['Name'], sort: true},
|
||||||
{field: 'type', title: i18n['Type'], width: 110, sort: true},
|
{field: 'type', title: i18n['Type'], width: 110, sort: true},
|
||||||
{field: 'local_ip', title: i18n['LocalIp'], width: 150, sort: true},
|
{field: 'localIP', title: i18n['LocalIP'], width: 150, sort: true},
|
||||||
{field: 'local_port', title: i18n['LocalPort'], width: 120, sort: true},
|
{field: 'localPort', title: i18n['LocalPort'], width: 120, sort: true},
|
||||||
];
|
];
|
||||||
|
|
||||||
if (currentProxyType === 'tcp' || currentProxyType === 'udp') {
|
if (currentProxyType === 'tcp' || currentProxyType === 'udp') {
|
||||||
cols.push({field: 'remote_port', title: i18n['RemotePort'], width: 130, sort: true});
|
cols.push({field: 'remotePort', title: i18n['RemotePort'], width: 130, sort: true});
|
||||||
} else if (currentProxyType === 'http' || currentProxyType === 'https') {
|
} else if (currentProxyType === 'http' || currentProxyType === 'https') {
|
||||||
cols.push({field: 'custom_domains', title: i18n['CustomDomains'], sort: true});
|
cols.push({field: 'customDomains', title: i18n['CustomDomains'], sort: true});
|
||||||
cols.push({field: 'subdomain', title: i18n['Subdomain'], width: 150, sort: true});
|
cols.push({field: 'subdomain', title: i18n['Subdomain'], width: 150, sort: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
cols.push({
|
cols.push({
|
||||||
field: 'use_encryption', title: i18n['UseEncryption'], width: 170, templet: function (d) {
|
field: 'useEncryption', title: i18n['UseEncryption'], width: 170, templet: function (d) {
|
||||||
return i18n[d.use_encryption]
|
return i18n[d.transport.useEncryption]
|
||||||
}, sort: true
|
}, sort: true
|
||||||
});
|
});
|
||||||
cols.push({
|
cols.push({
|
||||||
field: 'use_compression', title: i18n['UseCompression'], width: 170, templet: function (d) {
|
field: 'useCompression', title: i18n['UseCompression'], width: 170, templet: function (d) {
|
||||||
return i18n[d.use_compression]
|
return i18n[d.transport.useCompression]
|
||||||
}, sort: true
|
}, sort: true
|
||||||
});
|
});
|
||||||
cols.push({title: i18n['Operation'], width: 150, toolbar: '#proxyListOperationTemplate'});
|
cols.push({title: i18n['Operation'], width: 150, toolbar: '#proxyListOperationTemplate'});
|
||||||
@@ -88,11 +116,15 @@ var loadProxyInfo = (function ($) {
|
|||||||
text: {none: i18n['EmptyData']},
|
text: {none: i18n['EmptyData']},
|
||||||
cols: [cols],
|
cols: [cols],
|
||||||
page: {
|
page: {
|
||||||
layout: navigator.language.indexOf("zh") === -1 ? ['first', 'prev', 'next', 'last'] : ['prev', 'page', 'next', 'skip', 'count', 'limit']
|
limitTemplet: function (item) {
|
||||||
|
return item + i18n['PerPage'];
|
||||||
|
},
|
||||||
|
skipText: [i18n['Goto'], '', i18n['Confirm']],
|
||||||
|
countText: [i18n['Total'], i18n['Items']]
|
||||||
},
|
},
|
||||||
toolbar: '#proxyListToolbarTemplate',
|
toolbar: '#proxyListToolbarTemplate',
|
||||||
defaultToolbar: false,
|
defaultToolbar: false,
|
||||||
data: dataList,
|
data: proxies,
|
||||||
initSort: {
|
initSort: {
|
||||||
field: 'name',
|
field: 'name',
|
||||||
type: 'asc'
|
type: 'asc'
|
||||||
@@ -159,20 +191,32 @@ var loadProxyInfo = (function ($) {
|
|||||||
var extraData = [];
|
var extraData = [];
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
var tempData = $.extend(true, {}, data);
|
var tempData = $.extend(true, {}, data);
|
||||||
basicParamNames.forEach(function (basicName) {
|
|
||||||
if (data.hasOwnProperty(basicName)) {
|
basicParams.forEach(function (basicName) {
|
||||||
basicData[basicName] = tempData[basicName];
|
var name = basicName.name;
|
||||||
delete tempData[basicName];
|
if (name.indexOf('.') !== -1) {
|
||||||
|
var keys = name.split('.');
|
||||||
|
expandJSONKeys(tempData, keys, null);
|
||||||
|
expandJSONKeys(basicData, keys, basicName.defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eval('basicData.' + name + ' = ' + 'tempData.' + name);
|
||||||
|
eval('delete tempData.' + name)
|
||||||
});
|
});
|
||||||
for (var key in tempData) {
|
|
||||||
|
var flatted = flatJSON(tempData);
|
||||||
|
for (var key in flatted) {
|
||||||
|
var value = flatted[key];
|
||||||
|
if (value == null || value === '')
|
||||||
|
continue;
|
||||||
extraData.push({
|
extraData.push({
|
||||||
name: key,
|
name: key,
|
||||||
value: tempData[key]
|
value: value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var html = document.getElementById('addProxyTemplate').innerHTML;
|
|
||||||
|
var html = document.getElementById('proxyFormTemplate').innerHTML;
|
||||||
var content = layui.laytpl(html).render({
|
var content = layui.laytpl(html).render({
|
||||||
type: currentProxyType,
|
type: currentProxyType,
|
||||||
extraData: extraData
|
extraData: extraData
|
||||||
@@ -181,19 +225,18 @@ var loadProxyInfo = (function ($) {
|
|||||||
type: 1,
|
type: 1,
|
||||||
title: false,
|
title: false,
|
||||||
skin: 'proxy-popup',
|
skin: 'proxy-popup',
|
||||||
area: ['450px', '400px'],
|
area: ['550px', '400px'],
|
||||||
content: content,
|
content: content,
|
||||||
btn: [i18n['Confirm'], i18n['Cancel']],
|
btn: [i18n['Confirm'], i18n['Cancel']],
|
||||||
btn1: function (index) {
|
btn1: function (index) {
|
||||||
if (layui.form.validate('#addProxyTemplate')) {
|
if (layui.form.validate('#proxyForm')) {
|
||||||
var formData = layui.form.val('addProxyForm');
|
var formData = layui.form.val('proxyForm');
|
||||||
var $items = $('#addProxyForm .extra-param-tab-item .extra-param-item');
|
var $items = $('#proxyForm .extra-param-tab-item .extra-param-item');
|
||||||
$items.each(function () {
|
$items.each(function () {
|
||||||
var name = $(this).find('input').first().val();
|
var name = $(this).find('input').first().val();
|
||||||
var value = $(this).find('input').last().val();
|
var value = $(this).find('input').last().val();
|
||||||
formData[name] = value;
|
formData[name] = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
addOrUpdate(formData, index, update);
|
addOrUpdate(formData, index, update);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -202,19 +245,19 @@ var loadProxyInfo = (function ($) {
|
|||||||
},
|
},
|
||||||
success: function (layero, index, that) {
|
success: function (layero, index, that) {
|
||||||
//get and set old name for update form
|
//get and set old name for update form
|
||||||
var oldNameKey = layero.find('#oldName').attr('name');
|
var originalNameKey = layero.find('#originalNameKey').attr('name');
|
||||||
basicData[oldNameKey] = basicData.name;
|
basicData[originalNameKey] = basicData.name;
|
||||||
layui.form.val('addProxyForm', basicData);
|
layui.form.val('proxyForm', flatJSON(basicData));
|
||||||
proxyPopupSuccess();
|
proxyPopupSuccess();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function proxyPopupSuccess() {
|
function proxyPopupSuccess() {
|
||||||
layui.form.render(null, 'addProxyForm');
|
layui.form.render(null, 'proxyForm');
|
||||||
layui.form.on('input-affix(addition)', function (obj) {
|
layui.form.on('input-affix(addition)', function (obj) {
|
||||||
var $paramValue = $(obj.elem);
|
var $paramValue = $(obj.elem);
|
||||||
var $paramName = $paramValue.closest('.layui-form-item').find('input');
|
var $paramName = $paramValue.closest('.layui-form-item').find('input[type=text]');
|
||||||
var name = $paramName.first().val();
|
var name = $paramName.first().val();
|
||||||
var value = $paramValue.val();
|
var value = $paramValue.val();
|
||||||
var html = document.getElementById('extraParamAddedTemplate').innerHTML;
|
var html = document.getElementById('extraParamAddedTemplate').innerHTML;
|
||||||
@@ -241,18 +284,66 @@ var loadProxyInfo = (function ($) {
|
|||||||
* @param update update flag. true - update, false - add
|
* @param update update flag. true - update, false - add
|
||||||
*/
|
*/
|
||||||
function addOrUpdate(data, index, update) {
|
function addOrUpdate(data, index, update) {
|
||||||
var loading = layui.layer.load();
|
try {
|
||||||
var url = '';
|
var originalNameKey = $('#originalNameKey').attr('name');
|
||||||
if (update) {
|
var proxies = clientConfig.proxies;
|
||||||
url = '/update';
|
if (update) {
|
||||||
} else {
|
for (var i = 0; i < proxies.length; i++) {
|
||||||
url = '/add?type=' + currentProxyType;
|
if (data[originalNameKey] === proxies[i].name) {
|
||||||
|
delete data[originalNameKey];
|
||||||
|
proxies[i] = expandJSON(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
proxies.push(expandJSON(data));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
layui.layer.msg(e.message);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFrpcConfig(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* batch remove proxy popup
|
||||||
|
* @param data {[Map<string,string>]} proxy data list
|
||||||
|
*/
|
||||||
|
function batchRemovePopup(data) {
|
||||||
|
if (data.length === 0) {
|
||||||
|
layui.layer.msg(i18n['ShouldCheckProxy']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
layui.layer.confirm(i18n['ConfirmRemoveProxy'], {
|
||||||
|
title: i18n['OperationConfirm'],
|
||||||
|
btn: [i18n['Confirm'], i18n['Cancel']]
|
||||||
|
}, function (index) {
|
||||||
|
layui.layer.close(index);
|
||||||
|
var proxies = clientConfig.proxies;
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
proxies.forEach(function (proxy, j) {
|
||||||
|
if (data[i].name === proxy.name) {
|
||||||
|
proxies.splice(j, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFrpcConfig(index);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update frpc's config
|
||||||
|
* @param index popup index
|
||||||
|
*/
|
||||||
|
function updateFrpcConfig(index) {
|
||||||
|
var loading = layui.layer.load();
|
||||||
|
var content = TOML.stringify(clientConfig);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: '/update',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
contentType: 'application/json',
|
contentType: 'text/plain',
|
||||||
data: JSON.stringify(data),
|
data: content,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
layui.layer.close(index);
|
layui.layer.close(index);
|
||||||
@@ -272,59 +363,11 @@ var loadProxyInfo = (function ($) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* batch remove proxy popup
|
|
||||||
* @param data {[Map<string,string>]} proxy data list
|
|
||||||
*/
|
|
||||||
function batchRemovePopup(data) {
|
|
||||||
if (data.length === 0) {
|
|
||||||
layui.layer.msg(i18n['ShouldCheckProxy']);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
data.forEach(function (temp) {
|
|
||||||
for (var key in temp) {
|
|
||||||
if (typeof temp[key] === 'boolean') {
|
|
||||||
temp[key] = temp[key] + '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
layui.layer.confirm(i18n['ConfirmRemoveProxy'], {
|
|
||||||
title: i18n['OperationConfirm'],
|
|
||||||
btn: [i18n['Confirm'], i18n['Cancel']]
|
|
||||||
}, function (index) {
|
|
||||||
layui.layer.close(index);
|
|
||||||
|
|
||||||
var loading = layui.layer.load();
|
|
||||||
$.post({
|
|
||||||
url: '/remove',
|
|
||||||
type: 'post',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify(data),
|
|
||||||
success: function (result) {
|
|
||||||
if (result.success) {
|
|
||||||
layui.layer.close(index);
|
|
||||||
reloadTable();
|
|
||||||
layui.layer.msg(i18n['OperateSuccess']);
|
|
||||||
} else {
|
|
||||||
errorMsg(result);
|
|
||||||
if (result.code === 5) {
|
|
||||||
layui.layer.close(index);
|
|
||||||
reloadTable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
complete: function () {
|
|
||||||
layui.layer.close(loading);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reload proxy table
|
* reload proxy table
|
||||||
*/
|
*/
|
||||||
function reloadTable() {
|
function reloadTable() {
|
||||||
loadProxyInfo(null, null, null);
|
loadProxyInfo(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
var loadOverview = (function ($) {
|
var loadOverview = (function ($) {
|
||||||
var i18n = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get proxy info
|
* get proxy info
|
||||||
* @param lang {{}} language json
|
|
||||||
* @param title page title
|
* @param title page title
|
||||||
*/
|
*/
|
||||||
function loadOverview(lang, title) {
|
function loadOverview(title) {
|
||||||
i18n = lang;
|
|
||||||
$("#title").text(title);
|
$("#title").text(title);
|
||||||
$('#content').empty();
|
$('#content').empty();
|
||||||
var loading = layui.layer.load();
|
var loading = layui.layer.load();
|
||||||
@@ -63,7 +59,11 @@ var loadOverview = (function ($) {
|
|||||||
text: {none: i18n['EmptyData']},
|
text: {none: i18n['EmptyData']},
|
||||||
cols: [cols],
|
cols: [cols],
|
||||||
page: {
|
page: {
|
||||||
layout: navigator.language.indexOf("zh") === -1 ? ['first', 'prev', 'next', 'last'] : ['prev', 'page', 'next', 'skip', 'count', 'limit']
|
limitTemplet: function (item) {
|
||||||
|
return item + i18n['PerPage'];
|
||||||
|
},
|
||||||
|
skipText: [i18n['Goto'], '', i18n['Confirm']],
|
||||||
|
countText: [i18n['Total'], i18n['Items']]
|
||||||
},
|
},
|
||||||
data: dataList,
|
data: dataList,
|
||||||
initSort: {
|
initSort: {
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
window.clientConfig = {};
|
||||||
|
window.i18n = {};
|
||||||
(function ($) {
|
(function ($) {
|
||||||
$(function () {
|
$(function () {
|
||||||
function init() {
|
function init() {
|
||||||
var langLoading = layui.layer.load()
|
var langLoading = layui.layer.load()
|
||||||
$.getJSON('/lang.json').done(function (lang) {
|
$.getJSON('/lang.json').done(function (lang) {
|
||||||
|
window.i18n = lang;
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
error: function (xhr,) {
|
error: function (xhr,) {
|
||||||
if (xhr.status === 401) {
|
if (xhr.status === 401) {
|
||||||
@@ -17,13 +20,13 @@
|
|||||||
var id = elem.attr('id');
|
var id = elem.attr('id');
|
||||||
var title = elem.text();
|
var title = elem.text();
|
||||||
if (id === 'clientInfo') {
|
if (id === 'clientInfo') {
|
||||||
loadClientInfo(lang, title.trim());
|
loadClientInfo(title.trim());
|
||||||
} else if (id === 'overview') {
|
} else if (id === 'overview') {
|
||||||
loadOverview(lang, title.trim());
|
loadOverview(title.trim());
|
||||||
} else if (elem.closest('.layui-nav-item').attr('id') === 'proxies') {
|
} else if (elem.closest('.layui-nav-item').attr('id') === 'proxies') {
|
||||||
if (id != null && id.trim() !== '') {
|
if (id != null && id.trim() !== '') {
|
||||||
var suffix = elem.closest('.layui-nav-item').children('a').text().trim();
|
var suffix = elem.closest('.layui-nav-item').children('a').text().trim();
|
||||||
loadProxyInfo(lang, title + " " + suffix, id);
|
loadProxyInfo(title + " " + suffix, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -34,6 +37,45 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add verify rule to layui.form
|
||||||
|
*/
|
||||||
|
function initFormVerifyRule() {
|
||||||
|
layui.form.verify({
|
||||||
|
proxyName: function (value, elem) {
|
||||||
|
if (value.trim() === '') {
|
||||||
|
var nameI18n = $('#proxyName').closest('.layui-form-item').children('.layui-form-label').text();
|
||||||
|
return nameI18n + i18n['RequireNotEmpty'];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
localPort: function (value, elem) {
|
||||||
|
if (value !== '' && !/^\d+$/.test(value)) {
|
||||||
|
var nameI18n = $('#localPort').closest('.layui-form-item').children('.layui-form-label').text();
|
||||||
|
return nameI18n + i18n['RequireNumber'];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
domain: function (value, elem) {
|
||||||
|
var proxyType = $('#proxyType').val().toLowerCase();
|
||||||
|
var $customDomains = $('#customDomains');
|
||||||
|
var customDomains = $customDomains.val();
|
||||||
|
var $subdomain = $('#subdomain');
|
||||||
|
var subdomain = $subdomain.val();
|
||||||
|
if (proxyType === 'http' || proxyType === 'https') {
|
||||||
|
if (customDomains.trim() === '' && subdomain.trim() === '') {
|
||||||
|
var customDomainsNameI18n = $customDomains.closest('.layui-form-item').children('.layui-form-label').text();
|
||||||
|
var subdomainNameI18n = $subdomain.closest('.layui-form-item').children('.layui-form-label').text();
|
||||||
|
return customDomainsNameI18n + i18n['and'] + subdomainNameI18n + i18n['RequireNotAllEmpty'];
|
||||||
|
} else if (customDomains.trim() !== '') {
|
||||||
|
var nameI18n = $customDomains.closest('.layui-form-item').children('.layui-form-label').text();
|
||||||
|
if (!/^\s*\[.*]\s*$/.test(customDomains)) {
|
||||||
|
return nameI18n + i18n['RequireArray'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
$.get("/logout", function (result) {
|
$.get("/logout", function (result) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
@@ -45,5 +87,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
initFormVerifyRule();
|
||||||
});
|
});
|
||||||
})(layui.$);
|
})(layui.$);
|
||||||
210
assets/static/js/json-process.js
Normal file
210
assets/static/js/json-process.js
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
(function ($) {
|
||||||
|
//param names in Basic tab
|
||||||
|
var basicParams = [
|
||||||
|
{
|
||||||
|
name: 'name',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'type',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'localIP',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'localPort',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'customDomains',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'subdomain',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'remotePort',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'transport.useEncryption',
|
||||||
|
defaultValue: false,
|
||||||
|
}, {
|
||||||
|
name: 'transport.useCompression',
|
||||||
|
defaultValue: false,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
var mapParams = [{
|
||||||
|
name: 'plugin.ClientPluginOptions',
|
||||||
|
map: 'plugin'
|
||||||
|
}];
|
||||||
|
var paramTypes = {
|
||||||
|
number: [
|
||||||
|
'healthCheck.timeoutSeconds',
|
||||||
|
'healthCheck.maxFailed',
|
||||||
|
'healthCheck.intervalSeconds',
|
||||||
|
'localPort',
|
||||||
|
'remotePort'
|
||||||
|
],
|
||||||
|
boolean: [
|
||||||
|
'transport.useEncryption',
|
||||||
|
'transport.useCompression'
|
||||||
|
],
|
||||||
|
array: [
|
||||||
|
'customDomains',
|
||||||
|
'locations',
|
||||||
|
'allowUsers'
|
||||||
|
],
|
||||||
|
map: [
|
||||||
|
'metadatas',
|
||||||
|
'requestHeaders.set',
|
||||||
|
'plugin.ClientPluginOptions.requestHeaders.set'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a.b.c = 1
|
||||||
|
* a.b.d = [2,3]
|
||||||
|
* to
|
||||||
|
* {a: {
|
||||||
|
* b: {
|
||||||
|
* c: 1
|
||||||
|
* d: "[2,3]"
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @param obj json object
|
||||||
|
* @param keys all keys split from key string like 'a.b.c'
|
||||||
|
* @param value default value
|
||||||
|
* @param stringifyArray if true, when value is an array, it will stringify by JSON.stringify(value)
|
||||||
|
*/
|
||||||
|
function expandJSONKeys(obj, keys, value, stringifyArray) {
|
||||||
|
stringifyArray = stringifyArray == null ? true : stringifyArray;
|
||||||
|
var currentIndex = this.index || 0;
|
||||||
|
var childrenIndex = (currentIndex + 1) > keys.length ? null : (currentIndex + 1);
|
||||||
|
var currentKey = keys[currentIndex], currentValue = {};
|
||||||
|
var childrenKey = childrenIndex == null ? null : keys[childrenIndex];
|
||||||
|
if (obj.hasOwnProperty(currentKey)) {
|
||||||
|
currentValue = obj[currentKey];
|
||||||
|
} else {
|
||||||
|
obj[currentKey] = currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (childrenKey != null) {
|
||||||
|
this.index = childrenIndex;
|
||||||
|
expandJSONKeys(currentValue, keys, value, stringifyArray);
|
||||||
|
} else {
|
||||||
|
if (value != null) {
|
||||||
|
if (Array.isArray(value) && stringifyArray) {
|
||||||
|
obj[currentKey] = JSON.stringify(value);
|
||||||
|
} else {
|
||||||
|
obj[currentKey] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.index = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function expandJSON(obj) {
|
||||||
|
var newObj = {};
|
||||||
|
var inPopup = $('#proxyForm').length !== 0;
|
||||||
|
for (var name in obj) {
|
||||||
|
var value = obj[name];
|
||||||
|
if (value === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var nameI18n = name;
|
||||||
|
if (inPopup) {
|
||||||
|
nameI18n = $('#proxyForm [name="' + name + '"]').closest('.layui-form-item').children('.layui-form-label').text();
|
||||||
|
if (nameI18n === '') {
|
||||||
|
nameI18n = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paramTypes.number.indexOf(name) !== -1) {
|
||||||
|
value = parseInt(value);
|
||||||
|
if (isNaN(value)) {
|
||||||
|
throw new Error(nameI18n + i18n['RequireNumber']);
|
||||||
|
}
|
||||||
|
} else if (paramTypes.boolean.indexOf(name) !== -1) {
|
||||||
|
if (typeof value === "string" && (value === 'true' || value === 'false')) {
|
||||||
|
value = value === 'true';
|
||||||
|
} else if (typeof value !== 'boolean') {
|
||||||
|
throw new Error(nameI18n + i18n['RequireBoolean']);
|
||||||
|
}
|
||||||
|
} else if (paramTypes.array.indexOf(name) !== -1) {
|
||||||
|
try {
|
||||||
|
if (/^\s*\[.*]\s*$/.test(value)) {
|
||||||
|
value = eval('(' + value + ')') || [];
|
||||||
|
} else {
|
||||||
|
throw new Error('value format incorrect');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(nameI18n + i18n['RequireArray']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < paramTypes.map.length; i++) {
|
||||||
|
var key = paramTypes.map[i];
|
||||||
|
if (name.startsWith(key)) {
|
||||||
|
var json = {};
|
||||||
|
json[name.substring(key.length + 1, name.length)] = value;
|
||||||
|
value = json;
|
||||||
|
name = name.substring(0, key.length)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expandJSONKeys(newObj, name.split("."), value, false);
|
||||||
|
}
|
||||||
|
return newObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {a: {
|
||||||
|
* b: {
|
||||||
|
* c: 1
|
||||||
|
* d: [2,3]
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* to
|
||||||
|
* {
|
||||||
|
* 'a.b.c': 1,
|
||||||
|
* 'a.b.d': '[2,3]'
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @param obj json object
|
||||||
|
* @returns {*} flatted json key array
|
||||||
|
*/
|
||||||
|
function flatJSON(obj) {
|
||||||
|
var flat = function (obj, prentKey, flattedJSON) {
|
||||||
|
flattedJSON = flattedJSON || {};
|
||||||
|
prentKey = prentKey || '';
|
||||||
|
if (prentKey !== '')
|
||||||
|
prentKey = prentKey + '.';
|
||||||
|
for (var key in obj) {
|
||||||
|
var value = obj[key];
|
||||||
|
if (typeof value === 'object' && Object.prototype.toString.call(value) === '[object Object]') {
|
||||||
|
flat(value, prentKey + key, flattedJSON);
|
||||||
|
} else {
|
||||||
|
for (var mapParam of mapParams) {
|
||||||
|
if (prentKey.startsWith(mapParam.name)) {
|
||||||
|
prentKey = mapParam.map + '.';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
flattedJSON[prentKey + key] = JSON.stringify(value);
|
||||||
|
} else {
|
||||||
|
flattedJSON[prentKey + key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flattedJSON;
|
||||||
|
}
|
||||||
|
return flat(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.basicParams = basicParams;
|
||||||
|
window.expandJSONKeys = expandJSONKeys;
|
||||||
|
window.expandJSON = expandJSON;
|
||||||
|
window.flatJSON = flatJSON;
|
||||||
|
})(layui.$);
|
||||||
8337
assets/static/js/toml.js
Normal file
8337
assets/static/js/toml.js
Normal file
File diff suppressed because it is too large
Load Diff
344
assets/static/lib/codemirror/lib/codemirror.css
vendored
344
assets/static/lib/codemirror/lib/codemirror.css
vendored
@@ -1,344 +0,0 @@
|
|||||||
/* BASICS */
|
|
||||||
|
|
||||||
.CodeMirror {
|
|
||||||
/* Set height, width, borders, and global font properties here */
|
|
||||||
font-family: monospace;
|
|
||||||
height: 300px;
|
|
||||||
color: black;
|
|
||||||
direction: ltr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* PADDING */
|
|
||||||
|
|
||||||
.CodeMirror-lines {
|
|
||||||
padding: 4px 0; /* Vertical padding around content */
|
|
||||||
}
|
|
||||||
.CodeMirror pre.CodeMirror-line,
|
|
||||||
.CodeMirror pre.CodeMirror-line-like {
|
|
||||||
padding: 0 4px; /* Horizontal padding of content */
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
|
||||||
background-color: white; /* The little square between H and V scrollbars */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* GUTTER */
|
|
||||||
|
|
||||||
.CodeMirror-gutters {
|
|
||||||
border-right: 1px solid #ddd;
|
|
||||||
background-color: #f7f7f7;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.CodeMirror-linenumbers {}
|
|
||||||
.CodeMirror-linenumber {
|
|
||||||
padding: 0 3px 0 5px;
|
|
||||||
min-width: 20px;
|
|
||||||
text-align: right;
|
|
||||||
color: #999;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-guttermarker { color: black; }
|
|
||||||
.CodeMirror-guttermarker-subtle { color: #999; }
|
|
||||||
|
|
||||||
/* CURSOR */
|
|
||||||
|
|
||||||
.CodeMirror-cursor {
|
|
||||||
border-left: 1px solid black;
|
|
||||||
border-right: none;
|
|
||||||
width: 0;
|
|
||||||
}
|
|
||||||
/* Shown when moving in bi-directional text */
|
|
||||||
.CodeMirror div.CodeMirror-secondarycursor {
|
|
||||||
border-left: 1px solid silver;
|
|
||||||
}
|
|
||||||
.cm-fat-cursor .CodeMirror-cursor {
|
|
||||||
width: auto;
|
|
||||||
border: 0 !important;
|
|
||||||
background: #7e7;
|
|
||||||
}
|
|
||||||
.cm-fat-cursor div.CodeMirror-cursors {
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
.cm-fat-cursor .CodeMirror-line::selection,
|
|
||||||
.cm-fat-cursor .CodeMirror-line > span::selection,
|
|
||||||
.cm-fat-cursor .CodeMirror-line > span > span::selection { background: transparent; }
|
|
||||||
.cm-fat-cursor .CodeMirror-line::-moz-selection,
|
|
||||||
.cm-fat-cursor .CodeMirror-line > span::-moz-selection,
|
|
||||||
.cm-fat-cursor .CodeMirror-line > span > span::-moz-selection { background: transparent; }
|
|
||||||
.cm-fat-cursor { caret-color: transparent; }
|
|
||||||
@-moz-keyframes blink {
|
|
||||||
0% {}
|
|
||||||
50% { background-color: transparent; }
|
|
||||||
100% {}
|
|
||||||
}
|
|
||||||
@-webkit-keyframes blink {
|
|
||||||
0% {}
|
|
||||||
50% { background-color: transparent; }
|
|
||||||
100% {}
|
|
||||||
}
|
|
||||||
@keyframes blink {
|
|
||||||
0% {}
|
|
||||||
50% { background-color: transparent; }
|
|
||||||
100% {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Can style cursor different in overwrite (non-insert) mode */
|
|
||||||
.CodeMirror-overwrite .CodeMirror-cursor {}
|
|
||||||
|
|
||||||
.cm-tab { display: inline-block; text-decoration: inherit; }
|
|
||||||
|
|
||||||
.CodeMirror-rulers {
|
|
||||||
position: absolute;
|
|
||||||
left: 0; right: 0; top: -50px; bottom: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.CodeMirror-ruler {
|
|
||||||
border-left: 1px solid #ccc;
|
|
||||||
top: 0; bottom: 0;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* DEFAULT THEME */
|
|
||||||
|
|
||||||
.cm-s-default .cm-header {color: blue;}
|
|
||||||
.cm-s-default .cm-quote {color: #090;}
|
|
||||||
.cm-negative {color: #d44;}
|
|
||||||
.cm-positive {color: #292;}
|
|
||||||
.cm-header, .cm-strong {font-weight: bold;}
|
|
||||||
.cm-em {font-style: italic;}
|
|
||||||
.cm-link {text-decoration: underline;}
|
|
||||||
.cm-strikethrough {text-decoration: line-through;}
|
|
||||||
|
|
||||||
.cm-s-default .cm-keyword {color: #708;}
|
|
||||||
.cm-s-default .cm-atom {color: #219;}
|
|
||||||
.cm-s-default .cm-number {color: #164;}
|
|
||||||
.cm-s-default .cm-def {color: #00f;}
|
|
||||||
.cm-s-default .cm-variable,
|
|
||||||
.cm-s-default .cm-punctuation,
|
|
||||||
.cm-s-default .cm-property,
|
|
||||||
.cm-s-default .cm-operator {}
|
|
||||||
.cm-s-default .cm-variable-2 {color: #05a;}
|
|
||||||
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
|
|
||||||
.cm-s-default .cm-comment {color: #a50;}
|
|
||||||
.cm-s-default .cm-string {color: #a11;}
|
|
||||||
.cm-s-default .cm-string-2 {color: #f50;}
|
|
||||||
.cm-s-default .cm-meta {color: #555;}
|
|
||||||
.cm-s-default .cm-qualifier {color: #555;}
|
|
||||||
.cm-s-default .cm-builtin {color: #30a;}
|
|
||||||
.cm-s-default .cm-bracket {color: #997;}
|
|
||||||
.cm-s-default .cm-tag {color: #170;}
|
|
||||||
.cm-s-default .cm-attribute {color: #00c;}
|
|
||||||
.cm-s-default .cm-hr {color: #999;}
|
|
||||||
.cm-s-default .cm-link {color: #00c;}
|
|
||||||
|
|
||||||
.cm-s-default .cm-error {color: #f00;}
|
|
||||||
.cm-invalidchar {color: #f00;}
|
|
||||||
|
|
||||||
.CodeMirror-composing { border-bottom: 2px solid; }
|
|
||||||
|
|
||||||
/* Default styles for common addons */
|
|
||||||
|
|
||||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
|
|
||||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
|
||||||
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
|
||||||
.CodeMirror-activeline-background {background: #e8f2ff;}
|
|
||||||
|
|
||||||
/* STOP */
|
|
||||||
|
|
||||||
/* The rest of this file contains styles related to the mechanics of
|
|
||||||
the editor. You probably shouldn't touch them. */
|
|
||||||
|
|
||||||
.CodeMirror {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
background: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-scroll {
|
|
||||||
overflow: scroll !important; /* Things will break if this is overridden */
|
|
||||||
/* 50px is the magic margin used to hide the element's real scrollbars */
|
|
||||||
/* See overflow: hidden in .CodeMirror */
|
|
||||||
margin-bottom: -50px; margin-right: -50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
height: 100%;
|
|
||||||
outline: none; /* Prevent dragging from highlighting the element */
|
|
||||||
position: relative;
|
|
||||||
z-index: 0;
|
|
||||||
}
|
|
||||||
.CodeMirror-sizer {
|
|
||||||
position: relative;
|
|
||||||
border-right: 50px solid transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
|
||||||
before actual scrolling happens, thus preventing shaking and
|
|
||||||
flickering artifacts. */
|
|
||||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 6;
|
|
||||||
display: none;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
.CodeMirror-vscrollbar {
|
|
||||||
right: 0; top: 0;
|
|
||||||
overflow-x: hidden;
|
|
||||||
overflow-y: scroll;
|
|
||||||
}
|
|
||||||
.CodeMirror-hscrollbar {
|
|
||||||
bottom: 0; left: 0;
|
|
||||||
overflow-y: hidden;
|
|
||||||
overflow-x: scroll;
|
|
||||||
}
|
|
||||||
.CodeMirror-scrollbar-filler {
|
|
||||||
right: 0; bottom: 0;
|
|
||||||
}
|
|
||||||
.CodeMirror-gutter-filler {
|
|
||||||
left: 0; bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-gutters {
|
|
||||||
position: absolute; left: 0; top: 0;
|
|
||||||
min-height: 100%;
|
|
||||||
z-index: 3;
|
|
||||||
}
|
|
||||||
.CodeMirror-gutter {
|
|
||||||
white-space: normal;
|
|
||||||
height: 100%;
|
|
||||||
display: inline-block;
|
|
||||||
vertical-align: top;
|
|
||||||
margin-bottom: -50px;
|
|
||||||
}
|
|
||||||
.CodeMirror-gutter-wrapper {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 4;
|
|
||||||
background: none !important;
|
|
||||||
border: none !important;
|
|
||||||
}
|
|
||||||
.CodeMirror-gutter-background {
|
|
||||||
position: absolute;
|
|
||||||
top: 0; bottom: 0;
|
|
||||||
z-index: 4;
|
|
||||||
}
|
|
||||||
.CodeMirror-gutter-elt {
|
|
||||||
position: absolute;
|
|
||||||
cursor: default;
|
|
||||||
z-index: 4;
|
|
||||||
}
|
|
||||||
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
|
|
||||||
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
|
|
||||||
|
|
||||||
.CodeMirror-lines {
|
|
||||||
cursor: text;
|
|
||||||
min-height: 1px; /* prevents collapsing before first draw */
|
|
||||||
}
|
|
||||||
.CodeMirror pre.CodeMirror-line,
|
|
||||||
.CodeMirror pre.CodeMirror-line-like {
|
|
||||||
/* Reset some styles that the rest of the page might have set */
|
|
||||||
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
|
||||||
border-width: 0;
|
|
||||||
background: transparent;
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: inherit;
|
|
||||||
margin: 0;
|
|
||||||
white-space: pre;
|
|
||||||
word-wrap: normal;
|
|
||||||
line-height: inherit;
|
|
||||||
color: inherit;
|
|
||||||
z-index: 2;
|
|
||||||
position: relative;
|
|
||||||
overflow: visible;
|
|
||||||
-webkit-tap-highlight-color: transparent;
|
|
||||||
-webkit-font-variant-ligatures: contextual;
|
|
||||||
font-variant-ligatures: contextual;
|
|
||||||
}
|
|
||||||
.CodeMirror-wrap pre.CodeMirror-line,
|
|
||||||
.CodeMirror-wrap pre.CodeMirror-line-like {
|
|
||||||
word-wrap: break-word;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-break: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-linebackground {
|
|
||||||
position: absolute;
|
|
||||||
left: 0; right: 0; top: 0; bottom: 0;
|
|
||||||
z-index: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-linewidget {
|
|
||||||
position: relative;
|
|
||||||
z-index: 2;
|
|
||||||
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-widget {}
|
|
||||||
|
|
||||||
.CodeMirror-rtl pre { direction: rtl; }
|
|
||||||
|
|
||||||
.CodeMirror-code {
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Force content-box sizing for the elements where we expect it */
|
|
||||||
.CodeMirror-scroll,
|
|
||||||
.CodeMirror-sizer,
|
|
||||||
.CodeMirror-gutter,
|
|
||||||
.CodeMirror-gutters,
|
|
||||||
.CodeMirror-linenumber {
|
|
||||||
-moz-box-sizing: content-box;
|
|
||||||
box-sizing: content-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-measure {
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-cursor {
|
|
||||||
position: absolute;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
.CodeMirror-measure pre { position: static; }
|
|
||||||
|
|
||||||
div.CodeMirror-cursors {
|
|
||||||
visibility: hidden;
|
|
||||||
position: relative;
|
|
||||||
z-index: 3;
|
|
||||||
}
|
|
||||||
div.CodeMirror-dragcursors {
|
|
||||||
visibility: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-focused div.CodeMirror-cursors {
|
|
||||||
visibility: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-selected { background: #d9d9d9; }
|
|
||||||
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
|
||||||
.CodeMirror-crosshair { cursor: crosshair; }
|
|
||||||
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
|
|
||||||
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
|
||||||
|
|
||||||
.cm-searching {
|
|
||||||
background-color: #ffa;
|
|
||||||
background-color: rgba(255, 255, 0, .4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Used to force a border model for a node */
|
|
||||||
.cm-force-border { padding-right: .1px; }
|
|
||||||
|
|
||||||
@media print {
|
|
||||||
/* Hide the cursor when printing */
|
|
||||||
.CodeMirror div.CodeMirror-cursors {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* See issue #2901 */
|
|
||||||
.cm-tab-wrap-hack:after { content: ''; }
|
|
||||||
|
|
||||||
/* Help users use markselection to safely style text background */
|
|
||||||
span.CodeMirror-selectedtext { background: none; }
|
|
||||||
9874
assets/static/lib/codemirror/lib/codemirror.js
vendored
9874
assets/static/lib/codemirror/lib/codemirror.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,53 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: Properties files mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="properties.js"></script>
|
|
||||||
<style>.CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror5">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">Properties files</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>Properties files mode</h2>
|
|
||||||
<form><textarea id="code" name="code">
|
|
||||||
# This is a properties file
|
|
||||||
a.key = A value
|
|
||||||
another.key = http://example.com
|
|
||||||
! Exclamation mark as comment
|
|
||||||
but.not=Within ! A value # indeed
|
|
||||||
# Spaces at the beginning of a line
|
|
||||||
spaces.before.key=value
|
|
||||||
backslash=Used for multi\
|
|
||||||
line entries,\
|
|
||||||
that's convenient.
|
|
||||||
# Unicode sequences
|
|
||||||
unicode.key=This is \u0020 Unicode
|
|
||||||
no.multiline=here
|
|
||||||
# Colons
|
|
||||||
colons : can be used too
|
|
||||||
# Spaces
|
|
||||||
spaces\ in\ keys=Not very common...
|
|
||||||
</textarea></form>
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p><strong>MIME types defined:</strong> <code>text/x-properties</code>,
|
|
||||||
<code>text/x-ini</code>.</p>
|
|
||||||
|
|
||||||
</article>
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
||||||
|
|
||||||
(function(mod) {
|
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
||||||
mod(require("../../lib/codemirror"));
|
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
|
||||||
define(["../../lib/codemirror"], mod);
|
|
||||||
else // Plain browser env
|
|
||||||
mod(CodeMirror);
|
|
||||||
})(function(CodeMirror) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
CodeMirror.defineMode("properties", function() {
|
|
||||||
return {
|
|
||||||
token: function(stream, state) {
|
|
||||||
var sol = stream.sol() || state.afterSection;
|
|
||||||
var eol = stream.eol();
|
|
||||||
|
|
||||||
state.afterSection = false;
|
|
||||||
|
|
||||||
if (sol) {
|
|
||||||
if (state.nextMultiline) {
|
|
||||||
state.inMultiline = true;
|
|
||||||
state.nextMultiline = false;
|
|
||||||
} else {
|
|
||||||
state.position = "def";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eol && ! state.nextMultiline) {
|
|
||||||
state.inMultiline = false;
|
|
||||||
state.position = "def";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sol) {
|
|
||||||
while(stream.eatSpace()) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
var ch = stream.next();
|
|
||||||
|
|
||||||
if (sol && (ch === "#" || ch === "!" || ch === ";")) {
|
|
||||||
state.position = "comment";
|
|
||||||
stream.skipToEnd();
|
|
||||||
return "comment";
|
|
||||||
} else if (sol && ch === "[") {
|
|
||||||
state.afterSection = true;
|
|
||||||
stream.skipTo("]"); stream.eat("]");
|
|
||||||
return "header";
|
|
||||||
} else if (ch === "=" || ch === ":") {
|
|
||||||
state.position = "quote";
|
|
||||||
return null;
|
|
||||||
} else if (ch === "\\" && state.position === "quote") {
|
|
||||||
if (stream.eol()) { // end of line?
|
|
||||||
// Multiline value
|
|
||||||
state.nextMultiline = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return state.position;
|
|
||||||
},
|
|
||||||
|
|
||||||
startState: function() {
|
|
||||||
return {
|
|
||||||
position : "def", // Current position, "def", "quote" or "comment"
|
|
||||||
nextMultiline : false, // Is the next line multiline value
|
|
||||||
inMultiline : false, // Is the current line a multiline value
|
|
||||||
afterSection : false // Did we just open a section
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/x-properties", "properties");
|
|
||||||
CodeMirror.defineMIME("text/x-ini", "properties");
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: TOML Mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="toml.js"></script>
|
|
||||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror5">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">TOML Mode</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>TOML Mode</h2>
|
|
||||||
<form><textarea id="code" name="code">
|
|
||||||
# This is a TOML document. Boom.
|
|
||||||
|
|
||||||
title = "TOML Example"
|
|
||||||
|
|
||||||
[owner]
|
|
||||||
name = "Tom Preston-Werner"
|
|
||||||
organization = "GitHub"
|
|
||||||
bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
|
|
||||||
dob = 1979-05-27T07:32:00Z # First class dates? Why not?
|
|
||||||
|
|
||||||
[database]
|
|
||||||
server = "192.168.1.1"
|
|
||||||
ports = [ 8001, 8001, 8002 ]
|
|
||||||
connection_max = 5000
|
|
||||||
enabled = true
|
|
||||||
|
|
||||||
[servers]
|
|
||||||
|
|
||||||
# You can indent as you please. Tabs or spaces. TOML don't care.
|
|
||||||
[servers.alpha]
|
|
||||||
ip = "10.0.0.1"
|
|
||||||
dc = "eqdc10"
|
|
||||||
|
|
||||||
[servers.beta]
|
|
||||||
ip = "10.0.0.2"
|
|
||||||
dc = "eqdc10"
|
|
||||||
|
|
||||||
[clients]
|
|
||||||
data = [ ["gamma", "delta"], [1, 2] ]
|
|
||||||
|
|
||||||
# Line breaks are OK when inside arrays
|
|
||||||
hosts = [
|
|
||||||
"alpha",
|
|
||||||
"omega"
|
|
||||||
]
|
|
||||||
</textarea></form>
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
mode: {name: "toml"},
|
|
||||||
lineNumbers: true
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<h3>The TOML Mode</h3>
|
|
||||||
<p> Created by Forbes Lindesay.</p>
|
|
||||||
<p><strong>MIME type defined:</strong> <code>text/x-toml</code>.</p>
|
|
||||||
</article>
|
|
||||||
88
assets/static/lib/codemirror/mode/toml/toml.js
vendored
88
assets/static/lib/codemirror/mode/toml/toml.js
vendored
@@ -1,88 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
||||||
|
|
||||||
(function(mod) {
|
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
||||||
mod(require("../../lib/codemirror"));
|
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
|
||||||
define(["../../lib/codemirror"], mod);
|
|
||||||
else // Plain browser env
|
|
||||||
mod(CodeMirror);
|
|
||||||
})(function(CodeMirror) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
CodeMirror.defineMode("toml", function () {
|
|
||||||
return {
|
|
||||||
startState: function () {
|
|
||||||
return {
|
|
||||||
inString: false,
|
|
||||||
stringType: "",
|
|
||||||
lhs: true,
|
|
||||||
inArray: 0
|
|
||||||
};
|
|
||||||
},
|
|
||||||
token: function (stream, state) {
|
|
||||||
//check for state changes
|
|
||||||
if (!state.inString && ((stream.peek() == '"') || (stream.peek() == "'"))) {
|
|
||||||
state.stringType = stream.peek();
|
|
||||||
stream.next(); // Skip quote
|
|
||||||
state.inString = true; // Update state
|
|
||||||
}
|
|
||||||
if (stream.sol() && state.inArray === 0) {
|
|
||||||
state.lhs = true;
|
|
||||||
}
|
|
||||||
//return state
|
|
||||||
if (state.inString) {
|
|
||||||
while (state.inString && !stream.eol()) {
|
|
||||||
if (stream.peek() === state.stringType) {
|
|
||||||
stream.next(); // Skip quote
|
|
||||||
state.inString = false; // Clear flag
|
|
||||||
} else if (stream.peek() === '\\') {
|
|
||||||
stream.next();
|
|
||||||
stream.next();
|
|
||||||
} else {
|
|
||||||
stream.match(/^.[^\\\"\']*/);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return state.lhs ? "property string" : "string"; // Token style
|
|
||||||
} else if (state.inArray && stream.peek() === ']') {
|
|
||||||
stream.next();
|
|
||||||
state.inArray--;
|
|
||||||
return 'bracket';
|
|
||||||
} else if (state.lhs && stream.peek() === '[' && stream.skipTo(']')) {
|
|
||||||
stream.next();//skip closing ]
|
|
||||||
// array of objects has an extra open & close []
|
|
||||||
if (stream.peek() === ']') stream.next();
|
|
||||||
return "atom";
|
|
||||||
} else if (stream.peek() === "#") {
|
|
||||||
stream.skipToEnd();
|
|
||||||
return "comment";
|
|
||||||
} else if (stream.eatSpace()) {
|
|
||||||
return null;
|
|
||||||
} else if (state.lhs && stream.eatWhile(function (c) { return c != '=' && c != ' '; })) {
|
|
||||||
return "property";
|
|
||||||
} else if (state.lhs && stream.peek() === "=") {
|
|
||||||
stream.next();
|
|
||||||
state.lhs = false;
|
|
||||||
return null;
|
|
||||||
} else if (!state.lhs && stream.match(/^\d\d\d\d[\d\-\:\.T]*Z/)) {
|
|
||||||
return 'atom'; //date
|
|
||||||
} else if (!state.lhs && (stream.match('true') || stream.match('false'))) {
|
|
||||||
return 'atom';
|
|
||||||
} else if (!state.lhs && stream.peek() === '[') {
|
|
||||||
state.inArray++;
|
|
||||||
stream.next();
|
|
||||||
return 'bracket';
|
|
||||||
} else if (!state.lhs && stream.match(/^\-?\d+(?:\.\d+)?/)) {
|
|
||||||
return 'number';
|
|
||||||
} else if (!stream.eatSpace()) {
|
|
||||||
stream.next();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.defineMIME('text/x-toml', 'toml');
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: YAML mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="yaml.js"></script>
|
|
||||||
<style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror5">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">YAML</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>YAML mode</h2>
|
|
||||||
<form><textarea id="code" name="code">
|
|
||||||
--- # Favorite movies
|
|
||||||
- Casablanca
|
|
||||||
- North by Northwest
|
|
||||||
- The Man Who Wasn't There
|
|
||||||
--- # Shopping list
|
|
||||||
[milk, pumpkin pie, eggs, juice]
|
|
||||||
--- # Indented Blocks, common in YAML data files, use indentation and new lines to separate the key: value pairs
|
|
||||||
name: John Smith
|
|
||||||
age: 33
|
|
||||||
--- # Inline Blocks, common in YAML data streams, use commas to separate the key: value pairs between braces
|
|
||||||
{name: John Smith, age: 33}
|
|
||||||
---
|
|
||||||
receipt: Oz-Ware Purchase Invoice
|
|
||||||
date: 2007-08-06
|
|
||||||
customer:
|
|
||||||
given: Dorothy
|
|
||||||
family: Gale
|
|
||||||
|
|
||||||
items:
|
|
||||||
- part_no: A4786
|
|
||||||
descrip: Water Bucket (Filled)
|
|
||||||
price: 1.47
|
|
||||||
quantity: 4
|
|
||||||
|
|
||||||
- part_no: E1628
|
|
||||||
descrip: High Heeled "Ruby" Slippers
|
|
||||||
size: 8
|
|
||||||
price: 100.27
|
|
||||||
quantity: 1
|
|
||||||
|
|
||||||
bill-to: &id001
|
|
||||||
street: |
|
|
||||||
123 Tornado Alley
|
|
||||||
Suite 16
|
|
||||||
city: East Centerville
|
|
||||||
state: KS
|
|
||||||
|
|
||||||
ship-to: *id001
|
|
||||||
|
|
||||||
specialDelivery: >
|
|
||||||
Follow the Yellow Brick
|
|
||||||
Road to the Emerald City.
|
|
||||||
Pay no attention to the
|
|
||||||
man behind the curtain.
|
|
||||||
...
|
|
||||||
</textarea></form>
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p><strong>MIME types defined:</strong> <code>text/x-yaml</code>.</p>
|
|
||||||
|
|
||||||
</article>
|
|
||||||
120
assets/static/lib/codemirror/mode/yaml/yaml.js
vendored
120
assets/static/lib/codemirror/mode/yaml/yaml.js
vendored
@@ -1,120 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
||||||
|
|
||||||
(function(mod) {
|
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
||||||
mod(require("../../lib/codemirror"));
|
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
|
||||||
define(["../../lib/codemirror"], mod);
|
|
||||||
else // Plain browser env
|
|
||||||
mod(CodeMirror);
|
|
||||||
})(function(CodeMirror) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
CodeMirror.defineMode("yaml", function() {
|
|
||||||
|
|
||||||
var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
|
|
||||||
var keywordRegex = new RegExp("\\b(("+cons.join(")|(")+"))$", 'i');
|
|
||||||
|
|
||||||
return {
|
|
||||||
token: function(stream, state) {
|
|
||||||
var ch = stream.peek();
|
|
||||||
var esc = state.escaped;
|
|
||||||
state.escaped = false;
|
|
||||||
/* comments */
|
|
||||||
if (ch == "#" && (stream.pos == 0 || /\s/.test(stream.string.charAt(stream.pos - 1)))) {
|
|
||||||
stream.skipToEnd();
|
|
||||||
return "comment";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stream.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))
|
|
||||||
return "string";
|
|
||||||
|
|
||||||
if (state.literal && stream.indentation() > state.keyCol) {
|
|
||||||
stream.skipToEnd(); return "string";
|
|
||||||
} else if (state.literal) { state.literal = false; }
|
|
||||||
if (stream.sol()) {
|
|
||||||
state.keyCol = 0;
|
|
||||||
state.pair = false;
|
|
||||||
state.pairStart = false;
|
|
||||||
/* document start */
|
|
||||||
if(stream.match('---')) { return "def"; }
|
|
||||||
/* document end */
|
|
||||||
if (stream.match('...')) { return "def"; }
|
|
||||||
/* array list item */
|
|
||||||
if (stream.match(/\s*-\s+/)) { return 'meta'; }
|
|
||||||
}
|
|
||||||
/* inline pairs/lists */
|
|
||||||
if (stream.match(/^(\{|\}|\[|\])/)) {
|
|
||||||
if (ch == '{')
|
|
||||||
state.inlinePairs++;
|
|
||||||
else if (ch == '}')
|
|
||||||
state.inlinePairs--;
|
|
||||||
else if (ch == '[')
|
|
||||||
state.inlineList++;
|
|
||||||
else
|
|
||||||
state.inlineList--;
|
|
||||||
return 'meta';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* list separator */
|
|
||||||
if (state.inlineList > 0 && !esc && ch == ',') {
|
|
||||||
stream.next();
|
|
||||||
return 'meta';
|
|
||||||
}
|
|
||||||
/* pairs separator */
|
|
||||||
if (state.inlinePairs > 0 && !esc && ch == ',') {
|
|
||||||
state.keyCol = 0;
|
|
||||||
state.pair = false;
|
|
||||||
state.pairStart = false;
|
|
||||||
stream.next();
|
|
||||||
return 'meta';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* start of value of a pair */
|
|
||||||
if (state.pairStart) {
|
|
||||||
/* block literals */
|
|
||||||
if (stream.match(/^\s*(\||\>)\s*/)) { state.literal = true; return 'meta'; };
|
|
||||||
/* references */
|
|
||||||
if (stream.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i)) { return 'variable-2'; }
|
|
||||||
/* numbers */
|
|
||||||
if (state.inlinePairs == 0 && stream.match(/^\s*-?[0-9\.\,]+\s?$/)) { return 'number'; }
|
|
||||||
if (state.inlinePairs > 0 && stream.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/)) { return 'number'; }
|
|
||||||
/* keywords */
|
|
||||||
if (stream.match(keywordRegex)) { return 'keyword'; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* pairs (associative arrays) -> key */
|
|
||||||
if (!state.pair && stream.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^\s,\[\]{}#&*!|>'"%@`])[^#:]*(?=:($|\s))/)) {
|
|
||||||
state.pair = true;
|
|
||||||
state.keyCol = stream.indentation();
|
|
||||||
return "atom";
|
|
||||||
}
|
|
||||||
if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
|
|
||||||
|
|
||||||
/* nothing found, continue */
|
|
||||||
state.pairStart = false;
|
|
||||||
state.escaped = (ch == '\\');
|
|
||||||
stream.next();
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
startState: function() {
|
|
||||||
return {
|
|
||||||
pair: false,
|
|
||||||
pairStart: false,
|
|
||||||
keyCol: 0,
|
|
||||||
inlinePairs: 0,
|
|
||||||
inlineList: 0,
|
|
||||||
literal: false,
|
|
||||||
escaped: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
lineComment: "#",
|
|
||||||
fold: "indent"
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/x-yaml", "yaml");
|
|
||||||
CodeMirror.defineMIME("text/yaml", "yaml");
|
|
||||||
|
|
||||||
});
|
|
||||||
71
assets/static/lib/codemirror/theme/base16.css
vendored
71
assets/static/lib/codemirror/theme/base16.css
vendored
@@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Name: Base16 Default Light
|
|
||||||
Author: Chris Kempson (http://chriskempson.com)
|
|
||||||
|
|
||||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
|
||||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
.cm-s-base16.CodeMirror { background: #f5f5f5; color: #202020; }
|
|
||||||
.cm-s-base16 div.CodeMirror-selected { background: #e0e0e0; }
|
|
||||||
.cm-s-base16 .CodeMirror-line::selection, .cm-s-base16 .CodeMirror-line > span::selection, .cm-s-base16 .CodeMirror-line > span > span::selection { background: #e0e0e0; }
|
|
||||||
.cm-s-base16 .CodeMirror-line::-moz-selection, .cm-s-base16 .CodeMirror-line > span::-moz-selection, .cm-s-base16 .CodeMirror-line > span > span::-moz-selection { background: #e0e0e0; }
|
|
||||||
.cm-s-base16 .CodeMirror-gutters { background: #f5f5f5; border-right: 0px; }
|
|
||||||
.cm-s-base16 .CodeMirror-guttermarker { color: #ac4142; }
|
|
||||||
.cm-s-base16 .CodeMirror-guttermarker-subtle { color: #b0b0b0; }
|
|
||||||
.cm-s-base16 .CodeMirror-linenumber { color: #b0b0b0; }
|
|
||||||
.cm-s-base16 .CodeMirror-cursor { border-left: 1px solid #505050; }
|
|
||||||
|
|
||||||
.cm-s-base16 span.cm-comment { color: #8f5536; }
|
|
||||||
.cm-s-base16 span.cm-atom { color: #aa759f; }
|
|
||||||
.cm-s-base16 span.cm-number { color: #aa759f; }
|
|
||||||
|
|
||||||
.cm-s-base16 span.cm-property, .cm-s-base16 span.cm-attribute { color: #90a959; }
|
|
||||||
.cm-s-base16 span.cm-keyword { color: #ac4142; }
|
|
||||||
.cm-s-base16 span.cm-string { color: #f4bf75; }
|
|
||||||
|
|
||||||
.cm-s-base16 span.cm-variable { color: #90a959; }
|
|
||||||
.cm-s-base16 span.cm-variable-2 { color: #6a9fb5; }
|
|
||||||
.cm-s-base16 span.cm-def { color: #d28445; }
|
|
||||||
.cm-s-base16 span.cm-bracket { color: #202020; }
|
|
||||||
.cm-s-base16 span.cm-tag { color: #ac4142; }
|
|
||||||
.cm-s-base16 span.cm-link { color: #aa759f; }
|
|
||||||
.cm-s-base16 span.cm-error { background: #ac4142; color: #505050; }
|
|
||||||
|
|
||||||
.cm-s-base16 .CodeMirror-activeline-background { background: #DDDCDC; }
|
|
||||||
.cm-s-base16 .CodeMirror-matchingbracket { color: #f5f5f5 !important; background-color: #6A9FB5 !important}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
.cm-s-base16.CodeMirror { background: #151515; color: #e0e0e0; }
|
|
||||||
.cm-s-base16 div.CodeMirror-selected { background: #303030; }
|
|
||||||
.cm-s-base16 .CodeMirror-line::selection, .cm-s-base16 .CodeMirror-line > span::selection, .cm-s-base16 .CodeMirror-line > span > span::selection { background: rgba(48, 48, 48, .99); }
|
|
||||||
.cm-s-base16 .CodeMirror-line::-moz-selection, .cm-s-base16 .CodeMirror-line > span::-moz-selection, .cm-s-base16 .CodeMirror-line > span > span::-moz-selection { background: rgba(48, 48, 48, .99); }
|
|
||||||
.cm-s-base16 .CodeMirror-gutters { background: #151515; border-right: 0px; }
|
|
||||||
.cm-s-base16 .CodeMirror-guttermarker { color: #ac4142; }
|
|
||||||
.cm-s-base16 .CodeMirror-guttermarker-subtle { color: #505050; }
|
|
||||||
.cm-s-base16 .CodeMirror-linenumber { color: #505050; }
|
|
||||||
.cm-s-base16 .CodeMirror-cursor { border-left: 1px solid #b0b0b0; }
|
|
||||||
.cm-s-base16.cm-fat-cursor .CodeMirror-cursor { background-color: #8e8d8875 !important; }
|
|
||||||
.cm-s-base16 .cm-animate-fat-cursor { background-color: #8e8d8875 !important; }
|
|
||||||
|
|
||||||
.cm-s-base16 span.cm-comment { color: #8f5536; }
|
|
||||||
.cm-s-base16 span.cm-atom { color: #aa759f; }
|
|
||||||
.cm-s-base16 span.cm-number { color: #aa759f; }
|
|
||||||
|
|
||||||
.cm-s-base16 span.cm-property, .cm-s-base16 span.cm-attribute { color: #90a959; }
|
|
||||||
.cm-s-base16 span.cm-keyword { color: #ac4142; }
|
|
||||||
.cm-s-base16 span.cm-string { color: #f4bf75; }
|
|
||||||
|
|
||||||
.cm-s-base16 span.cm-variable { color: #90a959; }
|
|
||||||
.cm-s-base16 span.cm-variable-2 { color: #6a9fb5; }
|
|
||||||
.cm-s-base16 span.cm-def { color: #d28445; }
|
|
||||||
.cm-s-base16 span.cm-bracket { color: #e0e0e0; }
|
|
||||||
.cm-s-base16 span.cm-tag { color: #ac4142; }
|
|
||||||
.cm-s-base16 span.cm-link { color: #aa759f; }
|
|
||||||
.cm-s-base16 span.cm-error { background: #ac4142; color: #b0b0b0; }
|
|
||||||
|
|
||||||
.cm-s-base16 .CodeMirror-activeline-background { background: #202020; }
|
|
||||||
.cm-s-base16 .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,28 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Title</title>
|
|
||||||
<link rel="stylesheet" href="../static/lib/codemirror/lib/codemirror.css">
|
|
||||||
<link rel="stylesheet" href="../static/lib/codemirror/theme/base16.css">
|
|
||||||
<script src="../static/lib/codemirror/lib/codemirror.js"></script>
|
|
||||||
<script src="../static/lib/codemirror/mode/properties/properties.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<a href="https://codemirror.net/5/doc/manual.html">https://codemirror.net/5/doc/manual.html</a>
|
|
||||||
<textarea id="code" name="code"></textarea>
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
mode: 'text/x-ini',
|
|
||||||
theme: 'base16'
|
|
||||||
});
|
|
||||||
editor.setValue(`
|
|
||||||
[HTTP:aaa.bbb.com]
|
|
||||||
a = 1
|
|
||||||
b = 2
|
|
||||||
`)
|
|
||||||
console.log(editor.getValue());
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
<link rel="stylesheet" href="./static/css/index.css?v=${ .version }">
|
<link rel="stylesheet" href="./static/css/index.css?v=${ .version }">
|
||||||
<link rel="stylesheet" href="./static/css/color.css?v=${ .version }">
|
<link rel="stylesheet" href="./static/css/color.css?v=${ .version }">
|
||||||
<script src="./static/lib/layui/layui.js?v=${ .version }"></script>
|
<script src="./static/lib/layui/layui.js?v=${ .version }"></script>
|
||||||
|
<script src="./static/js/toml.js?v=${ .version }"></script>
|
||||||
|
<script src="./static/js/json-process.js?v=${ .version }"></script>
|
||||||
<script src="./static/js/index-client-info.js?v=${ .version }"></script>
|
<script src="./static/js/index-client-info.js?v=${ .version }"></script>
|
||||||
<script src="./static/js/index-proxy-overview.js?v=${ .version }"></script>
|
<script src="./static/js/index-proxy-overview.js?v=${ .version }"></script>
|
||||||
<script src="./static/js/index-proxy-list.js?v=${ .version }"></script>
|
<script src="./static/js/index-proxy-list.js?v=${ .version }"></script>
|
||||||
@@ -144,51 +146,51 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--用户列表-添加用户表单模板-->
|
<!--用户列表-添加用户表单模板-->
|
||||||
<script type="text/html" id="addProxyTemplate">
|
<script type="text/html" id="proxyFormTemplate">
|
||||||
<form class="layui-form" id="addProxyForm" lay-filter="addProxyForm">
|
<form class="layui-form" id="proxyForm" lay-filter="proxyForm">
|
||||||
<div class="layui-tab layui-tab-brief">
|
<div class="layui-tab layui-tab-brief">
|
||||||
<ul class="layui-tab-title">
|
<ul class="layui-tab-title">
|
||||||
<li class="layui-this">${ .Basic }</li>
|
<li class="layui-this">${ .Basic }</li>
|
||||||
<li>${ .Extra }</li>
|
<li>${ .Extra }</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="layui-tab-content">
|
<div class="layui-tab-content">
|
||||||
<input type="hidden" name="type">
|
<input type="hidden" name="type" id="proxyType">
|
||||||
<input type="hidden" name="${ .OldNameKey }" id="oldName">
|
<input type="hidden" name="${ .OriginalNameKey }" id="originalNameKey">
|
||||||
<div class="layui-tab-item layui-show">
|
<div class="layui-tab-item layui-show">
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">${ .ProxyName }</label>
|
<label class="layui-form-label">${ .ProxyName }</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="text" name="name" placeholder="${ .ProxyName }" autocomplete="off"
|
<input type="text" name="name" id="proxyName" placeholder="${ .ProxyNameExample }"
|
||||||
class="layui-input"/>
|
autocomplete="off" class="layui-input" lay-verify="proxyName"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">${ .LocalIp }</label>
|
<label class="layui-form-label">${ .LocalIP }</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="text" name="local_ip" placeholder="${ .LocalIp }" autocomplete="off"
|
<input type="text" name="localIP" id="localIP" placeholder="${ .LocalIPExample }"
|
||||||
class="layui-input"/>
|
autocomplete="off" class="layui-input"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">${ .LocalPort }</label>
|
<label class="layui-form-label">${ .LocalPort }</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="text" name="local_port" placeholder="${ .LocalPort }" autocomplete="off"
|
<input type="text" name="localPort" id="localPort" placeholder="${ .LocalPortExample }"
|
||||||
class="layui-input"/>
|
autocomplete="off" class="layui-input" lay-verify="localPort"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{# if (d.type.toLowerCase() === 'http' || d.type.toLowerCase() === 'https') { }}
|
{{# if (d.type.toLowerCase() === 'http' || d.type.toLowerCase() === 'https') { }}
|
||||||
<div class="layui-form-item http https">
|
<div class="layui-form-item http https">
|
||||||
<label class="layui-form-label">${ .CustomDomains }</label>
|
<label class="layui-form-label">${ .CustomDomains }</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<textarea name="custom_domains" placeholder="${ .CustomDomains }" autocomplete="off"
|
<textarea name="customDomains" id="customDomains" placeholder="${ .CustomDomainsExample }"
|
||||||
class="layui-textarea"></textarea>
|
autocomplete="off" class="layui-textarea" lay-verify="domain"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item layui-form-text http https">
|
<div class="layui-form-item layui-form-text http https">
|
||||||
<label class="layui-form-label">${ .Subdomain }</label>
|
<label class="layui-form-label">${ .Subdomain }</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<textarea name="subdomain" placeholder="${ .Subdomain }" autocomplete="off"
|
<textarea name="subdomain" id="subdomain" placeholder="${ .Subdomain }" autocomplete="off"
|
||||||
class="layui-textarea"></textarea>
|
class="layui-textarea" lay-verify="domain"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{# } }}
|
{{# } }}
|
||||||
@@ -196,7 +198,8 @@
|
|||||||
<div class="layui-form-item tcp udp">
|
<div class="layui-form-item tcp udp">
|
||||||
<label class="layui-form-label">${ .RemotePort }</label>
|
<label class="layui-form-label">${ .RemotePort }</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="text" name="remote_port" placeholder="${ .RemotePort }" autocomplete="off"
|
<input type="text" name="remotePort" placeholder="${ .RemotePortExample }"
|
||||||
|
autocomplete="off"
|
||||||
class="layui-input"/>
|
class="layui-input"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -206,7 +209,8 @@
|
|||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">${ .UseEncryption }</label>
|
<label class="layui-form-label">${ .UseEncryption }</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="checkbox" name="use_encryption" value="true" title="${ .true }">
|
<input type="checkbox" name="transport.useEncryption" value="true"
|
||||||
|
title="${ .true }">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -214,7 +218,8 @@
|
|||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">${ .UseCompression }</label>
|
<label class="layui-form-label">${ .UseCompression }</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="checkbox" name="use_compression" value="true" title="${ .true }">
|
<input type="checkbox" name="transport.useCompression" value="true"
|
||||||
|
title="${ .true }">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "1.0.1"
|
const version = "2.0.0"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
showVersion bool
|
showVersion bool
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -9,7 +9,6 @@ require (
|
|||||||
github.com/gin-contrib/sessions v0.0.5
|
github.com/gin-contrib/sessions v0.0.5
|
||||||
github.com/gin-gonic/gin v1.9.1
|
github.com/gin-gonic/gin v1.9.1
|
||||||
github.com/spf13/cobra v1.7.0
|
github.com/spf13/cobra v1.7.0
|
||||||
github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec
|
|
||||||
golang.org/x/text v0.11.0
|
golang.org/x/text v0.11.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -96,8 +96,6 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
|
|||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
|
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
|
||||||
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||||
github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec h1:DGmKwyZwEB8dI7tbLt/I/gQuP559o/0FrAkHKlQM/Ks=
|
|
||||||
github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec/go.mod h1:owBmyHYMLkxyrugmfwE/DLJyW8Ro9mkphwuVErQ0iUw=
|
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||||
golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc=
|
golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc=
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ for binFile in $list
|
|||||||
newBinFile=${newBinFile%%.exe*}
|
newBinFile=${newBinFile%%.exe*}
|
||||||
fi
|
fi
|
||||||
cp "$binFile" "$tmpFile"
|
cp "$binFile" "$tmpFile"
|
||||||
zip -r "$newBinFile-$version".zip "$tmpFile" frpc-panel.toml frpc-tokens.toml assets -x "*.git*" "*.idea*" "*.DS_Store" "*.contentFlavour"
|
zip -r "$newBinFile-$version".zip "$tmpFile" frpc-panel.toml assets -x "*.git*" "*.idea*" "*.DS_Store" "*.contentFlavour"
|
||||||
rm -rf "$binFile" "$tmpFile"
|
rm -rf "$binFile" "$tmpFile"
|
||||||
done
|
done
|
||||||
rm -rf frpc-panel.toml frpc-tokens.toml assets
|
rm -rf frpc-panel.toml assets
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
ginI18n "github.com/gin-contrib/i18n"
|
ginI18n "github.com/gin-contrib/i18n"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/vaughan0/go-ini"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
@@ -56,46 +55,51 @@ func (c *HandleController) MakeLogoutFunc() func(context *gin.Context) {
|
|||||||
func (c *HandleController) MakeIndexFunc() func(context *gin.Context) {
|
func (c *HandleController) MakeIndexFunc() func(context *gin.Context) {
|
||||||
return func(context *gin.Context) {
|
return func(context *gin.Context) {
|
||||||
context.HTML(http.StatusOK, "index.html", gin.H{
|
context.HTML(http.StatusOK, "index.html", gin.H{
|
||||||
"version": c.Version,
|
"version": c.Version,
|
||||||
"OldNameKey": OldNameKey,
|
"OriginalNameKey": OriginalNameKey,
|
||||||
"showExit": trimString(c.CommonInfo.AdminUser) != "" && trimString(c.CommonInfo.AdminPwd) != "",
|
"showExit": trimString(c.CommonInfo.AdminUser) != "" && trimString(c.CommonInfo.AdminPwd) != "",
|
||||||
"FrpcPanel": ginI18n.MustGetMessage(context, "Frpc Panel"),
|
"FrpcPanel": ginI18n.MustGetMessage(context, "Frpc Panel"),
|
||||||
"ClientInfo": ginI18n.MustGetMessage(context, "Client Info"),
|
"ClientInfo": ginI18n.MustGetMessage(context, "Client Info"),
|
||||||
"Overview": ginI18n.MustGetMessage(context, "Overview"),
|
"Overview": ginI18n.MustGetMessage(context, "Overview"),
|
||||||
"Proxies": ginI18n.MustGetMessage(context, "Proxies"),
|
"Proxies": ginI18n.MustGetMessage(context, "Proxies"),
|
||||||
"ServerAddress": ginI18n.MustGetMessage(context, "Server Address"),
|
"ServerAddress": ginI18n.MustGetMessage(context, "Server Address"),
|
||||||
"ServerPort": ginI18n.MustGetMessage(context, "Server Port"),
|
"ServerPort": ginI18n.MustGetMessage(context, "Server Port"),
|
||||||
"Protocol": ginI18n.MustGetMessage(context, "Protocol"),
|
"Protocol": ginI18n.MustGetMessage(context, "Protocol"),
|
||||||
"TCPMux": ginI18n.MustGetMessage(context, "TCP Mux"),
|
"TCPMux": ginI18n.MustGetMessage(context, "TCP Mux"),
|
||||||
"User": ginI18n.MustGetMessage(context, "User"),
|
"User": ginI18n.MustGetMessage(context, "User"),
|
||||||
"UserToken": ginI18n.MustGetMessage(context, "User Token"),
|
"UserToken": ginI18n.MustGetMessage(context, "User Token"),
|
||||||
"AdminAddress": ginI18n.MustGetMessage(context, "Admin Address"),
|
"AdminAddress": ginI18n.MustGetMessage(context, "Admin Address"),
|
||||||
"AdminPort": ginI18n.MustGetMessage(context, "Admin Port"),
|
"AdminPort": ginI18n.MustGetMessage(context, "Admin Port"),
|
||||||
"AdminUser": ginI18n.MustGetMessage(context, "Admin User"),
|
"AdminUser": ginI18n.MustGetMessage(context, "Admin User"),
|
||||||
"AdminPwd": ginI18n.MustGetMessage(context, "Admin Pwd"),
|
"AdminPwd": ginI18n.MustGetMessage(context, "Admin Pwd"),
|
||||||
"HeartbeatInterval": ginI18n.MustGetMessage(context, "Heartbeat Interval"),
|
"HeartbeatInterval": ginI18n.MustGetMessage(context, "Heartbeat Interval"),
|
||||||
"HeartbeatTimeout": ginI18n.MustGetMessage(context, "Heartbeat Timeout"),
|
"HeartbeatTimeout": ginI18n.MustGetMessage(context, "Heartbeat Timeout"),
|
||||||
"TLSEnable": ginI18n.MustGetMessage(context, "TLS Enable"),
|
"TLSEnable": ginI18n.MustGetMessage(context, "TLS Enable"),
|
||||||
"TLSKeyFile": ginI18n.MustGetMessage(context, "TLS Key File"),
|
"TLSKeyFile": ginI18n.MustGetMessage(context, "TLS Key File"),
|
||||||
"TLSCertFile": ginI18n.MustGetMessage(context, "TLS Cert File"),
|
"TLSCertFile": ginI18n.MustGetMessage(context, "TLS Cert File"),
|
||||||
"TLSTrustedCAFile": ginI18n.MustGetMessage(context, "TLS Trusted CA File"),
|
"TLSTrustedCAFile": ginI18n.MustGetMessage(context, "TLS Trusted CA File"),
|
||||||
"NewProxy": ginI18n.MustGetMessage(context, "New Proxy"),
|
"NewProxy": ginI18n.MustGetMessage(context, "New Proxy"),
|
||||||
"RemoveProxy": ginI18n.MustGetMessage(context, "Remove Proxy"),
|
"RemoveProxy": ginI18n.MustGetMessage(context, "Remove Proxy"),
|
||||||
"Update": ginI18n.MustGetMessage(context, "Update"),
|
"Update": ginI18n.MustGetMessage(context, "Update"),
|
||||||
"Remove": ginI18n.MustGetMessage(context, "Remove"),
|
"Remove": ginI18n.MustGetMessage(context, "Remove"),
|
||||||
"Basic": ginI18n.MustGetMessage(context, "Basic"),
|
"Basic": ginI18n.MustGetMessage(context, "Basic"),
|
||||||
"Extra": ginI18n.MustGetMessage(context, "Extra"),
|
"Extra": ginI18n.MustGetMessage(context, "Extra"),
|
||||||
"ProxyName": ginI18n.MustGetMessage(context, "Proxy Name"),
|
"ProxyName": ginI18n.MustGetMessage(context, "Proxy Name"),
|
||||||
"LocalIp": ginI18n.MustGetMessage(context, "Local Ip"),
|
"ProxyNameExample": ginI18n.MustGetMessage(context, "Proxy Name Example"),
|
||||||
"LocalPort": ginI18n.MustGetMessage(context, "Local Port"),
|
"LocalIP": ginI18n.MustGetMessage(context, "Local IP"),
|
||||||
"RemotePort": ginI18n.MustGetMessage(context, "Remote Port"),
|
"LocalIPExample": ginI18n.MustGetMessage(context, "Local IP Example"),
|
||||||
"CustomDomains": ginI18n.MustGetMessage(context, "Custom Domains"),
|
"LocalPort": ginI18n.MustGetMessage(context, "Local Port"),
|
||||||
"Subdomain": ginI18n.MustGetMessage(context, "Subdomain"),
|
"LocalPortExample": ginI18n.MustGetMessage(context, "Local Port Example"),
|
||||||
"UseEncryption": ginI18n.MustGetMessage(context, "Use Encryption"),
|
"RemotePort": ginI18n.MustGetMessage(context, "Remote Port"),
|
||||||
"true": ginI18n.MustGetMessage(context, "true"),
|
"RemotePortExample": ginI18n.MustGetMessage(context, "Remote Port Example"),
|
||||||
"UseCompression": ginI18n.MustGetMessage(context, "Use Compression"),
|
"CustomDomains": ginI18n.MustGetMessage(context, "Custom Domains"),
|
||||||
"ParamName": ginI18n.MustGetMessage(context, "Param Name"),
|
"CustomDomainsExample": ginI18n.MustGetMessage(context, "Custom Domains Example"),
|
||||||
"ParamValue": ginI18n.MustGetMessage(context, "Param Value"),
|
"Subdomain": ginI18n.MustGetMessage(context, "Subdomain"),
|
||||||
|
"UseEncryption": ginI18n.MustGetMessage(context, "Use Encryption"),
|
||||||
|
"true": ginI18n.MustGetMessage(context, "true"),
|
||||||
|
"UseCompression": ginI18n.MustGetMessage(context, "Use Compression"),
|
||||||
|
"ParamName": ginI18n.MustGetMessage(context, "Param Name"),
|
||||||
|
"ParamValue": ginI18n.MustGetMessage(context, "Param Value"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,6 +107,7 @@ func (c *HandleController) MakeIndexFunc() func(context *gin.Context) {
|
|||||||
func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
||||||
return func(context *gin.Context) {
|
return func(context *gin.Context) {
|
||||||
context.JSON(http.StatusOK, gin.H{
|
context.JSON(http.StatusOK, gin.H{
|
||||||
|
"Proxies": ginI18n.MustGetMessage(context, "Proxies"),
|
||||||
"EmptyData": ginI18n.MustGetMessage(context, "Empty data"),
|
"EmptyData": ginI18n.MustGetMessage(context, "Empty data"),
|
||||||
"true": ginI18n.MustGetMessage(context, "true"),
|
"true": ginI18n.MustGetMessage(context, "true"),
|
||||||
"false": ginI18n.MustGetMessage(context, "false"),
|
"false": ginI18n.MustGetMessage(context, "false"),
|
||||||
@@ -114,7 +119,9 @@ func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
|||||||
"Status": ginI18n.MustGetMessage(context, "Status"),
|
"Status": ginI18n.MustGetMessage(context, "Status"),
|
||||||
"Info": ginI18n.MustGetMessage(context, "Info"),
|
"Info": ginI18n.MustGetMessage(context, "Info"),
|
||||||
"running": ginI18n.MustGetMessage(context, "running"),
|
"running": ginI18n.MustGetMessage(context, "running"),
|
||||||
"LocalIp": ginI18n.MustGetMessage(context, "Local Ip"),
|
"start error": ginI18n.MustGetMessage(context, "start error"),
|
||||||
|
"new": ginI18n.MustGetMessage(context, "new"),
|
||||||
|
"LocalIP": ginI18n.MustGetMessage(context, "Local IP"),
|
||||||
"LocalPort": ginI18n.MustGetMessage(context, "Local Port"),
|
"LocalPort": ginI18n.MustGetMessage(context, "Local Port"),
|
||||||
"RemotePort": ginI18n.MustGetMessage(context, "Remote Port"),
|
"RemotePort": ginI18n.MustGetMessage(context, "Remote Port"),
|
||||||
"UseEncryption": ginI18n.MustGetMessage(context, "Use Encryption"),
|
"UseEncryption": ginI18n.MustGetMessage(context, "Use Encryption"),
|
||||||
@@ -135,69 +142,22 @@ func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
|||||||
"ProxyExist": ginI18n.MustGetMessage(context, "Proxy Exist"),
|
"ProxyExist": ginI18n.MustGetMessage(context, "Proxy Exist"),
|
||||||
"ProxyNotExist": ginI18n.MustGetMessage(context, "Proxy Not Exist"),
|
"ProxyNotExist": ginI18n.MustGetMessage(context, "Proxy Not Exist"),
|
||||||
"ClientTips": ginI18n.MustGetMessage(context, "Client Tips"),
|
"ClientTips": ginI18n.MustGetMessage(context, "Client Tips"),
|
||||||
|
"and": ginI18n.MustGetMessage(context, "and"),
|
||||||
|
"RequireNotAllEmpty": ginI18n.MustGetMessage(context, "Require Not All Empty"),
|
||||||
|
"RequireNotEmpty": ginI18n.MustGetMessage(context, "Require Not Empty"),
|
||||||
|
"RequireNumber": ginI18n.MustGetMessage(context, "Require Number"),
|
||||||
|
"RequireBoolean": ginI18n.MustGetMessage(context, "Require Boolean"),
|
||||||
|
"RequireArray": ginI18n.MustGetMessage(context, "Require Array"),
|
||||||
|
"Total": ginI18n.MustGetMessage(context, "Total"),
|
||||||
|
"Items": ginI18n.MustGetMessage(context, "Items"),
|
||||||
|
"Goto": ginI18n.MustGetMessage(context, "Go to"),
|
||||||
|
"PerPage": ginI18n.MustGetMessage(context, "Per Page"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HandleController) MakeAddProxyFunc() func(context *gin.Context) {
|
|
||||||
return func(context *gin.Context) {
|
|
||||||
proxy := ini.Section{}
|
|
||||||
|
|
||||||
response := OperationResponse{
|
|
||||||
Success: true,
|
|
||||||
Code: Success,
|
|
||||||
Message: "proxy add success",
|
|
||||||
}
|
|
||||||
|
|
||||||
err := context.BindJSON(&proxy)
|
|
||||||
if err != nil {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = ParamError
|
|
||||||
response.Message = fmt.Sprintf("proxy add failed, param error : %v", err)
|
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
name := proxy[NameKey]
|
|
||||||
|
|
||||||
if trimString(name) == "" {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = ParamError
|
|
||||||
response.Message = fmt.Sprintf("proxy add failed, proxy name invalid")
|
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, exist := clientProxies[name]; exist {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = ProxyExist
|
|
||||||
response.Message = fmt.Sprintf("proxy add failed, proxy exist")
|
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
clientProxies[name] = proxy
|
|
||||||
|
|
||||||
res := c.UpdateFrpcConfig()
|
|
||||||
if !res.Success {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = res.Code
|
|
||||||
response.Message = fmt.Sprintf("proxy add failed, error : %v", res.Message)
|
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
context.JSON(0, &response)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *HandleController) MakeUpdateProxyFunc() func(context *gin.Context) {
|
func (c *HandleController) MakeUpdateProxyFunc() func(context *gin.Context) {
|
||||||
return func(context *gin.Context) {
|
return func(context *gin.Context) {
|
||||||
proxy := ini.Section{}
|
|
||||||
|
|
||||||
response := OperationResponse{
|
response := OperationResponse{
|
||||||
Success: true,
|
Success: true,
|
||||||
@@ -205,119 +165,21 @@ func (c *HandleController) MakeUpdateProxyFunc() func(context *gin.Context) {
|
|||||||
Message: "proxy update success",
|
Message: "proxy update success",
|
||||||
}
|
}
|
||||||
|
|
||||||
err := context.BindJSON(&proxy)
|
data, err := context.GetRawData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.Success = false
|
response.Success = false
|
||||||
response.Code = ParamError
|
response.Code = http.StatusNoContent
|
||||||
response.Message = fmt.Sprintf("update failed, param error : %v", err)
|
response.Message = fmt.Sprintf("update failed, error : %v", err)
|
||||||
log.Printf(response.Message)
|
log.Printf(response.Message)
|
||||||
context.JSON(http.StatusOK, &response)
|
context.JSON(http.StatusOK, &response)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
oldName := proxy[OldNameKey]
|
res := c.UpdateFrpcConfig(data)
|
||||||
name := proxy[NameKey]
|
|
||||||
|
|
||||||
if trimString(oldName) == "" || trimString(name) == "" {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = ParamError
|
|
||||||
response.Message = fmt.Sprintf("proxy add failed, proxy name invalid")
|
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, exist := clientProxies[oldName]; !exist {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = ProxyNotExist
|
|
||||||
response.Message = fmt.Sprintf("proxy update failed, proxy not exist")
|
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if oldName != name {
|
|
||||||
if _, exist := clientProxies[name]; exist {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = ProxyExist
|
|
||||||
response.Message = fmt.Sprintf("proxy update failed, proxy exist")
|
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(clientProxies, oldName)
|
|
||||||
clientProxies[name] = proxy
|
|
||||||
|
|
||||||
res := c.UpdateFrpcConfig()
|
|
||||||
if !res.Success {
|
if !res.Success {
|
||||||
response.Success = false
|
response.Success = false
|
||||||
response.Code = res.Code
|
response.Code = res.Code
|
||||||
response.Message = fmt.Sprintf("user update failed, error : %v", res.Message)
|
response.Message = fmt.Sprintf("update failed, error : %v", res.Message)
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *HandleController) MakeRemoveProxyFunc() func(context *gin.Context) {
|
|
||||||
return func(context *gin.Context) {
|
|
||||||
var proxies []ini.Section
|
|
||||||
|
|
||||||
response := OperationResponse{
|
|
||||||
Success: true,
|
|
||||||
Code: Success,
|
|
||||||
Message: "proxy remove success",
|
|
||||||
}
|
|
||||||
|
|
||||||
err := context.BindJSON(&proxies)
|
|
||||||
if err != nil {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = ParamError
|
|
||||||
response.Message = fmt.Sprintf("proxy remove failed, param error : %v", err)
|
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
tempProxyNames := make([]string, len(proxies))
|
|
||||||
for index, proxy := range proxies {
|
|
||||||
name := proxy[NameKey]
|
|
||||||
|
|
||||||
if trimString(name) == "" {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = ParamError
|
|
||||||
response.Message = fmt.Sprintf("proxy remove failed, proxy %v name invalid", name)
|
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, exist := clientProxies[name]; !exist {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = ProxyExist
|
|
||||||
response.Message = fmt.Sprintf("proxy remove failed, proxy %v not exist", name)
|
|
||||||
log.Printf(response.Message)
|
|
||||||
context.JSON(http.StatusOK, &response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
tempProxyNames[index] = name
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, name := range tempProxyNames {
|
|
||||||
delete(clientProxies, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
res := c.UpdateFrpcConfig()
|
|
||||||
if !res.Success {
|
|
||||||
response.Success = false
|
|
||||||
response.Code = res.Code
|
|
||||||
response.Message = fmt.Sprintf("proxy remvoe failed, error : %v", res.Message)
|
|
||||||
log.Printf(response.Message)
|
log.Printf(response.Message)
|
||||||
context.JSON(http.StatusOK, &response)
|
context.JSON(http.StatusOK, &response)
|
||||||
return
|
return
|
||||||
@@ -363,11 +225,11 @@ func (c *HandleController) MakeProxyFunc() func(context *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HandleController) UpdateFrpcConfig() ProxyResponse {
|
func (c *HandleController) UpdateFrpcConfig(tomlStr []byte) ProxyResponse {
|
||||||
res := ProxyResponse{}
|
res := ProxyResponse{}
|
||||||
|
|
||||||
requestUrl := c.buildRequestUrl("/api/config")
|
requestUrl := c.buildRequestUrl("/api/config")
|
||||||
request, _ := http.NewRequest("PUT", requestUrl, bytes.NewReader(serializeSections()))
|
request, _ := http.NewRequest("PUT", requestUrl, bytes.NewReader(tomlStr))
|
||||||
response, err := c.getClientResponse(request, c.buildClient())
|
response, err := c.getClientResponse(request, c.buildClient())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ func (c *HandleController) Register(rootDir string, engine *gin.Engine) {
|
|||||||
group = engine.Group("/")
|
group = engine.Group("/")
|
||||||
}
|
}
|
||||||
group.GET("/", c.MakeIndexFunc())
|
group.GET("/", c.MakeIndexFunc())
|
||||||
group.POST("/add", c.MakeAddProxyFunc())
|
|
||||||
group.POST("/update", c.MakeUpdateProxyFunc())
|
group.POST("/update", c.MakeUpdateProxyFunc())
|
||||||
group.POST("/remove", c.MakeRemoveProxyFunc())
|
|
||||||
group.GET("/proxy/*serverApi", c.MakeProxyFunc())
|
group.GET("/proxy/*serverApi", c.MakeProxyFunc())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fatedier/frp/pkg/config"
|
"github.com/fatedier/frp/pkg/config"
|
||||||
v1 "github.com/fatedier/frp/pkg/config/v1"
|
v1 "github.com/fatedier/frp/pkg/config/v1"
|
||||||
"github.com/vaughan0/go-ini"
|
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -18,42 +16,8 @@ func trimString(str string) string {
|
|||||||
return strings.TrimSpace(str)
|
return strings.TrimSpace(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
func sortSectionKeys(object ini.Section) []string {
|
func equalIgnoreCase(source string, target string) bool {
|
||||||
var keys []string
|
return strings.ToUpper(source) == strings.ToUpper(target)
|
||||||
for key := range object {
|
|
||||||
keys = append(keys, key)
|
|
||||||
}
|
|
||||||
sort.Strings(keys)
|
|
||||||
return keys
|
|
||||||
}
|
|
||||||
|
|
||||||
func serializeSections() []byte {
|
|
||||||
var build strings.Builder
|
|
||||||
build.WriteString("[common]\n")
|
|
||||||
|
|
||||||
for _, key := range sortSectionKeys(clientCommon) {
|
|
||||||
build.WriteString(fmt.Sprintf("%s = %s\n", key, clientCommon[key]))
|
|
||||||
}
|
|
||||||
build.WriteString("\n")
|
|
||||||
|
|
||||||
sections := Sections{clientProxies}
|
|
||||||
|
|
||||||
for _, sectionInfo := range sections.sort() {
|
|
||||||
name := sectionInfo.Name
|
|
||||||
build.WriteString(fmt.Sprintf("[%s]\n", name))
|
|
||||||
section := sectionInfo.Section
|
|
||||||
|
|
||||||
for _, key := range sortSectionKeys(section) {
|
|
||||||
value := section[key]
|
|
||||||
if key == NameKey || key == OldNameKey || trimString(value) == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
build.WriteString(fmt.Sprintf("%s = %s\n", key, value))
|
|
||||||
}
|
|
||||||
build.WriteString("\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
return []byte(build.String())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HandleController) buildRequestUrl(serverApi string) string {
|
func (c *HandleController) buildRequestUrl(serverApi string) string {
|
||||||
@@ -139,5 +103,18 @@ func (c *HandleController) parseConfigure(content, proxyType string) (interface{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return clientConfig, nil
|
|
||||||
|
if proxyType == "none" {
|
||||||
|
return clientConfig, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
allProxies := clientConfig.Proxies
|
||||||
|
var filterProxies = make([]v1.TypedProxyConfig, 0)
|
||||||
|
for i := range allProxies {
|
||||||
|
if equalIgnoreCase(allProxies[i].Type, proxyType) {
|
||||||
|
filterProxies = append(filterProxies, allProxies[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filterProxies, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/vaughan0/go-ini"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Success int = iota
|
Success int = iota
|
||||||
ParamError
|
ParamError
|
||||||
@@ -17,7 +11,7 @@ const (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
NameKey = "name"
|
NameKey = "name"
|
||||||
OldNameKey = "_old_name"
|
OriginalNameKey = "_original_name"
|
||||||
SessionName = "GOSESSION"
|
SessionName = "GOSESSION"
|
||||||
AuthName = "_PANEL_AUTH"
|
AuthName = "_PANEL_AUTH"
|
||||||
LoginUrl = "/login"
|
LoginUrl = "/login"
|
||||||
@@ -26,16 +20,6 @@ const (
|
|||||||
LogoutSuccessUrl = "/login"
|
LogoutSuccessUrl = "/login"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
clientCommon ini.Section
|
|
||||||
clientProxies map[string]ini.Section
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
clientCommon = ini.Section{}
|
|
||||||
clientProxies = make(map[string]ini.Section)
|
|
||||||
}
|
|
||||||
|
|
||||||
type HTTPError struct {
|
type HTTPError struct {
|
||||||
Code int
|
Code int
|
||||||
Err error
|
Err error
|
||||||
@@ -75,38 +59,3 @@ type ProxyResponse struct {
|
|||||||
OperationResponse
|
OperationResponse
|
||||||
Data any `json:"data"`
|
Data any `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientProxies struct {
|
|
||||||
Proxy ini.Section `json:"proxy"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SectionInfo struct {
|
|
||||||
Name string
|
|
||||||
Section ini.Section
|
|
||||||
}
|
|
||||||
|
|
||||||
type Sections struct {
|
|
||||||
sections map[string]ini.Section
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Sections) sort() []SectionInfo {
|
|
||||||
sectionInfos := make([]SectionInfo, 0)
|
|
||||||
|
|
||||||
for key, value := range s.sections {
|
|
||||||
sectionInfos = append(sectionInfos, SectionInfo{Name: key, Section: value})
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Slice(sectionInfos, func(i, j int) bool {
|
|
||||||
typeCompare := strings.Compare(sectionInfos[i].Section["type"], sectionInfos[j].Section["type"])
|
|
||||||
if typeCompare == -1 {
|
|
||||||
return true
|
|
||||||
} else if typeCompare == 0 {
|
|
||||||
nameCompare := strings.Compare(sectionInfos[i].Name, sectionInfos[j].Name)
|
|
||||||
return nameCompare == -1
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return sectionInfos
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user