feat:完善信息
This commit is contained in:
@ -2,9 +2,11 @@ package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
@ -58,7 +60,19 @@ func WithFunction(function func(string) (bool, func(r *http.Request))) Option {
|
||||
func (this *Web) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
//remoteUrl, _ := url.Parse("http://192.168.0.147:9000")
|
||||
fmt.Println(r.Host)
|
||||
//fmt.Println(r.RequestURI)
|
||||
// 获取
|
||||
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
|
||||
}
|
||||
|
||||
if this.function != nil {
|
||||
pass, callback := this.function(r.Host)
|
||||
|
Reference in New Issue
Block a user