feat:完善信息

This commit is contained in:
henry
2022-01-25 11:45:53 +08:00
parent 26b58e3ca6
commit 932ed31450
13 changed files with 169 additions and 45 deletions

View File

@ -2,11 +2,9 @@ package web
import (
"fmt"
"net"
"net/http"
"os"
"os/signal"
"strings"
"syscall"
"time"
)
@ -61,18 +59,19 @@ func (this *Web) ServeHTTP(w http.ResponseWriter, r *http.Request) {
//remoteUrl, _ := url.Parse("http://192.168.0.147:9000")
fmt.Println(r.Host)
// 获取
ip, _, err := net.SplitHostPort(strings.TrimSpace(r.RemoteAddr))
if err != nil {
_, _ = w.Write([]byte("403: Host forbidden"))
return
}
remoteIP := net.ParseIP(ip)
if remoteIP == nil {
_, _ = w.Write([]byte("403: Host forbidden"))
return
}
//ip, _, err := net.SplitHostPort(strings.TrimSpace(r.RemoteAddr))
//
//if err != nil {
// _, _ = w.Write([]byte("403: Host forbidden"))
// return
//}
//remoteIP := net.ParseIP(ip)
//
//if remoteIP == nil {
// _, _ = w.Write([]byte("403: Host forbidden"))
// return
//}
//fmt.Println(remoteIP)
if this.function != nil {
pass, callback := this.function(r.Host)
@ -86,8 +85,6 @@ func (this *Web) ServeHTTP(w http.ResponseWriter, r *http.Request) {
callback(r)
}
}
//hostProxy[host] = proxy // 放入缓存
//w.Write([]byte("403: Host forbidden " + r.Host))
this.handler.ServeHTTP(w, r)
}