Files
p2ns/plugin-sites/peer.directory
2026-05-30 21:01:31 -04:00
..
2026-05-30 21:01:31 -04:00
2025-12-17 20:05:50 -05:00
2026-05-30 21:01:31 -04:00
2025-12-17 20:05:50 -05:00

Peer Directory Plugin

A P2NS plugin that provides a web interface for browsing and searching all domains in the P2NS network.

Overview

The Peer Directory plugin serves as a central directory for discovering domains within the P2NS peer-to-peer network. It displays all claimed domains, categorizes them by type, and provides search and pagination functionality.

Features

  • Domain Listing: View all domains in the P2NS network
  • Domain Categorization: Domains are categorized as:
    • remote - Domains owned by other peers in the network
    • local - Domains you own in the P2P network
    • internal - Internal P2NS system domains (e.g., p2ns.admin)
    • plugin - Plugin domains from plugin-sites/
  • Sorting Options: Sort domains by type, name (A-Z or Z-A), or hash
  • Pagination: Navigate through large domain lists with page controls
  • Real-Time Data: Domain list is fetched fresh from the P2NS network on each request
  • Responsive UI: Clean, modern interface with Tailwind CSS

Access

Navigate to https://peer.directory in your browser (requires P2NS to be running and the root CA to be trusted).

API Endpoints

GET /domains

Returns a paginated list of all domains in the P2NS network.

Query Parameters:

  • page (optional): Page number (1-indexed, default: 1)
  • limit (optional): Domains per page (1-10, default: 10)
  • sort (optional): Sort order - one of:
    • type (default) - Sort by domain type
    • type-desc - Sort by domain type (reversed)
    • name - Sort alphabetically (A-Z)
    • name-desc - Sort alphabetically (Z-A)
    • hash - Sort by hash
    • hash-desc - Sort by hash (reversed)

Response:

{
  "domains": [
    {
      "domain": "example.tld",
      "type": "remote",
      "hash": "hs://s00084bf...",
      "isLocal": false
    },
    {
      "domain": "peer.directory",
      "type": "internal",
      "hash": "internal",
      "isLocal": true
    }
  ],
  "total": 15,
  "page": 1,
  "limit": 10,
  "totalPages": 2
}

Admin Panel Integration

The plugin registers the following in the P2NS admin panel:

Actions

  • Refresh Domains: Manually trigger a domain list refresh

Settings

  • Default Sort Order: Choose the default sorting method for the domain list
  • Items Per Page: Set the default number of domains shown per page

File Structure

peer.directory/
├── config.json      # Plugin configuration
├── index.js         # Backend handler and API logic
├── README.md        # This file
└── www/             # Frontend files
    ├── index.html   # Main HTML page
    ├── icon.svg     # Plugin icon
    ├── manifest.json
    └── css/
        ├── style.css
        └── tailwind.css

How It Works

  1. Domain Discovery: The plugin fetches all DNS entries from the P2NS network
  2. Categorization: Each domain is categorized based on:
    • Whether it's a plugin domain (in plugin-sites/)
    • Whether it's an internal domain (like p2ns.admin)
    • Whether the local peer is the resolved claimant (owner)
  3. Sorting: Domains are sorted according to the requested sort option
  4. Pagination: Results are paginated for efficient browsing

Configuration

The plugin is configured via config.json:

{
  "name": "peer.directory",
  "version": "1.0.0",
  "domain": "peer.directory",
  "enabled": true,
  "description": "P2NS peer directory browser - Browse and search P2NS domains",
  "www": "www"
}

Dependencies

  • P2NS Plugin SDK
  • No external dependencies required

License

MIT