File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as net from 'net' ;
2+ import * as fs from 'fs' ;
23import { BaseProtocol } from './protocol/base-protocol' ;
34import BaseConnection from './connection/base-connection' ;
45import { JsonProtocol } from './protocol/json-protocol' ;
@@ -30,12 +31,17 @@ export default class JunoModule {
3031 }
3132
3233 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' ) {
3537 return this . fromInetSocket ( host , Number ( port ) ) ;
36- } else {
38+ }
39+ if ( ( await fs . promises . lstat ( socketPath ) ) . isSocket ( ) ) {
3740 return this . fromUnixSocket ( socketPath ) ;
3841 }
42+
43+ throw new Error ( 'Invalid socket object' ) ;
44+
3945 }
4046
4147 public static fromUnixSocket ( path : string ) {
You can’t perform that action at this time.
0 commit comments