more safety for wsproxy.
This commit is contained in:
parent
4fdea6126a
commit
3e2b0eb3fc
@ -47,10 +47,16 @@ module.exports = function wsproxy(options) {
|
|||||||
if (socket)
|
if (socket)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!utils.isNumber(port)
|
||||||
|
|| typeof host !== 'string') {
|
||||||
|
utils.error('Client gave bad arguments.');
|
||||||
|
ws.emit('tcp close');
|
||||||
|
ws.disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (options.pow) {
|
if (options.pow) {
|
||||||
if (!utils.isNumber(port)
|
if (!utils.isNumber(nonce)) {
|
||||||
|| typeof host !== 'string'
|
|
||||||
|| !utils.isNumber(nonce)) {
|
|
||||||
utils.error('Client did not solve proof of work.');
|
utils.error('Client did not solve proof of work.');
|
||||||
ws.emit('tcp close');
|
ws.emit('tcp close');
|
||||||
ws.disconnect();
|
ws.disconnect();
|
||||||
@ -72,6 +78,13 @@ module.exports = function wsproxy(options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!/^[a-zA-Z0-9\.:]+$/.test(host)) {
|
||||||
|
utils.error('Client gave a bad host.');
|
||||||
|
ws.emit('tcp close');
|
||||||
|
ws.disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (IP.isPrivate(host)) {
|
if (IP.isPrivate(host)) {
|
||||||
utils.error('Client is trying to connect to a private ip.');
|
utils.error('Client is trying to connect to a private ip.');
|
||||||
ws.emit('tcp close');
|
ws.emit('tcp close');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user