OverviewFilesCommitsIssuesDocsReleasesPeers

hyperident-gateway commits / f13919a

Remove obsolete service registry architecture
Service IPs and profiles are no longer needed in the P2P VPN model. Each gateway only needs its own IP address. Removed: - ServiceRegistry import and usage - Service registration loop - Static mappings config - Services array config - crypto import (unused) Updated stats output to show routing table size instead of services. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
f13919aa61c3b5902d07edf8a5a44d81b04a5920
by plankatron <fleeky@gmail.com> · 2026-01-17T18:29:25.000Z

Changed files (1) +4 -55

gateway.js +4 -55
……@@ -8,11 +8,9 @@
88
99import { GatewayIdentity } from './lib/gateway-identity.js'
1010import { UTUNManager } from './lib/utun-manager.js'
11import { ServiceRegistry } from './lib/service-registry.js'
1211import { HyperswarmRouter } from './lib/hyperswarm-router.js'
1312import fs from 'bare-fs/promises'
1413import minimist from 'minimist'
15import crypto from 'hypercore-crypto'
1614
1715const VERSION = '0.1.0'
1816
……@@ -84,59 +82,11 @@ async function startGateway(config) {
8482 // Initialize GatewayIdentity
8583 console.log('📝 Initializing GatewayIdentity...')
8684 const gatewayIdentity = new GatewayIdentity({
87 hyperidentPath: config.hyperident && config.hyperident.identityPath,
8885 subnet: config.gateway.subnet,
89 gatewayIP: config.gateway.virtualIP,
90 staticMappings: config.staticMappings || {}
86 gatewayIP: config.gateway.virtualIP
9187 })
9288 console.log(` Subnet: ${config.gateway.subnet}`)
93 console.log(` Gateway IP: ${config.gateway.virtualIP}`)
94 console.log(` Static mappings: ${Object.keys(config.staticMappings || {}).length}\n`)
95
96 // Initialize ServiceRegistry
97 const serviceRegistry = new ServiceRegistry(gatewayIdentity)
98
99 // Register services from config
100 console.log('📝 Registering services...')
101 const services = config.services || []
102
103 for (const serviceConfig of services) {
104 if (!serviceConfig.enabled) {
105 console.log(` ⏭️ Skipping ${serviceConfig.name} (disabled)`)
106 continue
107 }
108
109 try {
110 // For services with static IPs, manually register
111 const staticIP = config.staticMappings && config.staticMappings[serviceConfig.name]
112 if (staticIP) {
113 // Generate a deterministic topic from the service name
114 const topic = crypto.hash(Buffer.from(`hyperident-gateway:${serviceConfig.name}`)).subarray(0, 32)
115
116 gatewayIdentity.services.set(staticIP, {
117 name: serviceConfig.name,
118 profile: serviceConfig.profile,
119 ip: staticIP,
120 topic,
121 port: serviceConfig.port,
122 transport: serviceConfig.transport || 'tcp',
123 connections: []
124 })
125 console.log(` ✅ ${serviceConfig.name} -> ${staticIP}:${serviceConfig.port}`)
126 } else {
127 // For services with hyperident profiles, use registerService
128 await serviceRegistry.register(serviceConfig)
129 const service = gatewayIdentity.lookup(serviceConfig.ip)
130 console.log(` ✅ ${serviceConfig.name} -> ${service.ip}:${service.port}`)
131 }
132 } catch (error) {
133 console.error(` ❌ Failed to register ${serviceConfig.name}: ${error.message}`)
134 console.error(` Create profile with: hyperident create-profile ${serviceConfig.profile}`)
135 }
136 }
137
138 const stats = serviceRegistry.getStats()
139 console.log(`\n Total: ${stats.total} services registered\n`)
89 console.log(` Gateway IP: ${config.gateway.virtualIP}\n`)
14090
14191 // Initialize HyperswarmRouter (before UTUNManager so we can reference it)
14292 const hyperswarmRouter = new HyperswarmRouter({
……@@ -219,20 +169,19 @@ async function startGateway(config) {
219169 console.log('============================================================\n')
220170 console.log(`Virtual IP: ${config.gateway.virtualIP}`)
221171 console.log(`Subnet: ${config.gateway.subnet}`)
222 console.log(`Services: ${stats.total}`)
172 console.log(`Network Topic: ${config.gateway.networkTopic || 'hyperident-network'}`)
223173 console.log()
224174 console.log('Press Ctrl+C to stop\n')
225175
226176 // Log stats periodically
227177 setInterval(() => {
228178 const tunStats = utunManager.getStats()
229 const svcStats = serviceRegistry.getStats()
230179 const routerStats = hyperswarmRouter.getStats()
231180
232181 console.log(`[${new Date().toISOString()}] Stats:`)
233182 console.log(` TUN: ${tunStats.packetsReceived} rx, ${tunStats.packetsSent} tx, ${tunStats.packetsDropped} dropped`)
234183 console.log(` P2P: ${routerStats.packetsFromP2P} rx, ${routerStats.packetsToP2P} tx, ${routerStats.totalConnections} connections`)
235 console.log(` Services: ${svcStats.online}/${svcStats.total} online`)
184 console.log(` Routing: ${routerStats.routingTableSize} known IPs`)
236185 }, 60000) // Every minute
237186}
238187