denoland / denoland/std

`@std/http/file-server` shouldn't print network (non-loopback) address when host is loopback-only

Open
#5,558 6 comments 0 reactions 0 assignees View on GitHub
bug http
Dominant language
TypeScript
Stars
3.6k
Forks
681
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

**Steps to Reproduce**

Run the file server with permission `--allow-sys=networkInterfaces` and set the `--host` to a loopback value (e.g. `localhost`, `127.0.0.1`, etc.).

```sh
deno run --allow-net=localhost --allow-read --allow-sys=networkInterfaces jsr:@std/http/file-server --host=localhost
```

**Expected behavior**

The `onListen` event handler should not print a network (non-loopback) address in the informational output — because it will not be reachable:

```txt
Listening on:
- Local: http://127.0.0.1:8000
```

**Observed behavior**

Non-loopback addresses are printed and represented as reachable:

```txt
Listening on:
- Local: http://127.0.0.1:8000
- Network: http://10.0.1.100:8000
```

**Environment**

- OS: macOS 14.5
- deno version: 1.45.4
- std version: [2024.07.26](https://github.com/denoland/std/releases/tag/release-2024.07.26)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.