Skip to content

Commit

Permalink
add sample
Browse files Browse the repository at this point in the history
  • Loading branch information
joneugster committed Oct 1, 2024
1 parent 6a8abf4 commit b77afeb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion relay/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const server = app
const owner = req.params.owner;
const repo = req.params.repo
const lang = req.params.lang

const ip = anonymize(req.headers['x-forwarded-for'] || req.socket.remoteAddress)
console.log(`[${new Date()}] ${ip} requested translation for ${owner}/${repo} in ${lang}`)

const filename = req.params[0];
req.url = filename;
express.static(path.join(getGameDir(owner,repo),".i18n",lang))(req, res, next);
Expand Down Expand Up @@ -207,7 +211,9 @@ wss.addListener("connection", function(ws, req) {

socketCounter += 1;
const ip = anonymize(req.headers['x-forwarded-for'] || req.socket.remoteAddress)
console.log(`[${new Date()}] Socket opened - ${ip}`)

// TODO (Matvey): extract further information from `req`, for example browser language.
console.log(`[${new Date()}] Socket opened - ${ip} - ${owner}/${repo}`)

const socket = {
onMessage: (cb) => { ws.on("message", cb) },
Expand Down

0 comments on commit b77afeb

Please sign in to comment.