Skip to content

Commit 1534816

Browse files
committed
chore: small adjustment
1 parent 0511ea9 commit 1534816

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

main.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,6 @@ func basicProxyAuth(proxyAuth string) (username, password string, ok bool) {
8383
}
8484

8585
func handler(w http.ResponseWriter, r *http.Request) {
86-
addrPort, err := netip.ParseAddrPort(r.RemoteAddr)
87-
if err != nil {
88-
log.Printf("parse addrPort %s failed: %s", r.RemoteAddr, err.Error())
89-
http.Error(w, "bad request", http.StatusBadRequest)
90-
return
91-
}
92-
93-
log.Printf("%-15s %-7s %s %s", addrPort.Addr(), r.Method, r.Host, r.URL.Path)
94-
9586
if auth == authOn {
9687
_, p, ok := basicProxyAuth(r.Header.Get("Proxy-Authorization"))
9788
if !ok {
@@ -107,6 +98,15 @@ func handler(w http.ResponseWriter, r *http.Request) {
10798
r.Header.Del("Proxy-Authorization")
10899
}
109100

101+
addrPort, err := netip.ParseAddrPort(r.RemoteAddr)
102+
if err != nil {
103+
log.Printf("parse addrPort %s failed: %s", r.RemoteAddr, err.Error())
104+
http.Error(w, "bad request", http.StatusBadRequest)
105+
return
106+
}
107+
108+
log.Printf("%-15s %-7s %s %s", addrPort.Addr(), r.Method, r.Host, r.URL.Path)
109+
110110
if r.Method == http.MethodConnect {
111111
handleTunneling(w, r)
112112
} else {

0 commit comments

Comments
 (0)