0
Disable Outgoing Zone Transfers
One script reply has been approved by the moderators Verified

Disable outgoing zone transfers for primary zone and clears IXFR backlog of primary zone.

Created by hugo697 402 days ago Viewed 9143 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 402 days ago
1
type Cloudflare = {
2
  token: string;
3
  email: string;
4
  key: string;
5
};
6
/**
7
 * Disable Outgoing Zone Transfers
8
 * Disable outgoing zone transfers for primary zone and clears IXFR backlog of primary zone.
9
 */
10
export async function main(auth: Cloudflare, zone_identifier: string) {
11
  const url = new URL(
12
    `https://api.cloudflare.com/client/v4/zones/${zone_identifier}/secondary_dns/outgoing/disable`
13
  );
14

15
  const response = await fetch(url, {
16
    method: "POST",
17
    headers: {
18
      "X-AUTH-EMAIL": auth.email,
19
      "X-AUTH-KEY": auth.key,
20
      "Content-Type": "application/json",
21
      Authorization: "Bearer " + auth.token,
22
    },
23
    body: undefined,
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.json();
30
}
31