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"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
@ -28,7 +27,7 @@ func LinkAuth(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
|
@ -188,39 +187,40 @@ var auth_complete = `<?xml version="1.0" encoding="UTF-8"?>
|
|||
</config-auth>
|
||||
`
|
||||
|
||||
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">
|
||||
// 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">
|
||||
|
||||
<ClientInitialization>
|
||||
<UseStartBeforeLogon UserControllable="false">false</UseStartBeforeLogon>
|
||||
<StrictCertificateTrust>false</StrictCertificateTrust>
|
||||
<RestrictPreferenceCaching>false</RestrictPreferenceCaching>
|
||||
<RestrictTunnelProtocols>IPSec</RestrictTunnelProtocols>
|
||||
<BypassDownloader>true</BypassDownloader>
|
||||
<WindowsVPNEstablishment>AllowRemoteUsers</WindowsVPNEstablishment>
|
||||
<CertEnrollmentPin>pinAllowed</CertEnrollmentPin>
|
||||
<CertificateMatch>
|
||||
<KeyUsage>
|
||||
<MatchKey>Digital_Signature</MatchKey>
|
||||
</KeyUsage>
|
||||
<ExtendedKeyUsage>
|
||||
<ExtendedMatchKey>ClientAuth</ExtendedMatchKey>
|
||||
</ExtendedKeyUsage>
|
||||
</CertificateMatch>
|
||||
// <ClientInitialization>
|
||||
// <UseStartBeforeLogon UserControllable="false">false</UseStartBeforeLogon>
|
||||
// <StrictCertificateTrust>false</StrictCertificateTrust>
|
||||
// <RestrictPreferenceCaching>false</RestrictPreferenceCaching>
|
||||
// <RestrictTunnelProtocols>IPSec</RestrictTunnelProtocols>
|
||||
// <BypassDownloader>true</BypassDownloader>
|
||||
// <WindowsVPNEstablishment>AllowRemoteUsers</WindowsVPNEstablishment>
|
||||
// <CertEnrollmentPin>pinAllowed</CertEnrollmentPin>
|
||||
// <CertificateMatch>
|
||||
// <KeyUsage>
|
||||
// <MatchKey>Digital_Signature</MatchKey>
|
||||
// </KeyUsage>
|
||||
// <ExtendedKeyUsage>
|
||||
// <ExtendedMatchKey>ClientAuth</ExtendedMatchKey>
|
||||
// </ExtendedKeyUsage>
|
||||
// </CertificateMatch>
|
||||
|
||||
<BackupServerList>
|
||||
<HostAddress>localhost</HostAddress>
|
||||
</BackupServerList>
|
||||
</ClientInitialization>
|
||||
// <BackupServerList>
|
||||
// <HostAddress>localhost</HostAddress>
|
||||
// </BackupServerList>
|
||||
// </ClientInitialization>
|
||||
|
||||
<ServerList>
|
||||
<HostEntry>
|
||||
<HostName>VPN Server</HostName>
|
||||
<HostAddress>localhost</HostAddress>
|
||||
</HostEntry>
|
||||
</ServerList>
|
||||
</AnyConnectProfile>
|
||||
`
|
||||
// <ServerList>
|
||||
// <HostEntry>
|
||||
// <HostName>VPN Server</HostName>
|
||||
// <HostAddress>localhost</HostAddress>
|
||||
// </HostEntry>
|
||||
// </ServerList>
|
||||
//
|
||||
// </AnyConnectProfile>
|
||||
// `
|
||||
var ds_domains_xml = `
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config-auth client="vpn" type="complete" aggregate-auth-version="2">
|
||||
|
|
|
@ -33,7 +33,7 @@ func checkMacvtap() {
|
|||
|
||||
ifName := "anylinkMacvtap"
|
||||
// 加载 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)
|
||||
// 测试 macvtap 功能
|
||||
|
@ -66,9 +66,9 @@ func LinkMacvtap(cSess *sessdata.ConnSession) error {
|
|||
return createVtap(cSess, ifName)
|
||||
}
|
||||
|
||||
func checkIpvtap() {
|
||||
// func checkIpvtap() {
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
// 创建 Ipvtap 网卡
|
||||
func LinkIpvtap(cSess *sessdata.ConnSession) error {
|
||||
|
|
|
@ -55,38 +55,38 @@ var bytePool = sync.Pool{
|
|||
},
|
||||
}
|
||||
|
||||
func getByteZero() *[]byte {
|
||||
b := bytePool.Get().(*[]byte)
|
||||
*b = (*b)[:0]
|
||||
return b
|
||||
}
|
||||
// func getByteZero() *[]byte {
|
||||
// b := bytePool.Get().(*[]byte)
|
||||
// *b = (*b)[:0]
|
||||
// return b
|
||||
// }
|
||||
|
||||
func getByteFull() *[]byte {
|
||||
b := bytePool.Get().(*[]byte)
|
||||
return b
|
||||
}
|
||||
func putByte(b *[]byte) {
|
||||
*b = (*b)[:BufferSize]
|
||||
bytePool.Put(b)
|
||||
}
|
||||
// func getByteFull() *[]byte {
|
||||
// b := bytePool.Get().(*[]byte)
|
||||
// return b
|
||||
// }
|
||||
// func putByte(b *[]byte) {
|
||||
// *b = (*b)[:BufferSize]
|
||||
// bytePool.Put(b)
|
||||
// }
|
||||
|
||||
// 长度 34 小对象
|
||||
var byte34Pool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
b := make([]byte, 34)
|
||||
return &b
|
||||
},
|
||||
}
|
||||
// // 长度 34 小对象
|
||||
// var byte34Pool = sync.Pool{
|
||||
// New: func() interface{} {
|
||||
// b := make([]byte, 34)
|
||||
// return &b
|
||||
// },
|
||||
// }
|
||||
|
||||
func getByte34() *[]byte {
|
||||
b := byte34Pool.Get().(*[]byte)
|
||||
return b
|
||||
}
|
||||
// func getByte34() *[]byte {
|
||||
// b := byte34Pool.Get().(*[]byte)
|
||||
// return b
|
||||
// }
|
||||
|
||||
func putByte34(b *[]byte) {
|
||||
*b = (*b)[:34]
|
||||
byte34Pool.Put(b)
|
||||
}
|
||||
// func putByte34(b *[]byte) {
|
||||
// *b = (*b)[:34]
|
||||
// byte34Pool.Put(b)
|
||||
// }
|
||||
|
||||
type BufferPool struct {
|
||||
sync.Pool
|
||||
|
|
Loading…
Reference in New Issue