Skip to content

Commit

Permalink
Fix connecting to heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
Paxa committed Dec 29, 2021
1 parent 3f552c4 commit fad468d
Show file tree
Hide file tree
Showing 4 changed files with 302 additions and 234 deletions.
28 changes: 23 additions & 5 deletions app/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ class Connection {
if ('ssl' in cs.params) {
res.ssl = Boolean(cs.params.ssl)
}

if ('rejectUnauthorized' in cs.params && res.ssl) {
res.ssl = {
rejectUnauthorized: cs.params.rejectUnauthorized == "false" ? false : Boolean(cs.params.rejectUnauthorized)
}
}

delete res.socketPort;

return res;
Expand Down Expand Up @@ -170,6 +177,9 @@ class Connection {
if (options.ssl) {
cs.params.ssl = true;
}
if ('rejectUnauthorized' in options) {
cs.params.rejectUnauthorized = options.rejectUnauthorized;
}
return cs.toString();
}

Expand Down Expand Up @@ -286,12 +296,20 @@ class Connection {

clientConfig.idleTimeoutMillis = 600000;
clientConfig.max = clientConfig.max || 5;
clientConfig.log = (a, b, c) => { console.log('Pool:', a, b, c); }
var pool = new pg.Pool(clientConfig);

// pool.on('remove', client => {
// console.log('pool removed');
// })
console.log('clientConfig', connectString, clientConfig);
try {
throw "aaa";
} catch (e) {
console.log(e);
}

// if (clientConfig.ssl == 'require') {
//
// }

// clientConfig.log = (a, b, c) => { console.log('Pool:', a, b, c); }
var pool = new pg.Pool(clientConfig);

return pool;
}
Expand Down
2 changes: 1 addition & 1 deletion app/login_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class LoginScreen {
App.stopLoading();
return;
}
db_url = db_url + "?ssl=verify-full";
db_url = db_url + "?ssl=require&rejectUnauthorized=false";
console.log('connecting to', db_url);
this.makeConnection(db_url, {fetchDbList: false, name: heroku_app.name}, (tab) => {
if (tab) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@types/pg": "^7.14.5",
"@types/semver": "~7.3.8",
"electron": "^15.3.1",
"electron-builder": "^22.13.1",
"electron-builder": "^22.14.5",
"electron-mocha": "^9.2.0",
"eslint": "^7.32.0",
"localStorage": "^1.0.4",
Expand Down
Loading

0 comments on commit fad468d

Please sign in to comment.