Merge pull request #258 from bjdgyc/dev

Dev
This commit is contained in:
bjdgyc 2023-07-23 15:45:04 +08:00 committed by GitHub
commit 0a9fe8f96c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 72 additions and 48 deletions

View File

@ -204,6 +204,9 @@ https://cloud.tencent.com/document/product/216/62007
# 首先关闭nat转发功能 # 首先关闭nat转发功能
iptables_nat = false iptables_nat = false
# master网卡需要打开混杂模式
ip link set dev eth0 promisc on
#内网主网卡名称 #内网主网卡名称
ipv4_master = "eth0" ipv4_master = "eth0"
#以下网段需要跟ipv4_master网卡设置成一样 #以下网段需要跟ipv4_master网卡设置成一样
@ -297,7 +300,8 @@ ipv4_end = "10.1.2.200"
## Discussion ## Discussion
添加QQ群: 567510628 添加QQ群(1): 567510628
添加QQ群(2): 739072205
群共享文件有相关软件下载 群共享文件有相关软件下载

View File

@ -12,6 +12,9 @@ function RETVAL() {
#当前目录 #当前目录
cpath=$(pwd) cpath=$(pwd)
ver=`cat server/base/app_ver.go | grep APP_VER | awk '{print $3}' | sed 's/"//g'`
echo "当前版本 $ver"
echo "编译前端项目" echo "编译前端项目"
cd $cpath/web cd $cpath/web
#国内可替换源加快速度 #国内可替换源加快速度

View File

@ -80,7 +80,6 @@ func initCmd() {
linkViper.SetEnvPrefix("link") linkViper.SetEnvPrefix("link")
// 基础配置 // 基础配置
for _, v := range configs { for _, v := range configs {
if v.Typ == cfgStr { if v.Typ == cfgStr {
rootCmd.Flags().StringP(v.Name, v.Short, v.ValStr, v.Usage) rootCmd.Flags().StringP(v.Name, v.Short, v.ValStr, v.Usage)
@ -113,7 +112,7 @@ func initCmd() {
linkViper.SetConfigFile(conf) linkViper.SetConfigFile(conf)
err = linkViper.ReadInConfig() err = linkViper.ReadInConfig()
if err != nil { if err != nil {
fmt.Println("Using config file:", err) panic("config file err:" + err.Error())
} }
}) })
} }

View File

@ -103,7 +103,7 @@ func logLevel2Int(l string) int {
} }
lvl := LogLevelInfo lvl := LogLevelInfo
for k, v := range levels { for k, v := range levels {
if strings.EqualFold(strings.ToLower(l), strings.ToLower(v)) { if strings.ToLower(l) == strings.ToLower(v) {
lvl = k lvl = k
} }
} }

View File

