Skip to content

Commit

Permalink
update ssh server, remove packet install call
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanwerfling committed Jan 31, 2025
1 parent 079dc43 commit fd440d2
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 27 deletions.
3 changes: 1 addition & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"test": "node --experimental-vm-modules ../node_modules/.bin/jest",
"npm-check-updates": "npm-check-updates",
"build": "npm run compile",
"compile": "tsc --project tsconfig.json",
"install": "npm run compile"
"compile": "tsc --project tsconfig.json"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"types": "src/index.ts",
"type": "module",
"scripts": {
"npm-check-updates": "npm-check-updates",
"build": "npm run compile",
"compile": "tsc --project tsconfig.json",
"install": "npm run compile"
"compile": "tsc --project tsconfig.json"
},
"repository": {
"type": "git",
Expand Down
3 changes: 1 addition & 2 deletions ddnsserver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"scripts": {
"npm-check-updates": "npm-check-updates",
"build": "npm run compile",
"compile": "tsc --project tsconfig.json",
"install": "npm run compile"
"compile": "tsc --project tsconfig.json"
},
"repository": {
"type": "git",
Expand Down
3 changes: 1 addition & 2 deletions himhip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
"scripts": {
"npm-check-updates": "npm-check-updates",
"build": "npm run compile",
"compile": "tsc --project tsconfig.json",
"install": "npm run compile"
"compile": "tsc --project tsconfig.json"
},
"type": "module",
"version": "1.0.0"
Expand Down
7 changes: 3 additions & 4 deletions sshserver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"scripts": {
"npm-check-updates": "npm-check-updates",
"build": "npm run compile",
"compile": "tsc --project tsconfig.json",
"install": "npm run compile"
"compile": "tsc --project tsconfig.json"
},
"repository": {
"type": "git",
Expand All @@ -18,7 +17,7 @@
"license": "GPL-3.0-or-later",
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/ssh2": "^0.5.52",
"@types/ssh2": "^1.15.4",
"@types/uuid": "^9.0.8",
"@types/node-forge": "git+https://github.com/stefanwerfling/node-forge-types.git",
"@stylistic/eslint-plugin-ts": "^3.0.0",
Expand All @@ -36,7 +35,7 @@
"flyingfish_core": "file:../core",
"flyingfish_schemas": "file:../schemas",
"mysql": "^2.18.1",
"ssh2": "^1.15.0",
"ssh2": "^1.16.0",
"typeorm": "0.3.20",
"node-forge": "^1.3.1",
"uuid": "^9.0.0",
Expand Down
8 changes: 2 additions & 6 deletions sshserver/src/inc/Ssh/SshClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,7 @@ export class SshClient {
self._request(accept, reject, name, info);
});

this._clientConnection.on('tcpip', (
accept: () => ServerChannel,
reject: () => boolean,
info: TcpipRequestInfo
) => {
this._clientConnection.on('tcpip', (accept, reject, info) => {
self._tcpip(accept, reject, info);
});
}
Expand Down Expand Up @@ -322,7 +318,7 @@ export class SshClient {
*/
public _tcpip(
accept: () => ServerChannel,
reject: () => boolean,
reject: () => void,
info: TcpipRequestInfo
): void {
switch (this._forwardPort?.type) {
Expand Down
4 changes: 2 additions & 2 deletions sshserver/src/inc/Ssh/SshClientForward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ISshClientForward {
/**
* start
*/
start(accept?: () => ServerChannel, reject?: () => boolean): void;
start(accept?: () => ServerChannel, reject?: () => void): void;

/**
* close
Expand Down Expand Up @@ -58,7 +58,7 @@ export class SshClientForward implements ISshClientForward {
* @param reject
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public start(accept?: () => ServerChannel, reject?: () => boolean): void {
public start(accept?: () => ServerChannel, reject?: () => void): void {
Logger.getLogger().error('SshClientForward::start: Please overwrite start!');
}

Expand Down
2 changes: 1 addition & 1 deletion sshserver/src/inc/Ssh/SshClientForwardL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class SshClientForwardL extends SshClientForward {
* @param accept
* @param reject
*/
public start(accept?: () => ServerChannel|undefined, reject?: () => boolean|undefined): void {
public start(accept?: () => ServerChannel|undefined, reject?: () => void): void {
this._client.logToClient('SshClientForwardL::start: start');

if (accept && reject) {
Expand Down
16 changes: 10 additions & 6 deletions sshserver/src/inc/Ssh/SshServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class SshServer {
}

if (!fs.existsSync(hostKeyRsaFile)) {
Logger.getLogger().info(`SshServer::getInstance: Keyfile not found, create new: ${hostKeyRsaFile}`);
Logger.getLogger().info('SshServer::getInstance: Keyfile not found, create new: %s', hostKeyRsaFile);

if (!await SshKeygen.create2(hostKeyRsaFile)) {
Logger.getLogger().error('SshServer::getInstance: Keyfile can not create!');
Expand Down Expand Up @@ -102,13 +102,13 @@ export class SshServer {
* @protected
*/
public _onClientConnect(client: Connection, info: ClientInfo): void {
console.log('SshServer::_onConnection: Client connected!');
Logger.getLogger().info('SshServer::_onConnection: Client connected!');

const aclient = new SshClient(client, info);
this._clients.set(aclient.getIdent(), aclient);

client.on('close', (hadError) => {
aclient.close(hadError);
client.on('close', () => {
aclient.close(false);
this._clients.delete(aclient.getIdent());
});
}
Expand All @@ -117,8 +117,12 @@ export class SshServer {
* listen
*/
public listen(): void {
this._server.listen(22, '0.0.0.0', () => {
Logger.getLogger().info(`SshServer::listen: Listening on port ${this._server.address().port}`);
const port = 22;

this._server.listen(port, '0.0.0.0', () => {
Logger.getLogger().info('SshServer::listen: Listening on port %d', {
port: port
});
});
}

Expand Down

0 comments on commit fd440d2

Please sign in to comment.