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: Mask IP Address
|
||||||
// TODO: Query DB to determine whether visitor is returning
|
// 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()
|
q := r.URL.Query()
|
||||||
visit := models.Visit{
|
visit := models.Visit{
|
||||||
Path: q.Get("p"),
|
Path: q.Get("p"),
|
||||||
IpAddress: r.RemoteAddr,
|
IpAddress: ipAddress,
|
||||||
ReferrerUrl: q.Get("r"),
|
ReferrerUrl: q.Get("r"),
|
||||||
BrowserLanguage: q.Get("l"),
|
BrowserLanguage: q.Get("l"),
|
||||||
ScreenResolution: q.Get("sr"),
|
ScreenResolution: q.Get("sr"),
|
||||||
|
@ -12,17 +12,18 @@ class Realtime extends Component {
|
|||||||
}
|
}
|
||||||
this.fetchData = this.fetchData.bind(this);
|
this.fetchData = this.fetchData.bind(this);
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
|
window.setInterval(this.fetchData, 6000);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchData() {
|
fetchData() {
|
||||||
return fetch('/api/visits/count/realtime', {
|
return fetch('/api/visits/count/realtime', {
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
}).then((r) => {
|
}).then((r) => {
|
||||||
if( r.ok ) { r.json(); }
|
if( r.ok ) { return r.json(); }
|
||||||
throw new Error();
|
throw new Error();
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
this.setState({ count: data })
|
this.setState({ count: data })
|
||||||
}).catch((e) => {});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user