Skip to content

Commit

Permalink
feat: support to ssl connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Feb 3, 2021
1 parent 15417e8 commit 4e72bb1
Show file tree
Hide file tree
Showing 6 changed files with 512 additions and 248 deletions.
48 changes: 35 additions & 13 deletions src/main/ipc-handlers/connection.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@

import fs from 'fs';
import { ipcMain } from 'electron';
import { ClientsFactory } from '../libs/ClientsFactory';

export default connections => {
ipcMain.handle('test-connection', async (event, conn) => {
const params = {
host: conn.host,
port: +conn.port,
user: conn.user,
password: conn.password
};

if (conn.ssl) {
params.ssl = {
key: conn.key ? fs.readFileSync(conn.key) : null,
cert: conn.cert ? fs.readFileSync(conn.cert) : null,
ca: conn.ca ? fs.readFileSync(conn.ca) : null,
ciphers: conn.ciphers
};
}

const connection = ClientsFactory.getConnection({
client: conn.client,
params: {
host: conn.host,
port: +conn.port,
user: conn.user,
password: conn.password
}
params
});

await connection.connect();
Expand All @@ -32,14 +43,25 @@ export default connections => {
});

ipcMain.handle('connect', async (event, conn) => {
const params = {
host: conn.host,
port: +conn.port,
user: conn.user,
password: conn.password
};

if (conn.ssl) {
params.ssl = {
key: conn.key ? fs.readFileSync(conn.key) : null,
cert: conn.cert ? fs.readFileSync(conn.cert) : null,
ca: conn.ca ? fs.readFileSync(conn.ca) : null,
ciphers: conn.ciphers
};
}

const connection = ClientsFactory.getConnection({
client: conn.client,
params: {
host: conn.host,
port: +conn.port,
user: conn.user,
password: conn.password
},
params,
poolSize: 1
});

Expand Down
Loading

0 comments on commit 4e72bb1

Please sign in to comment.