diff --git a/db/knex_migrations/2025-06-03-0000-add-force-ipv4-ipv6.js b/db/knex_migrations/2025-06-03-0000-add-ip-family.js similarity index 70% rename from db/knex_migrations/2025-06-03-0000-add-force-ipv4-ipv6.js rename to db/knex_migrations/2025-06-03-0000-add-ip-family.js index af6011cb3..a3bcdc613 100644 --- a/db/knex_migrations/2025-06-03-0000-add-force-ipv4-ipv6.js +++ b/db/knex_migrations/2025-06-03-0000-add-ip-family.js @@ -1,13 +1,13 @@ exports.up = function (knex) { return knex.schema .alterTable("monitor", function (table) { - table.boolean("force_ip").defaultTo(null); + table.boolean("ip_family").defaultTo(null); }); }; exports.down = function (knex) { return knex.schema .alterTable("monitor", function (table) { - table.dropColumn("force_ip"); + table.dropColumn("ip_family"); }); }; diff --git a/server/model/monitor.js b/server/model/monitor.js index 9b6e3c268..c9844a55d 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -160,7 +160,7 @@ class Monitor extends BeanModel { smtpSecurity: this.smtpSecurity, rabbitmqNodes: JSON.parse(this.rabbitmqNodes), conditions: JSON.parse(this.conditions), - forceIp: this.forceIp, + ipFamily: this.ipFamily, // ping advanced options ping_numeric: this.isPingNumeric(), @@ -428,10 +428,10 @@ class Monitor extends BeanModel { } let agentFamily = undefined; - if (this.forceIp === "ipv4") { + if (this.ipFamily === "ipv4") { agentFamily = 4; } - if (this.forceIp === "ipv6") { + if (this.ipFamily === "ipv6") { agentFamily = 6; } @@ -439,11 +439,13 @@ class Monitor extends BeanModel { maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940) rejectUnauthorized: !this.getIgnoreTls(), secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT, + autoSelectFamily: true, ...(agentFamily ? { family: agentFamily } : {}) }; const httpAgentOptions = { maxCachedSessions: 0, + autoSelectFamily: true, ...(agentFamily ? { family: agentFamily } : {}) }; diff --git a/server/server.js b/server/server.js index ad9ec1080..77ba695d1 100644 --- a/server/server.js +++ b/server/server.js @@ -792,7 +792,7 @@ let needSetup = false; bean.url = monitor.url; bean.method = monitor.method; bean.body = monitor.body; - bean.forceIp = monitor.forceIp; + bean.ipFamily = monitor.ipFamily; bean.headers = monitor.headers; bean.basic_auth_user = monitor.basic_auth_user; bean.basic_auth_pass = monitor.basic_auth_pass; diff --git a/src/lang/en.json b/src/lang/en.json index 5caf66678..98b18bee3 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1112,6 +1112,6 @@ "Sender name": "Sender name", "smsplanetNeedToApproveName": "Needs to be approved in the client panel", "Disable URL in Notification": "Disable URL in Notification", - "Force Ip": "Force IP", - "forceIpDescription": "If not None, the monitor will enforce using either IPv4 or IPv6 for connecting to the target." + "Ip Family": "IP Family", + "ipFamilyDescription": "Choose the IP version to use (IPv4 or IPv6). If \"auto-select\" is chosen, it will use \"Happy Eyeballs\" for determining the IP version." } diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 69ad69491..b17765da4 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -747,11 +747,11 @@