Commit 439f4f08 authored by vicotor's avatar vicotor

add log

parent 0590905d
Pipeline #899 failed with stages
...@@ -88,6 +88,10 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) { ...@@ -88,6 +88,10 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
} }
if req.Method == "eth_getBalance" && len(req.Params) > 0 { if req.Method == "eth_getBalance" && len(req.Params) > 0 {
// get remote ip from header
xForwardedFor := r.Header.Get("X-Forwarded-For")
realIp := r.Header.Get("X-Real-IP")
log.Printf("eth_getBalance request from %s, X-Real-IP: %s, X-Forwarded-For: %s, address: %v", r.RemoteAddr, realIp, xForwardedFor, req.Params[0])
address, ok := req.Params[0].(string) address, ok := req.Params[0].(string)
if !ok { if !ok {
forwardToBackend(w, body) forwardToBackend(w, body)
...@@ -99,6 +103,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) { ...@@ -99,6 +103,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
Id: req.Id, Id: req.Id,
Result: "0x0", Result: "0x0",
} }
log.Printf("stop forward to rpc on eth_getBalance request from %s, X-Real-IP: %s, X-Forwarded-For: %s, address: %v", r.RemoteAddr, realIp, xForwardedFor, req.Params[0])
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(resp) json.NewEncoder(w).Encode(resp)
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment