mirror of
				https://github.com/bjdgyc/anylink.git
				synced 2025-11-01 00:59:34 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			40 lines
		
	
	
		
			988 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			988 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package handler
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"net/http"
 | |
| 	"strings"
 | |
| 
 | |
| 	"github.com/bjdgyc/anylink/admin"
 | |
| )
 | |
| 
 | |
| 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") {
 | |
| 		w.Header().Set("Connection", "close")
 | |
| 		w.WriteHeader(http.StatusBadRequest)
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	w.WriteHeader(http.StatusOK)
 | |
| 	fmt.Fprintln(w, "AnyLink 是一个企业级远程办公 sslvpn 的软件,可以支持多人同时在线使用。")
 | |
| }
 | |
| 
 | |
| func LinkOtpQr(w http.ResponseWriter, r *http.Request) {
 | |
| 	_ = r.ParseForm()
 | |
| 	idS := r.FormValue("id")
 | |
| 	jwtToken := r.FormValue("jwt")
 | |
| 	data, err := admin.GetJwtData(jwtToken)
 | |
| 	if err != nil || idS != fmt.Sprint(data["id"]) {
 | |
| 		w.WriteHeader(http.StatusForbidden)
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	admin.UserOtpQr(w, r)
 | |
| }
 |