MCPcopy
hub / github.com/fastify/fastify / getAddresses

Function getAddresses

lib/server.js:363–374  ·  view source on GitHub ↗

* Inspects the provided `server.address` object and returns a * normalized list of IP address strings. Normalization in this * case refers to mapping wildcard `0.0.0.0` to the list of IP * addresses the wildcard refers to. * * @see https://nodejs.org/docs/latest/api/net.html#serveraddress * *

(address)

Source from the content-addressed store, hash-verified

361 * @returns {string[]}
362 */
363function getAddresses (address) {
364 if (address.address === '0.0.0.0') {
365 return Object.values(os.networkInterfaces()).flatMap((iface) => {
366 return iface.filter((iface) => iface.family === 'IPv4')
367 }).sort((iface) => {
368 /* c8 ignore next 2 */
369 // Order the interfaces so that internal ones come first
370 return iface.internal ? -1 : 1
371 }).map((iface) => { return iface.address })
372 }
373 return [address.address]
374}
375
376function logServerAddress (server, listenTextResolver) {
377 let addresses

Callers 1

logServerAddressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected