Files
p2ns/plugin-sites/peer.directory
Raven Scott ea9124c429 BREAKING EXPERIMENTAL: Holepunch-native hard migration (RPC core, shared storage, SDK v2)
BREAKING: All nodes must upgrade together. Legacy p2ns.core-request string
messages are rejected; invite/consensus control plane uses protomux-rpc
(invite.request, invite.ack, invite.relay*, consensus.*). Shared Corestore
namespaces are the default for plugin DBs and drives; USE_SHARED_CORESTORE_NAMESPACES=false
is debug-only. Admin plugin actions with params are validated before run.

EXPERIMENTAL: End-to-end RPC invite path reuses existing handlers via adapters;
invite wire still ships on the invite channel. Multi-peer invite/relay
integration tests are not in CI yet (core-rpc-smoke only).

SDK & channels:
- channel-rpc.js, sdk.channels.rpc (register/request/event)
- core-rpc.js for p2ns.core; action-params + plugin route validation
- sdk.db.getCore/reopen, sdk.state.getPeerChannelSnapshot,
  sdk.metrics.getHolepunchStats (schema v1)

Runtime:
- p2ns.js: RPC-first core invite/consensus; Hyperswarm firewall/reconnect
- channel-manager: required protomux-rpc per peer
- db-shared-namespace-migration; drive-manager shared namespaces
- proxy-server: invite.request RPC for joiners

Plugins: file.drop, global.profile, peer.directory, domain.consensus,
peer.visualize, example.plugin (RPC demo); peer.directory UI polish

Also: CI/smoke scripts, diagnostics hardening, plugin config schema validation,
admin action param modal, docs/RFCS, package-lock + engines.node >= 18
2026-05-28 10:51:19 -04:00
..
2025-12-17 20:05:50 -05: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