Repository navigation
feat: add Dedicated and Direct network presets and configurable mesh policy - #71
Merged
Merged
Conversation
…le mesh policy - Expose NetDB subnet quotas, readiness router thresholds, floodfill K targets, exploration cadence, tunnel IP restrictions, and custom SU3 signer certificates across state, controlplane, and root SDK - Add small_private and office_lan presets (NewSmallPrivateNetwork, NewOfficeLANNetwork, SmallPrivateDestinationConfig, OfficeLANDestinationConfig) - Deduplicate confirmed floodfill targets across publication retry waves and add 2-node same-gateway (OBEP == IBGW) tunnel build fallbacks - Add E2E and deterministic simulation tests for 2-node OfficeLAN and 4-node SmallPrivate meshes
…lient tunnel hops
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
IVNP already lets a single
RouterandDestinationspan multiple overlay networks bynetId(1..255). Until now, however, every network context inherited parameters calibrated for the global public I2P network (netId = 2), which assumes tens of thousands of untrusted routers spread across thousands of autonomous systems.When an engineer embeds IVNP into a 2-device desktop clipboard-sync sidecar on home Wi-Fi (
192.168.1.0/24), a 10-node microservice cluster on an office VLAN (10.10.0.0/16), or a multi-region dedicated overlay, those public defaults stall the mesh before a single stream can open:/16Subnet Quotas (BucketSubnetQuota = 2) silently drop the 3rd node sharing a LAN or cloud VPC/16prefix./16Diversity (IPRestriction = 2) refuses to place two hops in the same/16subnet, making tunnel builds impossible on a flat subnet.OBEP == IBGW) rejects outbound tunnel builds when the only remote peer in a 2-node mesh is also the gateway for the inbound reply tunnel.MinRouters = 50,FloodfillK = 4..5) preventWaitReadyandLeaseSet2publication confirmation from ever completing in small clusters.netId = 2reseed servers,.i2paddressbook feeds, and public HTTP outproxies in air-gapped or private environments.This PR makes all 16 underlying NetDB, tunnel, and reseed parameters configurable via both
ivnp.confand the root Go API (gosuda.org/ivnp), resolves the 2-node 1-hopOBEP == IBGWbuild and publication edge cases incontrolplane, and introduces two first-class presets alongsidepublic:dedicated(NetworkProfileDedicated) anddirect(NetworkProfileDirect).Network & Destination Presets
gosuda.org/ivnp)public(NetworkProfilePublic)DefaultI2PNetwork()/NewNetwork(...)DefaultDestinationConfig()netId = 2) and large untrusted overlays (200+nodes)MinRouters = 50,/16bucket quota2,IPRestriction = 2,2-hopexploratory /3-hopclient tunnels,K = 4..5,60sprobes)dedicated(NetworkProfileDedicated)NewDedicatedNetwork(name, netID, opts...)DedicatedDestinationConfig()3 to 200+nodes) requiring multi-floodfill redundancy and hop diversityParticipationContributor), relaxes/16bucket quota to16, setsMinRouters = 2andFloodfillK = 2, builds1-hoptunnels (2active per direction), sets5smaintenance /10sprobes, and disables public reseed/outproxiesdirect(NetworkProfileDirect)NewDirectNetwork(name, netID, opts...)DirectDestinationConfig()2 to 30nodes)/16bucket quotas (0) and hop IP restrictions (0), setsMinRouters = 1andFloodfillK = 1(works with 2 nodes total), builds1-hoptunnels (1 active + 1 backup), and sets fast3smaintenance /5sprobesExample: 2-Device Clipboard Sync Sidecar (
direct+publicHappy Eyeballs)Key Changes Across Layers
1. L3
state: Profile Baseline & Raw INI Configuration (state/internal/configuration)NetworkProfile("public","dedicated","direct") andDefaultOperatingForProfile(profile)inoperating.go.[network] profileinivnp.conf; profile defaults are applied first, and any explicit key in[router],[netdb],[tunnel],[reseed],[http_proxy], or[addressbook]overrides the preset.[netdb]:bucket_subnet_quota(0disables/16quota),min_routers,router_info_floodfill_k,lease_set_floodfill_k,exploration_bootstrap_delay,exploration_steady_delay, and raisedmaxBootstrapRouterInfoFilesfrom8to64.[tunnel]:ip_restriction(0..4, where0disables subnet restriction and1..4enforce/8,/16,/24,/32),probe_timeout, andprobe_failure_threshold.[reseed]:bucket_subnet_quota(0..64),bucket_admit_limit,verify_anchor_count,merge_wait,trusted_cert_files(up to16PEM certificates), and dynamic?netid=<network.id>URL query verification instead of hardcoded?netid=2.2. L5
controlplane: Small-Mesh Convergence, 2-Node Self-Relay & Custom SU3 SignersOBEP == IBGWCoalesced Reply Handling (controlplane/internal/tunnel):selectDiverseHopsfalls back to allowing the outbound endpoint to match the reply tunnel's inbound gateway (AllowCoalescedReply = true), andBuildManager.inboundLocalDeliveryroutesI2NPOutboundTunnelBuildReplyframes arriving at the local inbound tunnel endpoint directly toHandleReply.len(refs) <= 8andrelaxSubTier) that remain completely inert on the public network (50+routers).controlplane/internal/netdb/confirmation.go):confirmedPublicationnow tracksconfirmedTargetsper generation so retry ticks do not re-send duplicateDatabaseStoremessages to floodfills that already acknowledged the current generation.controlplane/internal/reseed):ParseSU3SignerCertificateandMergeSU3Signersto validate and merge custom RSA-4096 X.509 certificates fromtrusted_cert_filesorWithTrustedReseedCerts.DisableBucketSubnetQuotatoreseed.Clientso single-subnet private reseeds are not throttled by/16ingress quotas.controlplane/internal/runtime):MinNetDBRouters,RouterInfoFloodfillK,LeaseSetFloodfillK,ExplorationBootstrapDelay,ExplorationSteadyDelay, andtunnelIPRestrictionthroughControlleranddestinationRuntimeFactory.3. L8 Root Go API & Documentation (
gosuda.org/ivnp,docs/)NewDedicatedNetwork,NewDirectNetwork,DedicatedDestinationConfig,DirectDestinationConfig,NetDBConfig,TunnelPolicyConfig,WithNetworkProfile,WithListenAddress,WithAdvertisedAddress,WithPeerSeeds,WithTrustedReseedCerts,WithNetDBConfig,WithTunnelTiming,WithIPRestriction, andWithPeerAdmission.docs/private-networks-and-presets.mdcovering failure modes of public defaults on LANs, realistic deployment scenarios, the complete raw parameter matrix, and runnable Go andivnp.confrecipes.Public I2P Network Compatibility
cryptography,foundation, anddataplane(NTCP2, SSU2, 1024-byte tunnel crypto, ECIES ratchet, streaming, and datagrams) are untouched.DefaultOperating(),DefaultRouterConfig(),DefaultI2PNetwork(), andDefaultDestinationConfig()produce the exact same parameter values asmain.controlplane/internal/tunnel/netdb_source.gotrigger only when standard candidate selection cannot fillwantedhops in sparse tables (len(refs) <= 8).Verification
go run gosuda.org/ivnp/tools/importformatter -writegojgp lint ./...(0 issues)go test -v ./architecture(L0-L9 acyclic DAG and canonical import checks pass)go test ./state/... ./controlplane/... ./client/... ./node/... ./cmd/...TestParseOperatingNetworkProfilesAndOverrides,TestConfirmedPublicationDoesNotResendToAlreadyConfirmedTargets,TestMergeSU3SignersAdmitsCustomPEMCertificate,TestSmallNetworkHopSelectionFallbacks,TestNetworkPresetsAndOptionsmulti_network_test.go):TestEmbeddedTwoNodeDirectMesh: 2-nodedirectmesh on a shared/24subnet with 1-hop tunnels and stream round-trip.TestEmbeddedDedicatedMeshWithPeerAdmission: 3-nodededicatedmesh on a shared/24subnet withAdmitPeersallowlist, stream, andDatagram2round-trip.TestE2ELoopbackDirectMesh: 2 embedded routers over live kernel TCP/UDP loopback sockets (ExportLocalRouterInfo/ImportRouterInfo,WaitReady, and end-to-end streaming).sim_dst_test.go):TestSimDirectTwoNodeMesh(DST_SEED=2088) andTestSimDedicatedMesh(DST_SEED=2042) pass undertesting/synctestwithdst_overlay.json.