mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-10 12:15:34 +00:00
replaced fxa-geodb with load balancer header
This commit is contained in:
@@ -11,6 +11,8 @@ module.exports = async function(req, res) {
|
||||
statDeleteEvent({
|
||||
id,
|
||||
ip: req.ip,
|
||||
country: req.geo.country,
|
||||
state: req.geo.state,
|
||||
owner: meta.owner,
|
||||
download_count: meta.dl,
|
||||
ttl,
|
||||
|
||||
@@ -31,6 +31,8 @@ module.exports = async function(req, res) {
|
||||
statDownloadEvent({
|
||||
id,
|
||||
ip: req.ip,
|
||||
country: req.geo.country,
|
||||
state: req.geo.state,
|
||||
owner: meta.owner,
|
||||
download_count: dl,
|
||||
ttl,
|
||||
|
||||
@@ -93,6 +93,19 @@ module.exports = function(app) {
|
||||
);
|
||||
next();
|
||||
});
|
||||
app.use(function(req, res, next) {
|
||||
try {
|
||||
// set by the load balancer
|
||||
const [country, state] = req.header('X-Client-Geo-Location').split(',');
|
||||
req.geo = {
|
||||
country,
|
||||
state
|
||||
};
|
||||
} catch (e) {
|
||||
req.geo = {};
|
||||
}
|
||||
next();
|
||||
});
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.text());
|
||||
app.get('/', language, pages.index);
|
||||
|
||||
@@ -12,7 +12,8 @@ module.exports = async function(req, res) {
|
||||
data.session_id + deltaT,
|
||||
deltaT,
|
||||
data.platform,
|
||||
req.ip
|
||||
req.geo.country,
|
||||
req.geo.state
|
||||
)
|
||||
);
|
||||
const status = await sendBatch(events);
|
||||
|
||||
@@ -9,6 +9,8 @@ module.exports = async function(req, res) {
|
||||
statReportEvent({
|
||||
id,
|
||||
ip: req.ip,
|
||||
country: req.geo.country,
|
||||
state: req.geo.state,
|
||||
owner: meta.owner,
|
||||
reason: req.body.reason,
|
||||
download_limit: meta.dlimit,
|
||||
|
||||
@@ -111,6 +111,8 @@ module.exports = function(ws, req) {
|
||||
statUploadEvent({
|
||||
id: newId,
|
||||
ip: req.ip,
|
||||
country: req.geo.country,
|
||||
state: req.geo.state,
|
||||
owner,
|
||||
dlimit,
|
||||
timeLimit,
|
||||
|
||||
Reference in New Issue
Block a user