Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!(userid in userMap)) {
userMap[userid] = {
websockets: [],
lastBroadcast: 0
};
} else if (userMap[userid].websockets.includes(ws)) {
return;
}
// Lookup ip info
const lu = geoip.lookup(req.connection.remoteAddress);
ws._sessionInfo = {
id: Math.floor(Math.random() * 1e15).toString(16) + Date.now().toString(16),
city: lu ? lu.city : 'Unknown',
country: lu ? i18nCountries.getName(lu.country, 'en') : 'Unknown',
device: userAgentParser(req.headers['user-agent'])
};
// Push to redis
redisClient.rpush(userid.toString(), JSON.stringify(ws._sessionInfo));
websocket.broadcast({
userid,
data: {
type: 'open-session',
value: ws._sessionInfo
}
});
// Append websocket
userMap[userid].websockets.push(ws);
import promise from 'redux-promise';
// import css from './style.css';
import css from './toolkit-inverse.css';
import application_css from './application.css';
import routes from './routes';
import { Websocket } from './components/index';
import App from './components/app';
import reducers from './reducers';
import { syncHistoryWithStore, ConnectedRouter, routerReducer, routerMiddleware, push } from 'react-router-redux'
import * as countries from 'i18n-iso-countries';
countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
const history = createHistory();
function configureStore() {
return createStore(
reducers,
{},
applyMiddleware(
routerMiddleware(history),
promise,
),
);
}
const store = configureStore({
sessions: { all: [], events: [], session: null, content: [], metadata: null, hotCountries: [], connected: false, topology: {} },
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import moment from 'moment';
import i18nIsoCode from 'i18n-iso-countries';
import en from '~/locales/en.json';
import fr from '~/locales/fr.json';
i18nIsoCode.registerLocale(require('i18n-iso-countries/langs/en.json'));
i18nIsoCode.registerLocale(require('i18n-iso-countries/langs/fr.json'));
Vue.use(VueI18n);
moment.locale('fr');
export default ({ app }) => {
// Set i18n instance on app
// This way we can use it in middleware and pages asyncData/fetch
app.i18n = new VueI18n({
locale: 'fr',
fallbackLocale: 'fr',
messages: {
en,
fr
}
});
const splittedLang = lang.split(splitLangRgx);
if (splittedLang.length < 1) {
return lang;
}
let standardLang =
splittedLang[0].length === 3
? alpha3TToAlpha2(splittedLang[0])
: splittedLang[0];
if (splittedLang.length === 1) {
return standardLang;
}
let standardCountry =
splittedLang[1].length === 3
? alpha3ToAlpha2(splittedLang[1])
: splittedLang[1];
return `${standardLang}-${standardCountry}`;
}
.map(companyInfo =>
countries.getName(companyInfo.company.country, "en")
)
getCountryName: function (name) {
var countries = require('i18n-iso-countries')
return countries.getName(name, 'en')
},
copyToClipboard: function(){
fromAlpha2Code: code => {
return {
name: countries.getName(code, 'en'),
emoji: flag(code),
};
},
};
.map(companyInfo =>
countries.getName(companyInfo.company.country, "en")
)
generateLadderEmbedTitle ({ type, country_code: cc }, t, language) {
const title = t(`commands:steamladder.ladders.${type}`)
if (cc) {
const suffix = ` - ${title}`
if (this.client.i18next.exists(`commands:steamladder.regions.${cc}`)) {
return t(`commands:steamladder.regions.${cc}`) + suffix
} else if (countries.getName(cc, language.substring(0, 2))) {
return countries.getName(cc, language.substring(0, 2)) + suffix
} else {
return cc + suffix
}
}
return title
}
case 'SYR':
return 'Syria';
case 'MKD':
return 'Macedonia';
case 'IRN':
return 'Iran';
case 'LBY':
return 'Libya';
case 'RUS':
return 'Russia';
case 'RCB':
return 'Congo';
case 'COD':
return 'Congo';
}
return countries.getName(country, 'en');
};