Skip to content

Instantly share code, notes, and snippets.

@sasasin
Created February 3, 2024 06:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasasin/9006968a0b5e72ab50ce6613b45ff43a to your computer and use it in GitHub Desktop.
Save sasasin/9006968a0b5e72ab50ce6613b45ff43a to your computer and use it in GitHub Desktop.
Gmail の DMARC レコードの変化を検知する New Relic Synthetics Monitoring Scripted API 用 JS コード
/**
* Feel free to explore, or check out the full documentation
* https://docs.newrelic.com/docs/synthetics/new-relic-synthetics/scripting-monitors/writing-api-tests
* for details.
*/
var assert = require('assert');
// Google Public DNS の API エンドポイントに投げると JSON で DNS レコードを返してくれる
// https://developers.google.com/speed/public-dns/docs/doh/json
var endpoint = 'https://dns.google.com/resolve?name=_dmarc.gmail.com&type=TXT'
$http.get(endpoint,
// Callback
function (err, response, body) {
assert.equal(response.statusCode, 200, 'Expected a 200 OK response');
console.log('Response:', body);
// ここから変化したら鳴ってほしい
assert.equal(body.Answer[0].data, 'v=DMARC1; p=none; sp=quarantine; rua=mailto:mailauth-reports@google.com', 'Expected DMARC p=none')
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment