Skip to content

palmthree-studio/meta-asn-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Meta ASN Filter πŸ”

npm version License: MIT TypeScript Tests

High-performance IP address filtering for Meta/Facebook networks (ASN 32934)

A lightweight, fast, and reliable TypeScript/JavaScript library to detect if an IP address belongs to Meta (formerly Facebook) infrastructure. Perfect for analytics, security filtering, bot detection, and network analysis.

🌟 Star this repository if you find it useful! ⭐

πŸš€ Features

  • βœ… Lightning fast IP address detection
  • βœ… IPv4 and IPv6 support - Complete coverage
  • βœ… TypeScript native with full type definitions
  • βœ… ESM and CommonJS compatible
  • βœ… Zero dependencies runtime (uses cidr-matcher for efficiency)
  • βœ… Monthly updates - Always up-to-date with latest Meta IP ranges
  • βœ… Comprehensive tests with 100% coverage
  • βœ… Production ready - Used in enterprise applications

πŸ“¦ Installation

# npm
npm install @palmthree-studio/meta-asn-filter

# yarn
yarn add @palmthree-studio/meta-asn-filter

# pnpm
pnpm add @palmthree-studio/meta-asn-filter

πŸ”§ Usage

ES Modules (Recommended)

import { isMetaIP } from "@palmthree-studio/meta-asn-filter";

// Check if an IP belongs to Meta/Facebook
console.log(isMetaIP("69.63.189.44")); // true - Meta IPv4
console.log(isMetaIP("2a03:2880::1")); // true - Meta IPv6
console.log(isMetaIP("8.8.8.8")); // false - Google DNS
console.log(isMetaIP("2001:4860:4860::8888")); // false - Google IPv6

CommonJS

const { isMetaIP } = require("@palmthree-studio/meta-asn-filter");

if (isMetaIP(userIP)) {
  console.log("Traffic from Meta/Facebook detected");
}

Real-world Examples

Web Analytics Filtering

import { isMetaIP } from "@palmthree-studio/meta-asn-filter";

function shouldTrackVisitor(ip: string): boolean {
  // Filter out Meta crawler traffic from analytics
  return !isMetaIP(ip);
}

Security & Rate Limiting

import { isMetaIP } from "@palmthree-studio/meta-asn-filter";

function applyRateLimit(ip: string) {
  if (isMetaIP(ip)) {
    // Apply special rate limits for Meta services
    return { limit: 1000, window: "1h" };
  }
  return { limit: 100, window: "1h" };
}

Express.js Middleware

import express from "express";
import { isMetaIP } from "@palmthree-studio/meta-asn-filter";

const app = express();

app.use((req, res, next) => {
  const clientIP = req.ip;
  if (isMetaIP(clientIP)) {
    req.isMeta = true;
  }
  next();
});

πŸ“Š Performance

  • ~0.001ms average lookup time
  • 972 CIDR ranges covered (as of latest update)
  • Memory efficient - Optimized CIDR matching
  • No network calls - All data bundled

πŸ”„ Data Updates

The IP ranges are automatically updated monthly from the RADB (Routing Assets Database) to ensure accuracy. The package includes:

  • All IPv4 and IPv6 ranges assigned to ASN 32934 (Meta)
  • Deduplicated and optimized CIDR blocks
  • Verified against official routing tables

πŸ› οΈ Development

Building from Source

# Clone the repository
git clone https://github.com/palmthree-studio/meta-asn-filter.git
cd meta-asn-filter

# Install dependencies
npm install

# Refresh Meta IP data from RADB
npm run refresh

# Build the package
npm run build

# Run tests
npm test

Available Scripts

  • npm run build - Build ESM, CommonJS, and TypeScript definitions
  • npm run refresh - Update Meta IP ranges from RADB
  • npm test - Run Jest test suite
  • npm run dev - Watch mode for development

πŸ§ͺ Testing

The package includes comprehensive tests covering:

  • IPv4 address detection
  • IPv6 address detection
  • Edge cases and invalid inputs
  • Performance benchmarks
npm test

πŸ“‹ API Reference

isMetaIP(ip: string): boolean

Determines if an IP address belongs to Meta (ASN 32934).

Parameters:

  • ip: string - IPv4 or IPv6 address to check

Returns:

  • boolean - true if the IP belongs to Meta, false otherwise

Throws:

  • No exceptions - Invalid IPs return false

πŸ” SEO Keywords

IP filtering, Meta Facebook IP ranges, ASN 32934, IPv4 IPv6 detection, TypeScript IP library, network security, bot detection, web crawlers, social media filtering, CIDR matching, Node.js IP utilities

🀝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🏒 About Palmthree Studio

Created and maintained by Younès ELAB Palmthree Studio - Building developer tools that just work.

🌟 Show Your Support

If this package helps you, please consider:

  • ⭐ Starring this repository
  • πŸ› Reporting bugs or requesting features
  • πŸ’ Contributing to the codebase
  • πŸ“’ Sharing with your network

⭐ Star this repository now! - It helps others discover this tool!


Made with ❀️ by Palmthree Studio

Report Bug β€’ Request Feature β€’ Documentation

About

Open source script for filtering IP from Meta bots

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors