1.0.2 • Published 2 years ago

iscloudy v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

build status code style styled with prettier made with lass license npm downloads

A simple library to check if your target(s) are cloudflare IPs

Table of Contents

General

With this library, you can check if your targets are Cloudflare IPs. Why did I make it? The reason is that I am building a CLI tool named gimmesites that requires checking if a given IP is Cloudflare to report it to the user, and since I could not find any library that does this, I then did it.

Install

npm:

npm install iscloudy

yarn:

yarn add iscloudy

Usage

const Cloudy = require('iscloudy');

const cloudflare = new Cloudy(
  [
    '188.114.96.7',
    'api.linkino.me',
    'https://admin.linkino.me/',
    'https://linkino.me/'
  ],
  false
);

(async function () {
  await cloudflare.check();
})();

cloudflare.onError((err) => {
  console.log(err); // will log error message
});
cloudflare.onCloudFlareFound((data) => {
  console.log('FOUND: ' + data); // will log single object
});
cloudflare.onDone((data) => {
  console.log('FOUND All: ' + data); // will log everything like the anonymous function above
});

API Docs

Methods

new IsCloudy(target, update): instance

Parameter nameTypeDescription
targetString[]List of targets, they can be IPs or domain names
updateBooleanif set to true it will fetch the latest ranges of Cloudflare IPs. Default value is false.

check(): void

This is the main method to call, it will not return anything. USE THE EVENTS TO GET THE RESULTS

Events

The methods that you define will need one parameter, to get the returning values. In case of success 'onCloudFlareFound' and 'onDone' you will get for the first event an object and for the latter, you will get an array of objects.

onError(method): void

Parameter nameDescription
methodthis event gets fired for any occurring error in the library

onCloudFlareFound(method): void

Parameter nameDescription
methodthis event gets fired for each found cloudflare target.

onDone(method): void

Parameter nameDescription
methodthis event gets fired only once, when all the targets have being checked.

Contributing

This is your typical "fork-and-pull" Git workflow.

  • Fork the repo on GitHub
  • Clone the project to your machine
  • Commit changes to your branch
  • Push your work back up to your fork
  • Submit a Pull request so that we can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a pull request!

License (MIT)

Copyright (c) 2022 Firas Jelassi firasroudi@gmail.com