mirror of https://github.com/bjdgyc/anylink.git
commit
0a9fe8f96c
|
@ -204,6 +204,9 @@ https://cloud.tencent.com/document/product/216/62007
|
|||
# 首先关闭nat转发功能
|
||||
iptables_nat = false
|
||||
|
||||
# master网卡需要打开混杂模式
|
||||
ip link set dev eth0 promisc on
|
||||
|
||||
#内网主网卡名称
|
||||
ipv4_master = "eth0"
|
||||
#以下网段需要跟ipv4_master网卡设置成一样
|
||||
|
@ -297,7 +300,8 @@ ipv4_end = "10.1.2.200"
|
|||
|
||||
## Discussion
|
||||
|
||||
添加QQ群: 567510628
|
||||
添加QQ群(1): 567510628
|
||||
添加QQ群(2): 739072205
|
||||
|
||||
群共享文件有相关软件下载
|
||||
|
||||
|
|
3
build.sh
3
build.sh
|
@ -12,6 +12,9 @@ function RETVAL() {
|
|||
#当前目录
|
||||
cpath=$(pwd)
|
||||
|
||||
ver=`cat server/base/app_ver.go | grep APP_VER | awk '{print $3}' | sed 's/"//g'`
|
||||
echo "当前版本 $ver"
|
||||
|
||||
echo "编译前端项目"
|
||||
cd $cpath/web
|
||||
#国内可替换源加快速度
|
||||
|
|
|
@ -80,7 +80,6 @@ func initCmd() {
|
|||
linkViper.SetEnvPrefix("link")
|
||||
|
||||
// 基础配置
|
||||
|
||||
for _, v := range configs {
|
||||
if v.Typ == cfgStr {
|
||||
rootCmd.Flags().StringP(v.Name, v.Short, v.ValStr, v.Usage)
|
||||
|
@ -113,7 +112,7 @@ func initCmd() {
|
|||
linkViper.SetConfigFile(conf)
|
||||
err = linkViper.ReadInConfig()
|
||||
if err != nil {
|
||||
fmt.Println("Using config file:", err)
|
||||
panic("config file err:" + err.Error())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ func logLevel2Int(l string) int {
|
|||
}
|
||||
lvl := LogLevelInfo
|
||||
for k, v := range levels {
|
||||
if strings.EqualFold(strings.ToLower(l), strings.ToLower(v)) {
|
||||
if strings.ToLower(l) == strings.ToLower(v) {
|
||||
lvl = k
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,8 +64,7 @@ type DNSProvider struct {
|
|||
SecretKey string `json:"secretKey"`
|
||||
} `json:"txcloud"`
|
||||
CfCloud struct {
|
||||
AuthEmail string `json:"authEmail"`
|
||||
AuthKey string `json:"authKey"`
|
||||
AuthToken string `json:"authToken"`
|
||||
} `json:"cfcloud"`
|
||||
}
|
||||
type LegoUserData struct {
|
||||
|
@ -89,15 +88,15 @@ type LeGoClient struct {
|
|||
func GetDNSProvider(l *SettingLetsEncrypt) (Provider challenge.Provider, err error) {
|
||||
switch l.Name {
|
||||
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
|
||||
}
|
||||
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
|
||||
}
|
||||
case "cloudflare":
|
||||
if Provider, err = cloudflare.NewDNSProviderConfig(&cloudflare.Config{AuthEmail: l.DNSProvider.CfCloud.AuthEmail, AuthKey: l.DNSProvider.CfCloud.AuthKey, TTL: 600}); err != nil {
|
||||
case "cfcloud":
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,9 +115,8 @@ func addInitData() error {
|
|||
SecretKey string `json:"secretKey"`
|
||||
}{SecretID: "", SecretKey: ""},
|
||||
CfCloud: struct {
|
||||
AuthEmail string `json:"authEmail"`
|
||||
AuthKey string `json:"authKey"`
|
||||
}{AuthEmail: "", AuthKey: ""}},
|
||||
AuthToken string `json:"authToken"`
|
||||
}{AuthToken: ""}},
|
||||
}
|
||||
err = SettingSessAdd(sess, provider)
|
||||
if err != nil {
|
||||
|
|
|
@ -19,7 +19,7 @@ require (
|
|||
github.com/lib/pq v1.10.2
|
||||
github.com/mattn/go-sqlite3 v1.14.9
|
||||
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/pires/go-proxyproto v0.6.2
|
||||
github.com/shirou/gopsutil v3.21.7+incompatible
|
||||
|
@ -29,14 +29,14 @@ require (
|
|||
github.com/spf13/cast v1.3.1
|
||||
github.com/spf13/cobra v1.2.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/xlzd/gotp v0.0.0-20181030022105-c8557ba2c119
|
||||
github.com/xuri/excelize/v2 v2.6.1
|
||||
go.uber.org/atomic v1.10.0
|
||||
golang.org/x/crypto v0.5.0
|
||||
golang.org/x/net v0.7.0
|
||||
golang.org/x/text v0.7.0
|
||||
golang.org/x/crypto v0.8.0
|
||||
golang.org/x/net v0.9.0
|
||||
golang.org/x/text v0.9.0
|
||||
golang.org/x/time v0.3.0
|
||||
layeh.com/radius v0.0.0-20210819152912-ad72663a72ab
|
||||
xorm.io/xorm v1.3.2
|
||||
|
@ -54,13 +54,12 @@ require (
|
|||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/miekg/dns v1.1.50 // indirect
|
||||
github.com/pion/transport/v2 v2.0.2 // indirect
|
||||
github.com/pion/udp/v2 v2.0.1 // indirect
|
||||
github.com/pion/transport/v2 v2.2.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/dnspod v1.0.490 // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
||||
golang.org/x/tools v0.1.12 // indirect
|
||||
golang.org/x/mod v0.8.0 // indirect
|
||||
golang.org/x/tools v0.6.0 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -94,8 +93,8 @@ require (
|
|||
github.com/tklauser/numcpus v0.2.3 // indirect
|
||||
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
|
||||
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.7.0 // indirect
|
||||
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
|
||||
gopkg.in/ini.v1 v1.66.6 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
|
|
|
@ -44,7 +44,7 @@ type macAddressList struct {
|
|||
|
||||
func setCommonHeader(w http.ResponseWriter) {
|
||||
// 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("Cache-Control", "no-store,no-cache")
|
||||
w.Header().Set("Pragma", "no-cache")
|
||||
|
|
|
@ -47,7 +47,12 @@
|
|||
|
||||
<el-table-column
|
||||
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
|
||||
|
@ -62,7 +67,7 @@
|
|||
<el-table-column
|
||||
prop="route_include"
|
||||
label="路由包含"
|
||||
width="200">
|
||||
width="180">
|
||||
<template slot-scope="scope">
|
||||
<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">
|
||||
|
@ -77,7 +82,7 @@
|
|||
<el-table-column
|
||||
prop="route_exclude"
|
||||
label="路由排除"
|
||||
width="200">
|
||||
width="180">
|
||||
<template slot-scope="scope">
|
||||
<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">
|
||||
|
@ -92,7 +97,7 @@
|
|||
<el-table-column
|
||||
prop="link_acl"
|
||||
label="LINK-ACL"
|
||||
min-width="200">
|
||||
min-width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-row v-for="(item,inx) in scope.row.link_acl.slice(0, readMinRows)" :key="inx">
|
||||
{{ item.action }} => {{ item.val }} : {{ item.port }}
|
||||
|
@ -186,9 +191,9 @@
|
|||
<el-input v-model="ruleForm.note"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="带宽限制" prop="bandwidth">
|
||||
<el-input v-model.number="ruleForm.bandwidth">
|
||||
<template slot="append">BYTE/S</template>
|
||||
<el-form-item label="带宽限制" prop="bandwidth_format" style="width:260px;">
|
||||
<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">Mbps</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="排除本地网络" prop="allow_lan">
|
||||
|
@ -266,7 +271,7 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="用户唯一ID" prop="auth.ldap.search_attr" :rules="this.ruleForm.auth.type== 'ldap' ? this.rules['auth.ldap.search_attr'] : [{ required: false }]">
|
||||
<el-input v-model="ruleForm.auth.ldap.search_attr" placeholder="例如 sAMAccountName / uid / cn"></el-input>
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
<el-form-item label="受限用户组" prop="auth.ldap.member_of">
|
||||
<el-input v-model="ruleForm.auth.ldap.member_of" placeholder="选填, 只允许指定组登入, 例如 CN=HomeWork,DC=abc,DC=com"></el-input>
|
||||
</el-form-item>
|
||||
|
@ -435,6 +440,7 @@ export default {
|
|||
},
|
||||
ruleForm: {
|
||||
bandwidth: 0,
|
||||
bandwidth_format: '0',
|
||||
status: 1,
|
||||
allow_lan: true,
|
||||
client_dns: [{val: '114.114.114.114'}],
|
||||
|
@ -463,9 +469,9 @@ export default {
|
|||
{required: true, message: '请输入组名', trigger: 'blur'},
|
||||
{max: 30, message: '长度小于 30 个字符', trigger: 'blur'}
|
||||
],
|
||||
bandwidth: [
|
||||
bandwidth_format: [
|
||||
{required: true, message: '请输入带宽限制', trigger: 'blur'},
|
||||
{type: 'number', message: '带宽限制必须为数字值'}
|
||||
{type: 'string', message: '带宽限制必须为数字值'}
|
||||
],
|
||||
status: [
|
||||
{required: true}
|
||||
|
@ -493,7 +499,7 @@ export default {
|
|||
],
|
||||
"auth.ldap.search_attr": [
|
||||
{required: true, message: '请输入用户唯一ID', trigger: 'blur'}
|
||||
],
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -536,7 +542,8 @@ export default {
|
|||
id: row.id,
|
||||
}
|
||||
}).then(resp => {
|
||||
this.ruleForm = resp.data.data;
|
||||
resp.data.data.bandwidth_format = this.convertBandwidth(resp.data.data.bandwidth, 'BYTE', 'Mbps').toString();
|
||||
this.ruleForm = resp.data.data;
|
||||
this.setAuthData(resp.data.data);
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
|
@ -582,6 +589,7 @@ export default {
|
|||
console.log('error submit!!');
|
||||
return false;
|
||||
}
|
||||
this.ruleForm.bandwidth = this.convertBandwidth(this.ruleForm.bandwidth_format, 'Mbps', 'BYTE');
|
||||
axios.post('/group/set', this.ruleForm).then(resp => {
|
||||
const rdata = resp.data;
|
||||
if (rdata.code === 0) {
|
||||
|
@ -666,6 +674,18 @@ export default {
|
|||
closeDialog() {
|
||||
this.user_edit_dialog = false;
|
||||
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);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -318,8 +318,7 @@ export default {
|
|||
secretKey: "",
|
||||
},
|
||||
cfcloud: {
|
||||
authEmail: "",
|
||||
authKey: "",
|
||||
authToken: "",
|
||||
},
|
||||
},
|
||||
customCert: { cert: "", key: "" },
|
||||
|
@ -399,19 +398,13 @@ export default {
|
|||
],
|
||||
cfcloud: [
|
||||
{
|
||||
label: "Email",
|
||||
prop: "email",
|
||||
component: "el-input",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
label: "AuthKey",
|
||||
prop: "authKey",
|
||||
label: "AuthToken",
|
||||
prop: "authToken",
|
||||
component: "el-input",
|
||||
type: "password",
|
||||
rules: {
|
||||
required: true,
|
||||
message: "请输入正确的APIKey",
|
||||
message: "请输入正确的AuthToken",
|
||||
trigger: "blur",
|
||||
},
|
||||
},
|
||||
|
@ -551,12 +544,20 @@ export default {
|
|||
});
|
||||
break;
|
||||
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) => {
|
||||
var rdata = resp.data;
|
||||
console.log(rdata);
|
||||
if (rdata.code === 0) {
|
||||
loading.close();
|
||||
this.$message.success(rdata.msg);
|
||||
} else {
|
||||
loading.close();
|
||||
this.$message.error(rdata.msg);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue