mirror of
				https://github.com/bjdgyc/anylink.git
				synced 2025-11-01 00:59:34 +08:00 
			
		
		
		
	
							
								
								
									
										1
									
								
								server/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								server/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -18,3 +18,4 @@ ui/ | ||||
| .idea/ | ||||
| anylink | ||||
| data.db | ||||
| conf/*.db | ||||
| @@ -88,6 +88,7 @@ func addInitData() error { | ||||
| 	other := &SettingOther{ | ||||
| 		LinkAddr:    "vpn.xx.com", | ||||
| 		Banner:      "您已接入公司网络,请按照公司规定使用。\n请勿进行非工作下载及视频行为!", | ||||
| 		Homeindex:   "AnyLink 是一个企业级远程办公 sslvpn 的软件,可以支持多人同时在线使用。", | ||||
| 		AccountMail: accountMail, | ||||
| 	} | ||||
| 	err = SettingSessAdd(sess, other) | ||||
|   | ||||
| @@ -22,6 +22,7 @@ type SettingSmtp struct { | ||||
| type SettingOther struct { | ||||
| 	LinkAddr    string `json:"link_addr"` | ||||
| 	Banner      string `json:"banner"` | ||||
| 	Homeindex   string `json:"homeindex"` | ||||
| 	AccountMail string `json:"account_mail"` | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -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"> | ||||
|   | ||||
| @@ -6,13 +6,13 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/bjdgyc/anylink/admin" | ||||
| 	"github.com/bjdgyc/anylink/dbdata" | ||||
| ) | ||||
|  | ||||
| func LinkHome(w http.ResponseWriter, r *http.Request) { | ||||
| 	// fmt.Println(r.RemoteAddr) | ||||
| 	// hu, _ := httputil.DumpRequest(r, true) | ||||
| 	// fmt.Println("DumpHome: ", string(hu)) | ||||
|  | ||||
| 	connection := strings.ToLower(r.Header.Get("Connection")) | ||||
| 	userAgent := strings.ToLower(r.UserAgent()) | ||||
| 	if connection == "close" && (strings.Contains(userAgent, "anyconnect") || strings.Contains(userAgent, "openconnect")) { | ||||
| @@ -20,9 +20,11 @@ func LinkHome(w http.ResponseWriter, r *http.Request) { | ||||
| 		w.WriteHeader(http.StatusBadRequest) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	index := &dbdata.SettingOther{} | ||||
| 	dbdata.SettingGet(index) | ||||
| 	w.WriteHeader(http.StatusOK) | ||||
| 	fmt.Fprintln(w, "AnyLink 是一个企业级远程办公 sslvpn 的软件,可以支持多人同时在线使用。") | ||||
| 	fmt.Fprintln(w, index.Homeindex) | ||||
| 	// fmt.Fprintln(w, "AnyLink 是一个企业级远程办公 sslvpn 的软件,可以支持多人同时在线使用。") | ||||
| } | ||||
|  | ||||
| func LinkOtpQr(w http.ResponseWriter, r *http.Request) { | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
							
								
								
									
										0
									
								
								server/handler/pool.go
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								server/handler/pool.go
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -51,6 +51,15 @@ | ||||
|             </el-input> | ||||
|           </el-form-item> | ||||
|  | ||||
|           <el-form-item label="自定义首页" prop="homeindex"> | ||||
|             <el-input | ||||
|                 type="textarea" | ||||
|                 :rows="5" | ||||
|                 placeholder="请输入内容" | ||||
|                 v-model="dataOther.homeindex"> | ||||
|             </el-input> | ||||
|           </el-form-item> | ||||
|  | ||||
|           <el-form-item label="账户开通邮件" prop="account_mail"> | ||||
|             <el-input | ||||
|                 type="textarea" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user