Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# internalIP(family: "v4" | "v6")
# findIp(family: "v4" | "v6")

Returns the internal IP address asynchronously.
Returns the internal IP address.

```js
const WebpackDevServer = require("webpack-dev-server");

const logInternalIPs = async () => {
const localIPv4 = await WebpackDevServer.internalIP("v4");
const localIPv6 = await WebpackDevServer.internalIP("v6");
const localIPv4 = WebpackDevServer.findIp("v4", false);
const localIPv6 = WebpackDevServer.findIp("v6", false);

console.log("Local IPv4 address:", localIPv4);
console.log("Local IPv6 address:", localIPv6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
const WebpackDevServer = require("../../../lib/Server");

const logInternalIPs = async () => {
const localIPv4 = await WebpackDevServer.internalIP("v4");
const localIPv6 = await WebpackDevServer.internalIP("v6");
const localIPv4 = WebpackDevServer.findIp("v4", false);
const localIPv6 = WebpackDevServer.findIp("v6", false);

console.log("Local IPv4 address:", localIPv4);
console.log("Local IPv6 address:", localIPv6);
Expand Down
23 changes: 0 additions & 23 deletions examples/api/internal-ip-sync/README.md

This file was deleted.

9 changes: 0 additions & 9 deletions examples/api/internal-ip-sync/app.js

This file was deleted.

18 changes: 0 additions & 18 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,24 +475,6 @@ class Server {
}
}

// TODO remove me in the next major release, we have `findIp`
/**
* @param {"v4" | "v6"} family family
* @returns {Promise<string | undefined>} internal API
*/
static async internalIP(family) {
return Server.findIp(family, false);
}

// TODO remove me in the next major release, we have `findIp`
/**
* @param {"v4" | "v6"} family family
* @returns {string | undefined} internal IP
*/
static internalIPSync(family) {
return Server.findIp(family, false);
}

/**
* @param {Host} hostname hostname
* @returns {Promise<string>} resolved hostname
Expand Down
19 changes: 19 additions & 0 deletions migration-v6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Migration guide

This document serves as a migration guide for `webpack-dev-server@6.0.0`.

## Deprecations

- The static methods `internalIP` and `internalIPSync` were removed. Use `findIp` instead.

v4:

```js
const ip = Server.internalIP("v4");
```

v5:

```js
const ip = Server.findIp("v4", true);
```
2 changes: 1 addition & 1 deletion test/e2e/allowed-hosts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ describe("allowed hosts", () => {
});

it("should always allow value from the `host` options if options.allowedHosts is auto", async () => {
const networkIP = Server.internalIPSync("v4");
const networkIP = Server.findIp("v4", false);
const options = {
host: networkIP,
allowedHosts: "auto",
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/web-socket-server-url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe("web socket server URL", () => {
it(`should work behind proxy, when hostnames are different and ports are same ("${webSocketServer}")`, async () => {
const devServerHost = "127.0.0.1";
const devServerPort = port1;
const proxyHost = Server.internalIPSync("v4");
const proxyHost = Server.findIp("v4", false);
const proxyPort = port1;

const compiler = webpack(config);
Expand Down Expand Up @@ -209,7 +209,7 @@ describe("web socket server URL", () => {
it(`should work behind proxy, when hostnames are different and ports are different ("${webSocketServer}")`, async () => {
const devServerHost = "localhost";
const devServerPort = port1;
const proxyHost = Server.internalIPSync("v4");
const proxyHost = Server.findIp("v4", false);
const proxyPort = port2;

const compiler = webpack(config);
Expand Down Expand Up @@ -310,7 +310,7 @@ describe("web socket server URL", () => {
it(`should work behind proxy, when the "host" option is "local-ip" and the "port" option is "auto" ("${webSocketServer}")`, async () => {
process.env.WEBPACK_DEV_SERVER_BASE_PORT = 40000;

const proxyHost = Server.internalIPSync("v4");
const proxyHost = Server.findIp("v4", false);
const proxyPort = port2;

const compiler = webpack(config);
Expand Down Expand Up @@ -2006,7 +2006,7 @@ describe("web socket server URL", () => {
});

it(`should work when "host" option is IPv4 ("${webSocketServer}")`, async () => {
const hostname = Server.internalIPSync("v4");
const hostname = Server.findIp("v4", false);
const compiler = webpack(config);
const devServerOptions = {
webSocketServer,
Expand Down Expand Up @@ -2074,7 +2074,7 @@ describe("web socket server URL", () => {
});

it(`should work when "host" option is "local-ip" ("${webSocketServer}")`, async () => {
const hostname = Server.internalIPSync("v4");
const hostname = Server.findIp("v4", false);
const compiler = webpack(config);
const devServerOptions = {
webSocketServer,
Expand Down Expand Up @@ -2143,7 +2143,7 @@ describe("web socket server URL", () => {
});

it(`should work when "host" option is "local-ipv4" ("${webSocketServer}")`, async () => {
const hostname = Server.internalIPSync("v4");
const hostname = Server.findIp("v4", false);
const compiler = webpack(config);
const devServerOptions = {
webSocketServer,
Expand Down
2 changes: 1 addition & 1 deletion test/server/open-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const Server = require("../../lib/Server");
const config = require("../fixtures/simple-config/webpack.config");
const port = require("../ports-map")["open-option"];

const internalIPv4 = Server.internalIPSync("v4");
const internalIPv4 = Server.findIp("v4", false);

let open;

Expand Down
10 changes: 0 additions & 10 deletions types/lib/Server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1141,16 +1141,6 @@ declare class Server<
gatewayOrFamily: string,
isInternal?: boolean | undefined,
): string | undefined;
/**
* @param {"v4" | "v6"} family family
* @returns {Promise<string | undefined>} internal API
*/
static internalIP(family: "v4" | "v6"): Promise<string | undefined>;
/**
* @param {"v4" | "v6"} family family
* @returns {string | undefined} internal IP
*/
static internalIPSync(family: "v4" | "v6"): string | undefined;
/**
* @param {Host} hostname hostname
* @returns {Promise<string>} resolved hostname
Expand Down