Home / Function/ getNetworkAddress() — astro Function Reference

getNetworkAddress() — astro Function Reference

Architecture documentation for the getNetworkAddress() function in log-listening-on.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  726a2ff2_ad33_a741_55cc_94f613b17c1f["getNetworkAddress()"]
  f924c5ec_b86a_e284_c9c3_d5d9b3562d39["log-listening-on.ts"]
  726a2ff2_ad33_a741_55cc_94f613b17c1f -->|defined in| f924c5ec_b86a_e284_c9c3_d5d9b3562d39
  2562c872_6018_1c23_f06c_cb53aad8e489["logListeningOn()"]
  2562c872_6018_1c23_f06c_cb53aad8e489 -->|calls| 726a2ff2_ad33_a741_55cc_94f613b17c1f
  style 726a2ff2_ad33_a741_55cc_94f613b17c1f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/node/src/log-listening-on.ts lines 48–78

function getNetworkAddress(
	protocol: 'http' | 'https' = 'http',
	hostname: string | undefined,
	port: number,
	base?: string,
) {
	const NetworkAddress: NetworkAddressOpt = {
		local: [],
		network: [],
	};
	Object.values(os.networkInterfaces())
		.flatMap((nInterface) => nInterface ?? [])
		.filter((detail) => detail && detail.address && detail.family === 'IPv4')
		.forEach((detail) => {
			let host = detail.address.replace(
				'127.0.0.1',
				hostname === undefined || wildcardHosts.has(hostname) ? 'localhost' : hostname,
			);
			// ipv6 host
			if (host.includes(':')) {
				host = `[${host}]`;
			}
			const url = `${protocol}://${host}:${port}${base ? base : ''}`;
			if (detail.address.includes('127.0.0.1')) {
				NetworkAddress.local.push(url);
			} else {
				NetworkAddress.network.push(url);
			}
		});
	return NetworkAddress;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getNetworkAddress() do?
getNetworkAddress() is a function in the astro codebase, defined in packages/integrations/node/src/log-listening-on.ts.
Where is getNetworkAddress() defined?
getNetworkAddress() is defined in packages/integrations/node/src/log-listening-on.ts at line 48.
What calls getNetworkAddress()?
getNetworkAddress() is called by 1 function(s): logListeningOn.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free