Skip to content

Commit

Permalink
Merge pull request #28 from P1X3/patch-1
Browse files Browse the repository at this point in the history
Update index.js
  • Loading branch information
willswire authored Apr 14, 2023
2 parents b0ea3b7 + 3f9723e commit 2acb32d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function handleRequest(request) {
*/
async function informAPI(url, name, token) {
// Parse Url
const hostname = url.searchParams.get("hostname");
const hostnames = url.searchParams.get("hostname").split(",");
// Get the IP address. This can accept two query parameters, this will
// use the "ip" query parameter if it is set, otherwise falling back to "myip".
const ip = url.searchParams.get("ip") || url.searchParams.get("myip");
Expand All @@ -60,8 +60,10 @@ async function informAPI(url, name, token) {
});

const zone = await cloudflare.findZone(name);
const record = await cloudflare.findRecord(zone, hostname);
const result = await cloudflare.updateRecord(record, ip);
for (const hostname of hostnames) {
const record = await cloudflare.findRecord(zone, hostname);
const result = await cloudflare.updateRecord(record, ip);
}

// Only returns this response when no exception is thrown.
return new Response(`good`, {
Expand Down

0 comments on commit 2acb32d

Please sign in to comment.