Browse Source

APIv4 now gives resolvers, so get resolver list from the API instead of hard-coding them

pull/5/head
L. Bradley LaBoon 6 months ago
parent
commit
498eda243d
  1. 258
      linodes/remote_access/remote_access.js

258
linodes/remote_access/remote_access.js

@ -44,241 +44,6 @@ import { settings, elements, apiGet, parseParams, setupHeader } from "/global.js
data.linode = {};
data.netInfo = {};
// The Linode API does not supply resolvers, so they must be hard-coded
data.resolvers = {
"us-central": [
"173.255.199.5",
"66.228.53.5",
"96.126.122.5",
"96.126.124.5",
"96.126.127.5",
"198.58.107.5",
"198.58.111.5",
"23.239.24.5",
"2600:3c00::5",
"2600:3c00::6",
"2600:3c00::7",
"2600:3c00::8",
"2600:3c00::9",
"2600:3c00::b",
"2600:3c00::c"
],
"us-west": [
"173.230.145.5",
"173.230.147.5",
"173.230.155.5",
"173.255.212.5",
"173.255.219.5",
"173.255.241.5",
"173.255.243.5",
"173.255.244.5",
"2600:3c01::5",
"2600:3c01::6",
"2600:3c01::7",
"2600:3c01::8",
"2600:3c01::9",
"2600:3c01::b",
"2600:3c01::c"
],
"us-southeast": [
"173.230.129.5",
"173.230.136.5",
"173.230.140.5",
"66.228.59.5",
"66.228.62.5",
"50.116.35.5",
"50.116.41.5",
"23.239.18.5",
"2600:3c02::5",
"2600:3c02::6",
"2600:3c02::7",
"2600:3c02::8",
"2600:3c02::9",
"2600:3c02::b",
"2600:3c02::c"
],
"us-east": [
"66.228.42.5",
"96.126.106.5",
"50.116.53.5",
"50.116.58.5",
"50.116.61.5",
"50.116.62.5",
"66.175.211.5",
"2600:3c03::5",
"2600:3c03::6",
"2600:3c03::7",
"2600:3c03::8",
"2600:3c03::9",
"2600:3c03::b",
"2600:3c03::c"
],
"us-east-1b": [
"172.104.200.4",
"172.104.200.5",
"2400:8903::5",
"2400:8903::6",
"2400:8903::7",
"2400:8903::8",
"2400:8903::9",
"2400:8903::b",
"2400:8903::c"
],
"eu-west": [
"178.79.182.5",
"176.58.107.5",
"176.58.116.5",
"176.58.121.5",
"151.236.220.5",
"212.71.252.5",
"212.71.253.5",
"2a01:7e00::5",
"2a01:7e00::6",
"2a01:7e00::7",
"2a01:7e00::8",
"2a01:7e00::9",
"2a01:7e00::b",
"2a01:7e00::c"
],
"ap-south": [
"139.162.11.5",
"139.162.13.5",
"139.162.14.5",
"139.162.15.5",
"139.162.16.5",
"139.162.21.5",
"139.162.27.5",
"2400:8901::5",
"2400:8901::6",
"2400:8901::7",
"2400:8901::8",
"2400:8901::9",
"2400:8901::b",
"2400:8901::c"
],
"eu-central": [
"139.162.130.5",
"139.162.131.5",
"139.162.132.5",
"139.162.133.5",
"139.162.134.5",
"139.162.135.5",
"139.162.136.5",
"139.162.137.5",
"139.162.138.5",
"139.162.139.5",
"2a01:7e01::5",
"2a01:7e01::6",
"2a01:7e01::7",
"2a01:7e01::8",
"2a01:7e01::9",
"2a01:7e01::b",
"2a01:7e01::c"
],
"ap-northeast": [
"106.187.90.5",
"106.187.93.5",
"106.187.94.5",
"106.187.95.5",
"106.186.116.5",
"106.186.123.5",
"106.186.124.5",
"2400:8900::5",
"2400:8900::6",
"2400:8900::7",
"2400:8900::8",
"2400:8900::9",
"2400:8900::b",
"2400:8900::c"
],
"ap-northeast-1a": [
"139.162.66.5",
"139.162.67.5",
"139.162.68.5",
"139.162.69.5",
"139.162.70.5",
"139.162.71.5",
"139.162.72.5",
"139.162.73.5",
"139.162.74.5",
"139.162.75.5",
"2400:8902::5",
"2400:8902::6",
"2400:8902::7",
"2400:8902::8",
"2400:8902::9",
"2400:8902::b",
"2400:8902::c"
],
"ca-central": [
"172.105.0.5",
"172.105.3.5",
"172.105.4.5",
"172.105.5.5",
"172.105.6.5",
"172.105.7.5",
"172.105.8.5",
"172.105.9.5",
"172.105.10.5",
"172.105.11.5",
"2600:3C04::5",
"2600:3C04::6",
"2600:3C04::7",
"2600:3C04::8",
"2600:3C04::9",
"2600:3C04::b",
"2600:3C04::c"
],
"ap-west": [
"172.105.34.5",
"172.105.35.5",
"172.105.36.5",
"172.105.37.5",
"172.105.38.5",
"172.105.39.5",
"172.105.40.5",
"172.105.41.5",
"172.105.42.5",
"172.105.43.5",
"2400:8904::5",
"2400:8904::6",
"2400:8904::7",
"2400:8904::8",
"2400:8904::9",
"2400:8904::b",
"2400:8904::c"
],
"ap-southeast": [
"172.105.166.5",
"172.105.169.5",
"172.105.168.5",
"172.105.172.5",
"172.105.162.5",
"172.105.170.5",
"172.105.167.5",
"172.105.171.5",
"172.105.181.5",
"172.105.161.5",
"2400:8907::5",
"2400:8907::6",
"2400:8907::7",
"2400:8907::8",
"2400:8907::9",
"2400:8907::b",
"2400:8907::c"
],
"philadelphia": [
"100.90.80.253",
"2400:8906::5",
"2400:8906::6",
"2400:8906::7",
"2400:8906::8",
"2400:8906::9",
"2400:8906::b",
"2400:8906::c"
]
};
// LISH uses different DC names than the API uses, so we need to translate them
data.lishDCs = {
"us-central": "dallas",
@ -344,14 +109,8 @@ import { settings, elements, apiGet, parseParams, setupHeader } from "/global.js
};
apiGet("/linode/instances", displayIPLinks, filters);
// Display resolvers
for (var i = 0; i < data.resolvers[data.linode.region].length; i++) {
var resolver = document.createElement("span");
resolver.innerHTML = data.resolvers[data.linode.region][i];
var br = document.createElement("br");
ui.resolvers.appendChild(resolver);
ui.resolvers.appendChild(br);
}
// Get region info to display resolvers
apiGet("/regions/" + data.linode.region, displayResolvers, null);
// Update the LISH link
ui.lishLink.href = ui.lishLink.href.replace("lish-", "lish-" + data.lishDCs[data.linode.region]);
@ -444,6 +203,19 @@ import { settings, elements, apiGet, parseParams, setupHeader } from "/global.js
ui.linkLocal.innerHTML = data.netInfo.ipv6.link_local.address + " / " + data.netInfo.ipv6.link_local.prefix;
};
// Callback for region info API call
var displayResolvers = function(response)
{
var resolvers = response.resolvers.ipv4.split(",").concat(response.resolvers.ipv6.split(","));
for (var i = 0; i < resolvers.length; i++) {
var resolver = document.createElement("span");
resolver.innerHTML = resolvers[i];
var br = document.createElement("br");
ui.resolvers.appendChild(resolver);
ui.resolvers.appendChild(br);
}
};
// Initial setup
var setup = function()
{

Loading…
Cancel
Save