File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
import * as net from 'net' ;
2
+ import * as fs from 'fs' ;
2
3
import { BaseProtocol } from './protocol/base-protocol' ;
3
4
import BaseConnection from './connection/base-connection' ;
4
5
import { JsonProtocol } from './protocol/json-protocol' ;
@@ -30,12 +31,17 @@ export default class JunoModule {
30
31
}
31
32
32
33
public static async default ( socketPath : string ) {
33
- if ( net . isIP ( socketPath . split ( ':' ) [ 0 ] ) ) {
34
- const [ host , port ] = socketPath . split ( ':' ) ;
34
+ const [ host , port ] = socketPath . split ( ':' ) ;
35
+
36
+ if ( net . isIP ( host ) && typeof Number ( port ) === 'number' ) {
35
37
return this . fromInetSocket ( host , Number ( port ) ) ;
36
- } else {
38
+ }
39
+ if ( ( await fs . promises . lstat ( socketPath ) ) . isSocket ( ) ) {
37
40
return this . fromUnixSocket ( socketPath ) ;
38
41
}
42
+
43
+ throw new Error ( 'Invalid socket object' ) ;
44
+
39
45
}
40
46
41
47
public static fromUnixSocket ( path : string ) {
You can’t perform that action at this time.
0 commit comments