(options: {
bindHost: string;
port: number;
networkInterfaces?: NetworkInterfaces;
})
| 258 | * since lockfiles are local-machine concerns. |
| 259 | */ |
| 260 | export 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 | |
| 291 | export class ServerService { |
| 292 | private launchProjectPath: string | null = null; |
no test coverage detected