@@ -31,7 +31,7 @@ export async function listInstance({ host, port = DEFAULT_PORT, family, signal,
3131 Buffer . from ( instanceName )
3232 ] ) ;
3333
34- const response = await sendRequest ( { address : host , family } , port , false , timeout , request , signal ) ;
34+ const response = await sendRequest ( { address : host , family } , port , timeout , request , signal ) ;
3535 if ( ! response ) {
3636 return ;
3737 }
@@ -51,28 +51,7 @@ export async function listInstances({ host, port = DEFAULT_PORT, family, signal,
5151 }
5252
5353 const request = Buffer . from ( [ 0x03 ] ) ;
54- const response = await sendRequest ( { address : host , family } , port , false , timeout , request , signal ) ;
55- if ( ! response ) {
56- return [ ] ;
57- }
58-
59- return parseResponse ( response ) ;
60- }
61-
62- export async function listAllInstances ( { port = DEFAULT_PORT , family, signal, timeout = DEFAULT_TIMEOUT } : {
63- port ?: number ;
64- family : 4 | 6 ;
65- timeout ?: number ;
66- signal ?: AbortSignal ;
67- } ) {
68- if ( signal ?. aborted ) {
69- throw new Error ( 'aborted' ) ;
70- }
71-
72- const address = family === 6 ? 'FF02::1' : '255.255.255.255' ;
73-
74- const request = Buffer . from ( [ 0x02 ] ) ;
75- const response = await sendRequest ( { address, family } , port , true , timeout , request , signal ) ;
54+ const response = await sendRequest ( { address : host , family } , port , timeout , request , signal ) ;
7655 if ( ! response ) {
7756 return [ ] ;
7857 }
@@ -91,7 +70,7 @@ function parseResponse(buffer: Buffer): Array < Instance > {
9170 return parse ( responseString ) ;
9271}
9372
94- function sendRequest ( address : { address : string , family : 4 | 6 } , port : number , broadcast : boolean , timeout : number , request : Buffer , signal ?: AbortSignal ) : Promise < Buffer | undefined > {
73+ function sendRequest ( address : { address : string , family : 4 | 6 } , port : number , timeout : number , request : Buffer , signal ?: AbortSignal ) : Promise < Buffer | undefined > {
9574 const socketType = address . family === 6 ? 'udp6' : 'udp4' ;
9675 const socket = dgram . createSocket ( socketType ) ;
9776
@@ -143,8 +122,6 @@ function sendRequest(address: { address: string, family: 4 | 6 }, port: number,
143122 socket . on ( 'error' , onError ) ;
144123 socket . on ( 'message' , onMessage ) ;
145124
146- socket . setBroadcast ( broadcast ) ;
147-
148125 socket . send ( request , 0 , request . length , port , address . address , ( err ) => {
149126 if ( err ) {
150127 reject ( err ) ;
0 commit comments