print less urls at start
Massimo Melina committed
Dec 15, 2022 at 12:12 UTC
1a9a58f9339438587b3181ce6127ecb07cbc3181
1 file changed
+10
-12
src/listen.ts
+10
-12
@@ -12,6 +12,7 @@ import { debounceAsync, onlyTruthy, wait } from './misc'
12
import { ADMIN_URI, DEV } from './const'
13
import findProcess from 'find-process'
14
import { anyAccountCanLoginAdmin } from './perm'
15
+import _ from 'lodash'
16
17
interface ServerExtra { name: string, error?: string, busy?: Promise<string> }
18
let httpSrv: http.Server & ServerExtra
@@ -195,17 +196,14 @@ export function getUrls() {
196
function printUrls(port: number, proto: string) {
197
if (!port) return
198
for (const [name, nets] of Object.entries(networkInterfaces())) {
198
- if (!nets) continue
199
- const filteredNets = nets.filter(n => !n.internal)
200
- if (!filteredNets.length || ignore.test(name)) continue
201
- console.log('network', name)
202
- for (const net of nets) {
203
- if (net.internal) continue
204
- const appendPort = port === (proto==='https' ? 443 : 80) ? '' : ':' + port
205
- let { address } = net
206
- if (address.includes(':'))
207
- address = '['+address+']'
208
- console.log('-', proto + '://' + address + appendPort)
209
- }
199
+ if (!nets || ignore.test(name)) continue
200
+ _.remove(nets, 'internal')
201
+ if (!nets.length) continue
202
+ const best = _.find(nets, { family: 'IPv4' }) || nets[0]
203
+ const appendPort = port === (proto==='https' ? 443 : 80) ? '' : ':' + port
204
+ let { address } = best
205
+ if (address.includes(':'))
206
+ address = '['+address+']'
207
+ console.log('network', name, proto + '://' + address + appendPort)
208
}
209
}