Skip to content

Commit

Permalink
update socket.io version
Browse files Browse the repository at this point in the history
  • Loading branch information
butlerx committed Feb 19, 2022
1 parent 24f5279 commit 17b75c9
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 308 deletions.
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
"parseurl": "^1.3.3",
"prom-client": "^14.0.1",
"sass": "^1.26.10",
"socket.io": "^2.3.0",
"socket.io-client": "^2.3.0",
"socket.io": "^4.4.1",
"socket.io-client": "^4.4.1",
"toastify-js": "^1.9.1",
"winston": "^3.3.3",
"xterm": "^4.8.1",
Expand All @@ -146,30 +146,30 @@
"@types/node": "^14.6.3",
"@types/parseurl": "^1.3.1",
"@types/sinon": "^7.5.1",
"@types/socket.io": "^2.1.11",
"@types/socket.io-client": "^1.4.33",
"@types/socket.io": "^3.0.2",
"@types/socket.io-client": "^3.0.0",
"@types/toastify-js": "^1.9.2",
"@types/winston": "^2.4.4",
"@types/yargs": "^15.0.5",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"all-contributors-cli": "^6.17.2",
"chai": "^4.2.0",
"concurrently": "^5.2.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint": "^8.9.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.4.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-mocha": "^10.0.3",
"eslint-plugin-prettier": "^4.0.0",
"git-authors-cli": "^1.0.28",
"husky": "^4.2.5",
"jsdom": "^15.2.1",
"lint-staged": "^10.2.13",
"mocha": "^8.1.3",
"nodemon": "^2.0.4",
"prettier": "^2.3.2",
"prettier": "^2.5.1",
"sinon": "^7.5.0",
"snowpack": "^3.8.7",
"ts-node": "^9.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/client/wetty/term.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { configureTerm, shouldFitTerm } from './term/confiruragtion.js';
import { terminal as termElement } from '../shared/elements.js';

export class Term extends Terminal {
socket: typeof Socket;
socket: Socket;
fitAddon: FitAddon;
constructor(socket: typeof Socket) {
constructor(socket: Socket) {
super();
this.socket = socket;
this.fitAddon = new FitAddon();
Expand All @@ -25,7 +25,7 @@ export class Term extends Terminal {
}
}

export function terminal(socket: typeof Socket): Term | undefined {
export function terminal(socket: Socket): Term | undefined {
const term = new Term(socket) as Term;
if (_.isNull(termElement)) return undefined;
termElement.innerHTML = '';
Expand Down
4 changes: 2 additions & 2 deletions src/server/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const localhost = (host: string): boolean =>
(host === 'localhost' || host === '0.0.0.0' || host === '127.0.0.1');

const urlArgs = (
referer: string,
referer: string | undefined,
def: { [s: string]: string },
): { [s: string]: string } =>
Object.assign(def, url.parse(referer, true).query);
Object.assign(def, url.parse(referer || '', true).query);

export function getCommand(
{
Expand Down
16 changes: 10 additions & 6 deletions src/server/command/address.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import type { IncomingHttpHeaders } from 'http';
import _ from 'lodash';
import { escapeShell } from '../shared/shell.js';

export function address(
headers: Record<string, string>,
headers: IncomingHttpHeaders,
user: string,
host: string,
): string {
// Check request-header for username
const remoteUser = headers['remote-user'];
if (remoteUser) {
if (!_.isUndefined(remoteUser) && !Array.isArray(remoteUser)) {
return `${escapeShell(remoteUser)}@${host}`;
}
const match = headers.referer.match('.+/ssh/([^/]+)$');
if (match) {
const username = escapeShell(match[1].split('?')[0]);
return `${username}@${host}`;
if (!_.isUndefined(headers.referer)) {
const match = headers.referer.match('.+/ssh/([^/]+)$');
if (match) {
const username = escapeShell(match[1].split('?')[0]);
return `${username}@${host}`;
}
}
return user ? `${escapeShell(user)}@${host}` : host;
}
6 changes: 3 additions & 3 deletions src/server/socketServer/socket.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type express from 'express';
import socket from 'socket.io';
import { Server } from 'socket.io';
import http from 'http';
import https from 'https';
import isUndefined from 'lodash/isUndefined.js';
Expand All @@ -13,8 +13,8 @@ export const listen = (
port: number,
path: string,
{ key, cert }: SSLBuffer,
): SocketIO.Server =>
socket(
): Server =>
new Server(
!isUndefined(key) && !isUndefined(cert)
? https.createServer({ key, cert }, app).listen(port, host, () => {
logger().info('Server started', {
Expand Down
Loading

0 comments on commit 17b75c9

Please sign in to comment.