@@ -83,15 +83,6 @@ func basicProxyAuth(proxyAuth string) (username, password string, ok bool) {
83
83
}
84
84
85
85
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
-
95
86
if auth == authOn {
96
87
_ , p , ok := basicProxyAuth (r .Header .Get ("Proxy-Authorization" ))
97
88
if ! ok {
@@ -107,6 +98,15 @@ func handler(w http.ResponseWriter, r *http.Request) {
107
98
r .Header .Del ("Proxy-Authorization" )
108
99
}
109
100
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
+
110
110
if r .Method == http .MethodConnect {
111
111
handleTunneling (w , r )
112
112
} else {
0 commit comments