IPv4 address space: scarce, bought, leased, leased out; IPv6 is free (#150)

A rule (ip4), on in On-call and BGP at 3 a.m., off in the gentler
presets, sandbox and puzzles; scenarios only when they opt in. You start
with a /21 from the registry, sized so the early game never notices
(a gameplay-rules F1 test plays six start cities for 50 days). Business
customers need a block by kind and size; broadband homes take what is
left and the rest go behind CGNAT, which costs a box per home and
annoys some customers. An offer that does not fit cannot be signed and
says why, and a customer that cannot grow at renewal stays its size.

The bank's Address space section buys and sells blocks on a transfer
market with a gentle trend, leases blocks in, and leases spare blocks
out for monthly income, in real CIDR sizes (/24 to /16), at most 256
blocks (what a save keeps). Old saves get what they already use, plus
room, so nothing changes on load. The dashboard's AS box now lists the
blocks you announce.
This commit is contained in:
jvanvik 2026-11-07 01:04:00 +01:00
parent 2cd6b71198
commit eac0604300
34 changed files with 957 additions and 32 deletions

View file

@ -232,7 +232,7 @@ const API_CMD={
doc:'Set how many channels of one optic model a dark-fiber span carries, in one change. Added optics come from the spares shelf when you have them (regen cards still cost their share); removed ones go back to the shelf.'},
/* ---------- customers ---------- */
accept:{args:[['id','entityId']],
doc:'Sign a pending offer. Rejected without a POP in every city it needs, without free channels for a wave sale, or after an event\'s start date. Extra waves for a carrier you already serve grow that contract.'},
doc:'Sign a pending offer. Rejected without a POP in every city it needs, without the IPv4 addresses it needs (rule ip4: see the bank\'s Address space), without free channels for a wave sale, or after an event\'s start date. Extra waves for a carrier you already serve grow that contract.'},
decline:{args:[['id','entityId']],
doc:'Throw an offer away.'},
salesHire:{args:[['id','salesPersona']],
@ -282,6 +282,23 @@ const API_CMD={
repayLoan:{args:[['id','entityId']],confirm:'double',
quote:a=>{const l=S.loans.find(x=>x.id===a.id);return l?{setup:repayCost(l,BANKS[l.bank])}:{};},
doc:'Repay a loan early, or buy an equity investor out.'},
/* ---------- address space (IPv4, rule ip4: On-call and BGP at 3 a.m.) ---------- */
ip4Buy:{args:[['len','ip4Len']],watch:['ip4'],
quote:a=>({setup:ip4Cost(Number(a.len)),blocked:[ip4On()?'':tr('ip4.off'),ip4On()&&ip4Full()?tr('ip4.too_many',{n:IP4_BLK}):''].filter(Boolean)}),
doc:'Buy an IPv4 block of this prefix length (24 = 256 addresses up to 16 = 65,536) on the transfer market at today\'s price. It can be sold again two years after this transfer. A network holds at most 256 blocks, bought, leased in and from the registry together.'},
ip4Lease:{args:[['len','ip4Len']],watch:['ip4'],
quote:a=>({setup:0,monthly:ip4InMo(Number(a.len)),blocked:[ip4On()?'':tr('ip4.off'),ip4On()&&ip4Full()?tr('ip4.too_many',{n:IP4_BLK}):''].filter(Boolean)}),
doc:'Lease an IPv4 block of this prefix length by the month, at today\'s rate (fixed for the lease). Hand it back with ip4Return. Refused at 256 blocks, like ip4Buy.'},
ip4Sell:{args:[['id','entityId']],confirm:'double',watch:['ip4'],
doc:'Sell an owned block (not leased out) for 92% of the market price. Refused within two years of its last transfer, or when the customers signed would no longer fit with every home behind CGNAT.'},
ip4Out:{args:[['id','entityId']],watch:['ip4'],
doc:'Lease an owned block out through a broker for a monthly income, while your own customers still fit without it.'},
ip4Back:{args:[['id','entityId']],watch:['ip4'],
doc:'End the lease of a block you leased out; its addresses are yours to use again.'},
ip4Return:{args:[['id','entityId']],watch:['ip4'],
doc:'Hand a leased-in block back, ending its monthly fee, when your customers still fit without it.'},
ip4Nat:{args:[['v','ip4Ratio']],watch:['ip4'],
doc:'Set how many broadband homes share one IPv4 address behind CGNAT (8, 16, 32 or 64). More frees space for business customers but more gamers ask for refunds; fewer is refused when the customers signed would not fit.'},
/* ---------- security, China, incidents ---------- */
buildScrub:{args:[['city','cityId'],['tier','scrubTier',false]],watch:['scrubs'],
quote:a=>{const T=SCRUB_TIERS[a.tier||0];return {setup:T?T.cost:undefined,monthly:T?T.mo:undefined};},
@ -453,6 +470,8 @@ const API_CMD={
const API_VIEW={
pieOpen:{args:[],doc:'Open Pie Control, the rocket company\'s panel.'},
ip4Open:{args:[],doc:'Open the bank at its Address space section: your IPv4 blocks, who uses them, CGNAT and the transfer market.'},
ip4Pick:{args:[['v','ip4Len']],doc:'Pick the block size the Address space market quotes (a prefix length, 24 to 16).'},
pieGovOpen:{args:[],doc:'Open the bank at its Government money section: the rocket company\'s fund auctions, the Pitcairn grant and the Ex-Im Pie Bank (it used to be Pie Control\'s Gov tab).'},
pieTab:{args:[['t','pieTab']],doc:'Switch the Pie Control tab: traffic, co (the company, its books and the Founder\'s posts), fly (launches) or dish.'},
pieCity:{args:[['v','cityId']],doc:'Pick the POP the Dishes tab works on.'},