mirror of
https://github.com/status-im/fathom.git
synced 2025-03-01 03:20:27 +00:00
add suport for x-forwarded-for header
This commit is contained in:
parent
78932ede14
commit
3c77eb14b1
@ -34,11 +34,16 @@ func CollectHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// TODO: Mask IP Address
|
||||
// TODO: Query DB to determine whether visitor is returning
|
||||
ipAddress := r.RemoteAddr
|
||||
headerForwardedFor := r.Header.Get("X-Forwarded-For")
|
||||
if( headerForwardedFor != "" ) {
|
||||
ipAddress = headerForwardedFor
|
||||
}
|
||||
|
||||
q := r.URL.Query()
|
||||
visit := models.Visit{
|
||||
Path: q.Get("p"),
|
||||
IpAddress: r.RemoteAddr,
|
||||
IpAddress: ipAddress,
|
||||
ReferrerUrl: q.Get("r"),
|
||||
BrowserLanguage: q.Get("l"),
|
||||
ScreenResolution: q.Get("sr"),
|
||||
|
@ -12,17 +12,18 @@ class Realtime extends Component {
|
||||
}
|
||||
this.fetchData = this.fetchData.bind(this);
|
||||
this.fetchData();
|
||||
window.setInterval(this.fetchData, 6000);
|
||||
}
|
||||
|
||||
fetchData() {
|
||||
return fetch('/api/visits/count/realtime', {
|
||||
credentials: 'include'
|
||||
}).then((r) => {
|
||||
if( r.ok ) { r.json(); }
|
||||
if( r.ok ) { return r.json(); }
|
||||
throw new Error();
|
||||
}).then((data) => {
|
||||
this.setState({ count: data })
|
||||
}).catch((e) => {});
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user