@@ -8,6 +8,7 @@ import _ from 'lodash';
8
8
const actions = {
9
9
connect ( config ) {
10
10
return dispatch => {
11
+ let sshErrorThrown = false
11
12
if ( config . ssh ) {
12
13
dispatch ( { type : 'updateConnectStatus' , data : 'SSH connecting...' } ) ;
13
14
const conn = new Client ( ) ;
@@ -25,26 +26,26 @@ const actions = {
25
26
} ) ;
26
27
} )
27
28
. on ( 'error' , err => {
29
+ sshErrorThrown = true
28
30
dispatch ( { type : 'disconnect' } ) ;
29
31
alert ( `SSH Error: ${ err . message } ` ) ;
30
32
} ) ;
31
33
32
34
try {
35
+ const connectionConfig = {
36
+ host : config . sshHost ,
37
+ port : config . sshPort || 22 ,
38
+ username : config . sshUser
39
+ }
33
40
if ( config . sshKey ) {
34
- conn . connect ( {
35
- host : config . sshHost ,
36
- port : config . sshPort || 22 ,
37
- username : config . sshUser ,
41
+ conn . connect ( Object . assign ( connectionConfig , {
38
42
privateKey : config . sshKey ,
39
43
passphrase : config . sshKeyPassphrase
40
- } ) ;
44
+ } ) ) ;
41
45
} else {
42
- conn . connect ( {
43
- host : config . sshHost ,
44
- port : config . sshPort || 22 ,
45
- username : config . sshUser ,
46
+ conn . connect ( Object . assign ( connectionConfig , {
46
47
password : config . sshPassword
47
- } ) ;
48
+ } ) ) ;
48
49
}
49
50
} catch ( err ) {
50
51
dispatch ( { type : 'disconnect' } ) ;
@@ -98,7 +99,9 @@ const actions = {
98
99
} ) ;
99
100
redis . once ( 'end' , function ( ) {
100
101
dispatch ( { type : 'disconnect' } ) ;
101
- alert ( 'Redis Error: Connection failed' ) ;
102
+ if ( ! sshErrorThrown ) {
103
+ alert ( 'Redis Error: Connection failed' ) ;
104
+ }
102
105
} ) ;
103
106
}
104
107
} ;
0 commit comments