Repository: fastify/fastify
File: lib/server.js (JavaScript)

Code before:
    }
    server.on('session', sessionTimeout(options.http2SessionTimeout))
  } else {
    // this is http1
    if (httpsOptions) {
      server = https.createServer(httpsOptions, httpHandler)
    } else {
      server = http.createServer(options.http, httpHandler)
    }
    server.keepAliveTimeout = options.keepAliveTimeout
    server.requestTimeout = options.requestTimeout
    // we treat zero as null
    // and null is the default setting from nodejs
    // so we do not pass the option to server
    if (options.maxRequestsPerSocket > 0) {
      server.maxRequestsPerSocket = options.maxRequestsPerSocket
    }
  }

  if (!options.serverFactory) {
    server.setTimeout(options.connectionTimeout)
  }
  return server
}

function getAddresses (address) {
  if (address.address === '0.0.0.0') {
    return Object.values(os.networkInterfaces()).flatMap((iface) => {
      return iface.filter((iface) => iface.family === 'IPv4')
    }).sort((iface) => {
      // Order the interfaces so that internal ones come first
      /* istanbul ignore next */
      return iface.internal ? -1 : 1
    }).map((iface) => { return iface.address })
  }
  return [address.address]
}

function logServerAddress (server, listenTextResolver) {
  let addresses
  const isUnixSocket = typeof server.address() === 'string'
  /* istanbul ignore next */
  if (!isUnixSocket) {
    if (server.address().address.indexOf(':') === -1) {
      // IPv4
      addresses = getAddresses(server.address()).map((address) => address + ':' + server.address().port)
    } else {
      // IPv6
      addresses = ['[' + server.address().address + ']:' + server.address().port]
    }


Review comment (suggestion):
```suggestion
/**
 * 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
 *
 * @param {object} A server address object as described in the
 * linked docs.
 *
 * @returns {string[]}
 */
function getAddresses (address) {
```

Code after:
    }
    server.on('session', sessionTimeout(options.http2SessionTimeout))
  } else {
    // this is http1
    if (httpsOptions) {
      server = https.createServer(httpsOptions, httpHandler)
    } else {
      server = http.createServer(options.http, httpHandler)
    }
    server.keepAliveTimeout = options.keepAliveTimeout
    server.requestTimeout = options.requestTimeout
    // we treat zero as null
    // and null is the default setting from nodejs
    // so we do not pass the option to server
    if (options.maxRequestsPerSocket > 0) {
      server.maxRequestsPerSocket = options.maxRequestsPerSocket
    }
  }

  if (!options.serverFactory) {
    server.setTimeout(options.connectionTimeout)
  }
  return server
}
/**
 * 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
 *
 * @param {object} A server address object as described in the
 * linked docs.
 *
 * @returns {string[]}
 */
function getAddresses (address) {
  if (address.address === '0.0.0.0') {
    return Object.values(os.networkInterfaces()).flatMap((iface) => {
      return iface.filter((iface) => iface.family === 'IPv4')
    }).sort((iface) => {
      // Order the interfaces so that internal ones come first
      /* c8 ignore next 1 */
      return iface.internal ? -1 : 1
    }).map((iface) => { return iface.address })
  }
  return [address.address]
}

function logServerAddress (server, listenTextResolver) {