|
|
@ -1,6 +1,6 @@ |
|
|
|
import * as WS from 'ws' |
|
|
|
import * as WS from 'ws' |
|
|
|
import * as http from 'http' |
|
|
|
import * as http from 'http' |
|
|
|
import { WebsocketOpt, ServiceClient } from './types' // eslint-disable-line
|
|
|
|
import { WebsocketOpt, ServiceClient } from './types' |
|
|
|
import { getDomain } from './utils' |
|
|
|
import { getDomain } from './utils' |
|
|
|
import { createClient } from '@remixproject/plugin-ws' |
|
|
|
import { createClient } from '@remixproject/plugin-ws' |
|
|
|
export default class WebSocket { |
|
|
|
export default class WebSocket { |
|
|
@ -18,14 +18,14 @@ export default class WebSocket { |
|
|
|
const loopback = '127.0.0.1' |
|
|
|
const loopback = '127.0.0.1' |
|
|
|
|
|
|
|
|
|
|
|
this.server.listen(this.port, loopback, () => { |
|
|
|
this.server.listen(this.port, loopback, () => { |
|
|
|
console.log((new Date()) + ' remixd is listening on ' + loopback + ':' + this.port + '') |
|
|
|
console.log(`${new Date()} remixd is listening on ${loopback}:${this.port}`) |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.wsServer = new WS.Server({ |
|
|
|
this.wsServer = new WS.Server({ |
|
|
|
server: this.server, |
|
|
|
server: this.server, |
|
|
|
verifyClient: (info, done) => { |
|
|
|
verifyClient: (info, done) => { |
|
|
|
if (!originIsAllowed(info.origin, this)) { |
|
|
|
if (!originIsAllowed(info.origin, this)) { |
|
|
|
done(false) |
|
|
|
done(false) |
|
|
|
console.log((new Date()) + ' Connection from origin ' + info.origin + ' rejected.') |
|
|
|
console.log(`${new Date()} connection from origin ${info.origin}`)
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
done(true) |
|
|
|
done(true) |
|
|
|