mirror of https://github.com/bjdgyc/anylink.git
注释一些未使用的函数,修改一处语法,更改io库
This commit is contained in:
parent
8b1098917f
commit
19bda654ff
|
@ -4,7 +4,6 @@ import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
@ -28,7 +27,7 @@ func LinkAuth(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
@ -188,39 +187,40 @@ var auth_complete = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
</config-auth>
|
</config-auth>
|
||||||
`
|
`
|
||||||
|
|
||||||
var auth_profile = `<?xml version="1.0" encoding="UTF-8"?>
|
// var auth_profile = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<AnyConnectProfile xmlns="http://schemas.xmlsoap.org/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.xmlsoap.org/encoding/ AnyConnectProfile.xsd">
|
// <AnyConnectProfile xmlns="http://schemas.xmlsoap.org/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.xmlsoap.org/encoding/ AnyConnectProfile.xsd">
|
||||||
|
|
||||||
<ClientInitialization>
|
// <ClientInitialization>
|
||||||
<UseStartBeforeLogon UserControllable="false">false</UseStartBeforeLogon>
|
// <UseStartBeforeLogon UserControllable="false">false</UseStartBeforeLogon>
|
||||||
<StrictCertificateTrust>false</StrictCertificateTrust>
|
// <StrictCertificateTrust>false</StrictCertificateTrust>
|
||||||
<RestrictPreferenceCaching>false</RestrictPreferenceCaching>
|
// <RestrictPreferenceCaching>false</RestrictPreferenceCaching>
|
||||||
<RestrictTunnelProtocols>IPSec</RestrictTunnelProtocols>
|
// <RestrictTunnelProtocols>IPSec</RestrictTunnelProtocols>
|
||||||
<BypassDownloader>true</BypassDownloader>
|
// <BypassDownloader>true</BypassDownloader>
|
||||||
<WindowsVPNEstablishment>AllowRemoteUsers</WindowsVPNEstablishment>
|
// <WindowsVPNEstablishment>AllowRemoteUsers</WindowsVPNEstablishment>
|
||||||
<CertEnrollmentPin>pinAllowed</CertEnrollmentPin>
|
// <CertEnrollmentPin>pinAllowed</CertEnrollmentPin>
|
||||||
<CertificateMatch>
|
// <CertificateMatch>
|
||||||
<KeyUsage>
|
// <KeyUsage>
|
||||||
<MatchKey>Digital_Signature</MatchKey>
|
// <MatchKey>Digital_Signature</MatchKey>
|
||||||
</KeyUsage>
|
// </KeyUsage>
|
||||||
<ExtendedKeyUsage>
|
// <ExtendedKeyUsage>
|
||||||
<ExtendedMatchKey>ClientAuth</ExtendedMatchKey>
|
// <ExtendedMatchKey>ClientAuth</ExtendedMatchKey>
|
||||||
</ExtendedKeyUsage>
|
// </ExtendedKeyUsage>
|
||||||
</CertificateMatch>
|
// </CertificateMatch>
|
||||||
|
|
||||||
<BackupServerList>
|
// <BackupServerList>
|
||||||
<HostAddress>localhost</HostAddress>
|
// <HostAddress>localhost</HostAddress>
|
||||||
</BackupServerList>
|
// </BackupServerList>
|
||||||
</ClientInitialization>
|
// </ClientInitialization>
|
||||||
|
|
||||||
<ServerList>
|
// <ServerList>
|
||||||
<HostEntry>
|
// <HostEntry>
|
||||||
<HostName>VPN Server</HostName>
|
// <HostName>VPN Server</HostName>
|
||||||
<HostAddress>localhost</HostAddress>
|
// <HostAddress>localhost</HostAddress>
|
||||||
</HostEntry>
|
// </HostEntry>
|
||||||
</ServerList>
|
// </ServerList>
|
||||||
</AnyConnectProfile>
|
//
|
||||||
`
|
// </AnyConnectProfile>
|
||||||
|
// `
|
||||||
var ds_domains_xml = `
|
var ds_domains_xml = `
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<config-auth client="vpn" type="complete" aggregate-auth-version="2">
|
<config-auth client="vpn" type="complete" aggregate-auth-version="2">
|
||||||
|
|
|
@ -33,7 +33,7 @@ func checkMacvtap() {
|
||||||
|
|
||||||
ifName := "anylinkMacvtap"
|
ifName := "anylinkMacvtap"
|
||||||
// 加载 macvtap
|
// 加载 macvtap
|
||||||
cmdstr0 := fmt.Sprintf("modprobe -i macvtap")
|
cmdstr0 := fmt.Sprintln("modprobe -i macvtap")
|
||||||
// 开启主网卡混杂模式
|
// 开启主网卡混杂模式
|
||||||
cmdstr1 := fmt.Sprintf("ip link set dev %s promisc on", base.Cfg.Ipv4Master)
|
cmdstr1 := fmt.Sprintf("ip link set dev %s promisc on", base.Cfg.Ipv4Master)
|
||||||
// 测试 macvtap 功能
|
// 测试 macvtap 功能
|
||||||
|
@ -66,9 +66,9 @@ func LinkMacvtap(cSess *sessdata.ConnSession) error {
|
||||||
return createVtap(cSess, ifName)
|
return createVtap(cSess, ifName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkIpvtap() {
|
// func checkIpvtap() {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 创建 Ipvtap 网卡
|
// 创建 Ipvtap 网卡
|
||||||
func LinkIpvtap(cSess *sessdata.ConnSession) error {
|
func LinkIpvtap(cSess *sessdata.ConnSession) error {
|
||||||
|
|
|
@ -55,38 +55,38 @@ var bytePool = sync.Pool{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func getByteZero() *[]byte {
|
// func getByteZero() *[]byte {
|
||||||
b := bytePool.Get().(*[]byte)
|
// b := bytePool.Get().(*[]byte)
|
||||||
*b = (*b)[:0]
|
// *b = (*b)[:0]
|
||||||
return b
|
// return b
|
||||||
}
|
// }
|
||||||
|
|
||||||
func getByteFull() *[]byte {
|
// func getByteFull() *[]byte {
|
||||||
b := bytePool.Get().(*[]byte)
|
// b := bytePool.Get().(*[]byte)
|
||||||
return b
|
// return b
|
||||||
}
|
// }
|
||||||
func putByte(b *[]byte) {
|
// func putByte(b *[]byte) {
|
||||||
*b = (*b)[:BufferSize]
|
// *b = (*b)[:BufferSize]
|
||||||
bytePool.Put(b)
|
// bytePool.Put(b)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 长度 34 小对象
|
// // 长度 34 小对象
|
||||||
var byte34Pool = sync.Pool{
|
// var byte34Pool = sync.Pool{
|
||||||
New: func() interface{} {
|
// New: func() interface{} {
|
||||||
b := make([]byte, 34)
|
// b := make([]byte, 34)
|
||||||
return &b
|
// return &b
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
|
|
||||||
func getByte34() *[]byte {
|
// func getByte34() *[]byte {
|
||||||
b := byte34Pool.Get().(*[]byte)
|
// b := byte34Pool.Get().(*[]byte)
|
||||||
return b
|
// return b
|
||||||
}
|
// }
|
||||||
|
|
||||||
func putByte34(b *[]byte) {
|
// func putByte34(b *[]byte) {
|
||||||
*b = (*b)[:34]
|
// *b = (*b)[:34]
|
||||||
byte34Pool.Put(b)
|
// byte34Pool.Put(b)
|
||||||
}
|
// }
|
||||||
|
|
||||||
type BufferPool struct {
|
type BufferPool struct {
|
||||||
sync.Pool
|
sync.Pool
|
||||||
|
|
Loading…
Reference in New Issue