feat:完善信息

This commit is contained in:
henry
2022-01-24 17:29:02 +08:00
parent 1c0d9dfb6b
commit 26b58e3ca6
6 changed files with 38 additions and 7 deletions

View File

@ -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)