Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getClientIpFromXForwardedFor(value) {
if (!is.existy(value)) {
return null;
}
if (is.not.string(value)) {
throw new TypeError("Expected a string, got \"".concat(_typeof(value), "\""));
} // x-forwarded-for may return multiple IP addresses in the format:
// "client IP, proxy 1 IP, proxy 2 IP"
// Therefore, the right-most IP address is the IP address of the most recent proxy
// and the left-most IP address is the IP address of the originating client.
// source: http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/x-forwarded-headers.html
// Azure Web App's also adds a port for some reason, so we'll only use the first part (the IP)
var forwardedIps = value.split(',').map(function (e) {
var ip = e.trim();
OmxManager.prototype.setConfigurations = function setConfigurations(config) {
// Parameters checking
if (is.not.object(config)) throw new TypeError('Error: config: must be an object.');
// Redirect methods
if (is.existy(config.videosDirectory)) this.setVideosDirectory(config.videosDirectory);
if (is.existy(config.videosExtension)) this.setVideosExtension(config.videosExtension);
if (is.existy(config.omxCommand)) this.setOmxCommand(config.omxCommand);
if (is.existy(config.dbusController)) this.setDbusController(config.dbusController);
};
if (is.existy(req.connection.socket) && is.ip(req.connection.socket.remoteAddress)) {
return req.connection.socket.remoteAddress;
}
}
if (is.existy(req.socket) && is.ip(req.socket.remoteAddress)) {
return req.socket.remoteAddress;
}
if (is.existy(req.info) && is.ip(req.info.remoteAddress)) {
return req.info.remoteAddress;
} // AWS Api Gateway + Lambda
if (is.existy(req.requestContext) && is.existy(req.requestContext.identity) && is.ip(req.requestContext.identity.sourceIp)) {
return req.requestContext.identity.sourceIp;
}
return null;
}
/**
socket.send(path, payload, response => {
if (is.not.undefined(t_o)) {
if (t_o) clearTimeout(t_o);
if (is.existy(response) && is.not.string(response)) cb(response);
else cb(is.empty(response) ? new Error('INVALID_RESPONSE') : new Error(response));
}
});
} catch(e) {
validate(attrs) {
const errObj = {};
const addError = (fieldName, error) => {
errObj[fieldName] = errObj[fieldName] || [];
errObj[fieldName].push(error);
};
if (!is.existy(attrs.name) || is.empty(attrs.name)) {
addError('name', app.polyglot.t('serverConfigModelErrors.provideValue'));
}
if (!is.existy(attrs.serverIp) || is.empty(attrs.serverIp)) {
addError('serverIp', app.polyglot.t('serverConfigModelErrors.provideValue'));
} else {
if (
!is.ip(attrs.serverIp) &&
!is.url(attrs.serverIp) &&
attrs.serverIp !== 'localhost'
) {
addError('serverIp', app.polyglot.t('serverConfigModelErrors.invalidIp'));
}
}
if (!this.isLocalServer()) {
if (!attrs.username) {
addError('username', app.polyglot.t('serverConfigModelErrors.provideValue'));
}
export function rulesRunner(value, schema) {
const fieldState = createNewFieldState();
fieldState.value = value;
if (is.existy(value) && is.not.empty(value)) {
fieldState.status = FieldStatus.ok;
}
return runMatchers(handlerMatcher, fieldState, schema);
}
formState = undefined
) {
const fieldState = { [propName]: newFieldState };
if (formState === undefined) {
update(fieldState);
return;
}
const oldFieldState = formState[propName];
const newFieldState1 = {
...oldFieldState,
...fieldState[propName]
};
if (
is.existy(oldFieldState) &&
is.existy(newFieldState)
) {
if (!shouldChange(oldFieldState, newFieldState)) return;
} else {
return;
}
const finalState = {
...formState,
[propName]: { ...newFieldState1 }
};
update(checkIsFormOK(schema, finalState));
}
options.routingRules.forEach(r => {
if (!is.existy(r.redirect)) {
validationErrors.push('redirect must be specified for each member of routingRules');
}
if (is.existy(r.redirect.replaceKeyPrefixWith) && is.existy(r.redirect.replaceKeyWith)) {
validationErrors.push(
'replaceKeyPrefixWith and replaceKeyWith cannot both be specified for a member of member of routingRules'
);
}
const redirectProps = [
'hostName',
'httpRedirectCode',
'protocol',
'replaceKeyPrefixWith',
'replaceKeyWith'
];
redirectProps.forEach(p => {
if (r.redirect[p]) {
if (p === 'httpRedirectCode') {
if (!is.integer(r.redirect[p])) {
) {
const fieldState = { [propName]: newFieldState };
if (formState === undefined) {
update(fieldState);
return;
}
const oldFieldState = formState[propName];
const newFieldState1 = {
...oldFieldState,
...fieldState[propName]
};
if (
is.existy(oldFieldState) &&
is.existy(newFieldState)
) {
if (!shouldChange(oldFieldState, newFieldState)) return;
} else {
return;
}
const finalState = {
...formState,
[propName]: { ...newFieldState1 }
};
update(checkIsFormOK(schema, finalState));
}