Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdaa191c

Browse files
committed
fix: take the first network found instead of the last one, this restores the same behavior as 5.0.4
1 parent5a39c70 commitdaa191c

File tree

2 files changed

+125
-2
lines changed

2 files changed

+125
-2
lines changed

‎lib/Server.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,9 @@ class Server {
437437
returnnetwork.address;
438438
});
439439

440-
for(constnetworkofnetworks){
441-
host=network.address;
440+
if(networks.length>0){
441+
// Take the first network found
442+
host=networks[0].address;
442443

443444
if(host.includes(":")){
444445
host=`[${host}]`;

‎test/cli/host-option.test.js‎

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use strict";
22

3+
constos=require("os");
34
const{ testBin, normalizeStderr}=require("../helpers/test-bin");
45
constport=require("../ports-map")["cli-host"];
56
constServer=require("../../lib/Server");
@@ -116,6 +117,127 @@ describe('"host" CLI option', () => {
116117
expect(normalizeStderr(stderr)).toMatchSnapshot("stderr");
117118
});
118119

120+
it('should work using "--host local-ip" take the first network found',async()=>{
121+
const{ exitCode, stderr}=awaittestBin([
122+
"--port",
123+
port,
124+
"--host",
125+
"local-ip",
126+
]);
127+
128+
expect(exitCode).toEqual(0);
129+
jest.spyOn(os,"networkInterfaces").mockImplementation(()=>{
130+
return{
131+
lo:[
132+
{
133+
address:"127.0.0.1",
134+
netmask:"255.0.0.0",
135+
family:"IPv4",
136+
mac:"00:00:00:00:00:00",
137+
internal:true,
138+
cidr:"127.0.0.1/8",
139+
},
140+
{
141+
address:"::1",
142+
netmask:"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
143+
family:"IPv6",
144+
mac:"00:00:00:00:00:00",
145+
internal:true,
146+
cidr:"::1/128",
147+
scopeid:0,
148+
},
149+
],
150+
enp6s0:[
151+
{
152+
address:"192.168.1.15",
153+
netmask:"255.255.255.0",
154+
family:"IPv4",
155+
mac:"50:eb:f6:97:9f:6f",
156+
internal:false,
157+
cidr:"192.168.1.15/24",
158+
},
159+
{
160+
address:"2a01:cb0c:1623:6800:4ff8:723c:1a4b:fe5d",
161+
netmask:"ffff:ffff:ffff:ffff::",
162+
family:"IPv6",
163+
mac:"50:eb:f6:97:9f:6f",
164+
internal:false,
165+
cidr:"2a01:cb0c:1623:6800:4ff8:723c:1a4b:fe5d/64",
166+
scopeid:0,
167+
},
168+
{
169+
address:"2a01:cb0c:1623:6800:9acc:408c:ee87:27cf",
170+
netmask:"ffff:ffff:ffff:ffff::",
171+
family:"IPv6",
172+
mac:"50:eb:f6:97:9f:6f",
173+
internal:false,
174+
cidr:"2a01:cb0c:1623:6800:9acc:408c:ee87:27cf/64",
175+
scopeid:0,
176+
},
177+
{
178+
address:"fe80::bf2a:e5e2:8f9:4336",
179+
netmask:"ffff:ffff:ffff:ffff::",
180+
family:"IPv6",
181+
mac:"50:eb:f6:97:9f:6f",
182+
internal:false,
183+
cidr:"fe80::bf2a:e5e2:8f9:4336/64",
184+
scopeid:2,
185+
},
186+
],
187+
"br-9bb0264f9b1c":[
188+
{
189+
address:"172.19.0.1",
190+
netmask:"255.255.0.0",
191+
family:"IPv4",
192+
mac:"02:42:e4:c8:6e:5f",
193+
internal:false,
194+
cidr:"172.19.0.1/16",
195+
},
196+
{
197+
address:"fe80::42:e4ff:fec8:6e5f",
198+
netmask:"ffff:ffff:ffff:ffff::",
199+
family:"IPv6",
200+
mac:"02:42:e4:c8:6e:5f",
201+
internal:false,
202+
cidr:"fe80::42:e4ff:fec8:6e5f/64",
203+
scopeid:4,
204+
},
205+
],
206+
"br-a52e5d90701f":[
207+
{
208+
address:"172.18.0.1",
209+
netmask:"255.255.0.0",
210+
family:"IPv4",
211+
mac:"02:42:f6:7e:a2:45",
212+
internal:false,
213+
cidr:"172.18.0.1/16",
214+
},
215+
{
216+
address:"fe80::42:f6ff:fe7e:a245",
217+
netmask:"ffff:ffff:ffff:ffff::",
218+
family:"IPv6",
219+
mac:"02:42:f6:7e:a2:45",
220+
internal:false,
221+
cidr:"fe80::42:f6ff:fe7e:a245/64",
222+
scopeid:5,
223+
},
224+
],
225+
docker0:[
226+
{
227+
address:"172.17.0.1",
228+
netmask:"255.255.0.0",
229+
family:"IPv4",
230+
mac:"02:42:3e:89:61:cf",
231+
internal:false,
232+
cidr:"172.17.0.1/16",
233+
},
234+
],
235+
};
236+
});
237+
expect(stderr.indexOf("172.17.0.1")===-1);
238+
expect(stderr.indexOf("192.168.1.15")>-1);
239+
});
240+
119241
it('should work using "--host local-ipv4"',async()=>{
120242
const{ exitCode, stderr}=awaittestBin([
121243
"--port",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp