feat:完善信息
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user