feat: Add P2P Domain Conflicts management

Implement comprehensive P2P domain conflict resolution allowing users to choose between local claim hashes and consensus-resolved hashes for domains where they have local claims but another claimant won consensus.

Key features:
- P2P Domain Conflicts UI tab in Local DNS section
- Hash preference toggle (local vs resolved) with automatic client restart
- Extended selector_cache.json to store hashPreferences alongside versionPreferences
- DNS cache invalidation for immediate preference application
- REST API endpoints for conflict detection and preference management
- Automatic Holesail client restart when hash preferences change
- Complete documentation updates across README, API docs, and glossary

Resolves conflicts between local claims and consensus resolution by giving users control over which hash their domain resolves to, with seamless client management ensuring immediate effect.
This commit is contained in:
Raven Scott
2025-12-26 16:36:19 -05:00
parent 480f99ae28
commit 01acfb766c
22 changed files with 1193 additions and 65 deletions
+94 -1
View File
@@ -607,7 +607,100 @@ The P2NS (Peer-to-Peer Name System) admin backend API, hosted at `https://p2ns.a
OK
```
### 28. POST /api/holesail-create
### 28. GET /api/p2p-domain-conflicts
- **Description**: Retrieves domains with P2P consensus conflicts where the user has a local claim but another claimant won consensus. Used for the P2P Domain Conflicts management interface.
- **Response**: JSON object with `conflicts` array containing objects with:
- `domain` (string): Domain name
- `localHash` (string): User's local claim hash
- `resolvedHash` (string): Consensus-resolved hash
- `resolvedClaimant` (string): Public key of consensus winner
- `localClaimant` (string): User's public key
- `consensusStatus` (string): Current consensus status
- `hashPreference` (string): User's hash preference ('local' or 'resolved')
- **Status Codes**:
- `200`: Success.
- `500`: Failed to fetch P2P domain conflicts.
- **WebSocket Broadcast**: None.
- **Example**:
```bash
curl -X GET \
https://p2ns.admin/api/p2p-domain-conflicts
```
```json
{
"conflicts": [
{
"domain": "example.com",
"localHash": "hs://s0001abc...",
"resolvedHash": "hs://s0001def...",
"resolvedClaimant": "abc123...",
"localClaimant": "def456...",
"consensusStatus": "resolved",
"hashPreference": "resolved"
}
]
}
```
### 29. POST /api/update-hash-preference
- **Description**: Updates the hash preference ('local' or 'resolved') for a domain with P2P consensus conflicts, stored in `selector_cache.json`. When changed, automatically restarts any active Holesail clients for the domain to use the new hash.
- **Request Body**: JSON with `domain` (string) and `preference` (string: `local` or `resolved`).
- **Response**: Plain text `OK` on success, error message on failure.
- **Status Codes**:
- `200`: Success.
- `400`: Invalid preference.
- `500`: Failed to update hash preference.
- **WebSocket Broadcast**: `update-local-dns`.
- **Example**:
```bash
curl -X POST \
-H "Content-Type: application/json" \
-d '{"domain":"example.com","preference":"local"}' \
https://p2ns.admin/api/update-hash-preference
```
```text
OK
```
### 30. POST /api/clear-dns-cache
- **Description**: Clears DNS resolution cache entries for a specific domain to force fresh hash resolution on next DNS query.
- **Request Body**: JSON with `domain` (string).
- **Response**: Plain text `OK` on success, error message on failure.
- **Status Codes**:
- `200`: Success.
- `500`: Failed to clear DNS cache.
- **WebSocket Broadcast**: None.
- **Example**:
```bash
curl -X POST \
-H "Content-Type: application/json" \
-d '{"domain":"example.com"}' \
https://p2ns.admin/api/clear-dns-cache
```
```text
OK
```
### 31. POST /api/restart-holesail-clients-for-domain
- **Description**: Restarts all Holesail clients (both admin-managed and DNS-triggered) for a specific domain to use updated hash preferences. Closes existing connections and creates new ones with correct hashes.
- **Request Body**: JSON with `domain` (string).
- **Response**: Plain text `OK` on success, error message on failure.
- **Status Codes**:
- `200`: Success.
- `500`: Failed to restart Holesail clients.
- **WebSocket Broadcast**: `update-holesail-clients`.
- **Example**:
```bash
curl -X POST \
-H "Content-Type: application/json" \
-d '{"domain":"example.com"}' \
https://p2ns.admin/api/restart-holesail-clients-for-domain
```
```text
OK
```
### 32. POST /api/holesail-create
- **Description**: Creates a new Holesail server, optionally assigning it to a domain. Persists to `holesail_servers.json`.
- **Request Body**: JSON with `name` (string, optional), `port` (number), `host` (string, optional), `key` (string, optional), `domain` (string, optional), `secure` (boolean), `udp` (boolean), `log` (number).
- **Response**: JSON with `id` (string) on success, error message on failure.