MCPcopy
hub / github.com/coder/mux / computeNetworkBaseUrls

Function computeNetworkBaseUrls

src/node/services/serverService.ts:260–289  ·  view source on GitHub ↗
(options: {
  bindHost: string;
  port: number;
  networkInterfaces?: NetworkInterfaces;
})

Source from the content-addressed store, hash-verified

258 * since lockfiles are local-machine concerns.
259 */
260export function computeNetworkBaseUrls(options: {
261 bindHost: string;
262 port: number;
263 networkInterfaces?: NetworkInterfaces;
264}): string[] {
265 const bindHost = options.bindHost.trim();
266 if (!bindHost) {
267 return [];
268 }
269
270 if (isLoopbackHost(bindHost)) {
271 return [];
272 }
273
274 const networkInterfaces = options.networkInterfaces ?? os.networkInterfaces();
275
276 if (bindHost === "0.0.0.0") {
277 return getNonInternalInterfaceAddresses(networkInterfaces, "IPv4").map((address) =>
278 buildHttpBaseUrl(address, options.port)
279 );
280 }
281
282 if (bindHost === "::") {
283 return getNonInternalInterfaceAddresses(networkInterfaces, "IPv6").map((address) =>
284 buildHttpBaseUrl(address, options.port)
285 );
286 }
287
288 return [buildHttpBaseUrl(bindHost, options.port)];
289}
290
291export class ServerService {
292 private launchProjectPath: string | null = null;

Callers 2

startServerMethod · 0.85

Calls 3

buildHttpBaseUrlFunction · 0.85
isLoopbackHostFunction · 0.70

Tested by

no test coverage detected