@ -64,8 +64,7 @@ type DNSProvider struct {
SecretKey string `json:"secretKey"` SecretKey string `json:"secretKey"`
} `json:"txcloud"` } `json:"txcloud"`
CfCloud struct { CfCloud struct {
AuthEmail string `json:"authEmail"` AuthToken string `json:"authToken"`
AuthKey string `json:"authKey"`
} `json:"cfcloud"` } `json:"cfcloud"`
} }
type LegoUserData struct { type LegoUserData struct {
@ -89,15 +88,15 @@ type LeGoClient struct {
func GetDNSProvider(l *SettingLetsEncrypt) (Provider challenge.Provider, err error) { func GetDNSProvider(l *SettingLetsEncrypt) (Provider challenge.Provider, err error) {
switch l.Name { switch l.Name {
case "aliyun": case "aliyun":
if Provider, err = alidns.NewDNSProviderConfig(&alidns.Config{APIKey: l.DNSProvider.AliYun.APIKey, SecretKey: l.DNSProvider.AliYun.SecretKey, TTL: 600}); err != nil { if Provider, err = alidns.NewDNSProviderConfig(&alidns.Config{APIKey: l.DNSProvider.AliYun.APIKey, SecretKey: l.DNSProvider.AliYun.SecretKey, PropagationTimeout: 60 * time.Second, PollingInterval: 2 * time.Second, TTL: 600}); err != nil {
return return
} }
case "txcloud": case "txcloud":
if Provider, err = tencentcloud.NewDNSProviderConfig(&tencentcloud.Config{SecretID: l.DNSProvider.TXCloud.SecretID, SecretKey: l.DNSProvider.TXCloud.SecretKey, TTL: 600}); err != nil { if Provider, err = tencentcloud.NewDNSProviderConfig(&tencentcloud.Config{SecretID: l.DNSProvider.TXCloud.SecretID, SecretKey: l.DNSProvider.TXCloud.SecretKey, PropagationTimeout: 60 * time.Second, PollingInterval: 2 * time.Second, TTL: 600}); err != nil {
return return
} }
case "cloudflare": case "cfcloud":
if Provider, err = cloudflare.NewDNSProviderConfig(&cloudflare.Config{AuthEmail: l.DNSProvider.CfCloud.AuthEmail, AuthKey: l.DNSProvider.CfCloud.AuthKey, TTL: 600}); err != nil { if Provider, err = cloudflare.NewDNSProviderConfig(&cloudflare.Config{AuthToken: l.DNSProvider.CfCloud.AuthToken, PropagationTimeout: 60 * time.Second, PollingInterval: 2 * time.Second, TTL: 600}); err != nil {
return return
} }
} }

View File

@ -115,9 +115,8 @@ func addInitData() error {
SecretKey string `json:"secretKey"` SecretKey string `json:"secretKey"`
}{SecretID: "", SecretKey: ""}, }{SecretID: "", SecretKey: ""},
CfCloud: struct { CfCloud: struct {
AuthEmail string `json:"authEmail"` AuthToken string `json:"authToken"`
AuthKey string `json:"authKey"` }{AuthToken: ""}},
}{AuthEmail: "", AuthKey: ""}},
} }
err = SettingSessAdd(sess, provider) err = SettingSessAdd(sess, provider)
if err != nil { if err != nil {

View File

@ -19,7 +19,7 @@ require (
github.com/lib/pq v1.10.2 github.com/lib/pq v1.10.2
github.com/mattn/go-sqlite3 v1.14.9 github.com/mattn/go-sqlite3 v1.14.9
github.com/orcaman/concurrent-map v1.0.0 github.com/orcaman/concurrent-map v1.0.0
github.com/pion/dtls/v2 v2.2.6 github.com/pion/dtls/v2 v2.2.7
github.com/pion/logging v0.2.2 github.com/pion/logging v0.2.2
github.com/pires/go-proxyproto v0.6.2 github.com/pires/go-proxyproto v0.6.2
github.com/shirou/gopsutil v3.21.7+incompatible github.com/shirou/gopsutil v3.21.7+incompatible
@ -29,14 +29,14 @@ require (
github.com/spf13/cast v1.3.1 github.com/spf13/cast v1.3.1
github.com/spf13/cobra v1.2.1 github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.8.1 github.com/spf13/viper v1.8.1
github.com/stretchr/testify v1.8.1 github.com/stretchr/testify v1.8.3
github.com/xhit/go-simple-mail/v2 v2.10.0 github.com/xhit/go-simple-mail/v2 v2.10.0
github.com/xlzd/gotp v0.0.0-20181030022105-c8557ba2c119 github.com/xlzd/gotp v0.0.0-20181030022105-c8557ba2c119
github.com/xuri/excelize/v2 v2.6.1 github.com/xuri/excelize/v2 v2.6.1
go.uber.org/atomic v1.10.0 go.uber.org/atomic v1.10.0
golang.org/x/crypto v0.5.0 golang.org/x/crypto v0.8.0
golang.org/x/net v0.7.0 golang.org/x/net v0.9.0
golang.org/x/text v0.7.0 golang.org/x/text v0.9.0
golang.org/x/time v0.3.0 golang.org/x/time v0.3.0
layeh.com/radius v0.0.0-20210819152912-ad72663a72ab layeh.com/radius v0.0.0-20210819152912-ad72663a72ab
xorm.io/xorm v1.3.2 xorm.io/xorm v1.3.2
@ -54,13 +54,12 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kr/text v0.2.0 // indirect github.com/kr/text v0.2.0 // indirect
github.com/miekg/dns v1.1.50 // indirect github.com/miekg/dns v1.1.50 // indirect
github.com/pion/transport/v2 v2.0.2 // indirect github.com/pion/transport/v2 v2.2.1 // indirect
github.com/pion/udp/v2 v2.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.490 // indirect github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.490 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.490 // indirect github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.490 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/mod v0.8.0 // indirect
golang.org/x/tools v0.1.12 // indirect golang.org/x/tools v0.6.0 // indirect
) )
require ( require (
@ -94,8 +93,8 @@ require (
github.com/tklauser/numcpus v0.2.3 // indirect github.com/tklauser/numcpus v0.2.3 // indirect
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect golang.org/x/sys v0.7.0 // indirect
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
gopkg.in/ini.v1 v1.66.6 // indirect gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect

View File

@ -44,7 +44,7 @@ type macAddressList struct {
func setCommonHeader(w http.ResponseWriter) { func setCommonHeader(w http.ResponseWriter) {
// Content-Length Date 默认已经存在 // Content-Length Date 默认已经存在
w.Header().Set("Server", "AnyLink") w.Header().Set("Server", "AnyLinkOpenSource")
w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Header().Set("Cache-Control", "no-store,no-cache") w.Header().Set("Cache-Control", "no-store,no-cache")
w.Header().Set("Pragma", "no-cache") w.Header().Set("Pragma", "no-cache")

View File

@ -47,7 +47,12 @@
<el-table-column <el-table-column
prop="bandwidth" prop="bandwidth"
label="带宽限制"> label="带宽限制"
width="90">
<template slot-scope="scope">
<el-row v-if="scope.row.bandwidth > 0">{{ convertBandwidth(scope.row.bandwidth, 'BYTE', 'Mbps') }} Mbps</el-row>
<el-row v-else>不限</el-row>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -62,7 +67,7 @@
<el-table-column <el-table-column
prop="route_include" prop="route_include"
label="路由包含" label="路由包含"
width="200"> width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<el-row v-for="(item,inx) in scope.row.route_include.slice(0, readMinRows)" :key="inx">{{ item.val }}</el-row> <el-row v-for="(item,inx) in scope.row.route_include.slice(0, readMinRows)" :key="inx">{{ item.val }}</el-row>
<div v-if="scope.row.route_include.length > readMinRows"> <div v-if="scope.row.route_include.length > readMinRows">
@ -77,7 +82,7 @@
<el-table-column <el-table-column
prop="route_exclude" prop="route_exclude"
label="路由排除" label="路由排除"
width="200"> width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<el-row v-for="(item,inx) in scope.row.route_exclude.slice(0, readMinRows)" :key="inx">{{ item.val }}</el-row> <el-row v-for="(item,inx) in scope.row.route_exclude.slice(0, readMinRows)" :key="inx">{{ item.val }}</el-row>
<div v-if="scope.row.route_exclude.length > readMinRows"> <div v-if="scope.row.route_exclude.length > readMinRows">
@ -92,7 +97,7 @@
<el-table-column <el-table-column
prop="link_acl" prop="link_acl"
label="LINK-ACL" label="LINK-ACL"
min-width="200"> min-width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<el-row v-for="(item,inx) in scope.row.link_acl.slice(0, readMinRows)" :key="inx"> <el-row v-for="(item,inx) in scope.row.link_acl.slice(0, readMinRows)" :key="inx">
{{ item.action }} => {{ item.val }} : {{ item.port }} {{ item.action }} => {{ item.val }} : {{ item.port }}
@ -186,9 +191,9 @@
<el-input v-model="ruleForm.note"></el-input> <el-input v-model="ruleForm.note"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="带宽限制" prop="bandwidth"> <el-form-item label="带宽限制" prop="bandwidth_format" style="width:260px;">
<el-input v-model.number="ruleForm.bandwidth"> <el-input v-model="ruleForm.bandwidth_format" oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''">
<template slot="append">BYTE/S</template> <template slot="append">Mbps</template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="排除本地网络" prop="allow_lan"> <el-form-item label="排除本地网络" prop="allow_lan">
@ -435,6 +440,7 @@ export default {
}, },
ruleForm: { ruleForm: {
bandwidth: 0, bandwidth: 0,
bandwidth_format: '0',
status: 1, status: 1,
allow_lan: true, allow_lan: true,
client_dns: [{val: '114.114.114.114'}], client_dns: [{val: '114.114.114.114'}],
@ -463,9 +469,9 @@ export default {
{required: true, message: '请输入组名', trigger: 'blur'}, {required: true, message: '请输入组名', trigger: 'blur'},
{max: 30, message: '长度小于 30 个字符', trigger: 'blur'} {max: 30, message: '长度小于 30 个字符', trigger: 'blur'}
], ],
bandwidth: [ bandwidth_format: [
{required: true, message: '请输入带宽限制', trigger: 'blur'}, {required: true, message: '请输入带宽限制', trigger: 'blur'},
{type: 'number', message: '带宽限制必须为数字值'} {type: 'string', message: '带宽限制必须为数字值'}
], ],
status: [ status: [
{required: true} {required: true}
@ -536,6 +542,7 @@ export default {
id: row.id, id: row.id,
} }
}).then(resp => { }).then(resp => {
resp.data.data.bandwidth_format = this.convertBandwidth(resp.data.data.bandwidth, 'BYTE', 'Mbps').toString();
this.ruleForm = resp.data.data; this.ruleForm = resp.data.data;
this.setAuthData(resp.data.data); this.setAuthData(resp.data.data);
}).catch(error => { }).catch(error => {
@ -582,6 +589,7 @@ export default {
console.log('error submit!!'); console.log('error submit!!');
return false; return false;
} }
this.ruleForm.bandwidth = this.convertBandwidth(this.ruleForm.bandwidth_format, 'Mbps', 'BYTE');
axios.post('/group/set', this.ruleForm).then(resp => { axios.post('/group/set', this.ruleForm).then(resp => {
const rdata = resp.data; const rdata = resp.data;
if (rdata.code === 0) { if (rdata.code === 0) {
@ -666,6 +674,18 @@ export default {
closeDialog() { closeDialog() {
this.user_edit_dialog = false; this.user_edit_dialog = false;
this.activeTab = "general"; this.activeTab = "general";
},
convertBandwidth(bandwidth, fromUnit, toUnit) {
const units = {
bps: 1,
Kbps: 1000,
Mbps: 1000000,
Gbps: 1000000000,
BYTE: 8,
};
const result = bandwidth * units[fromUnit] / units[toUnit];
const fixedResult = result.toFixed(2);
return parseFloat(fixedResult);
} }
}, },
} }

View File

@ -318,8 +318,7 @@ export default {
secretKey: "", secretKey: "",
}, },
cfcloud: { cfcloud: {
authEmail: "", authToken: "",
authKey: "",
}, },
}, },
customCert: { cert: "", key: "" }, customCert: { cert: "", key: "" },
@ -399,19 +398,13 @@ export default {
], ],
cfcloud: [ cfcloud: [
{ {
label: "Email", label: "AuthToken",
prop: "email", prop: "authToken",
component: "el-input",
type: "text",
},
{
label: "AuthKey",
prop: "authKey",
component: "el-input", component: "el-input",
type: "password", type: "password",
rules: { rules: {
required: true, required: true,
message: "请输入正确的APIKey", message: "请输入正确的AuthToken",
trigger: "blur", trigger: "blur",
}, },
}, },
@ -551,12 +544,20 @@ export default {
}); });
break; break;
case "letsCert": case "letsCert":
var loading = this.$loading({
lock: true,
text: "证书申请中...",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)",
});
axios.post("/set/other/createcert", this.letsCert).then((resp) => { axios.post("/set/other/createcert", this.letsCert).then((resp) => {
var rdata = resp.data; var rdata = resp.data;
console.log(rdata); console.log(rdata);
if (rdata.code === 0) { if (rdata.code === 0) {
loading.close();
this.$message.success(rdata.msg); this.$message.success(rdata.msg);
} else { } else {
loading.close();
this.$message.error(rdata.msg); this.$message.error(rdata.msg);
} }
}); });