⚠️ ${tr('Max-prefix limit hit: {who} at {ix}',{who:esc(ibxWho(x)),ix:esc(ixName(x.ix))})}
@@ -69,8 +75,9 @@ function inboxModal(){const I=ibx(),items=I.items.slice().sort((a,b)=>(b.k==='mp
openModal(`
${tr('Every exchange port brings mail. Answer peering requests, and look at sessions that hit their max-prefix limit: is it growth, or a route leak? Unanswered mail gets you a reputation, and selective networks hear about it.')}
${PPOL.map(p=>btn(tr(PPOL_N[p]),'inboxPol',{p},ppol()===p?'sm':'ghost sm')).join('')}
${I.bot?`
🤖 ${tr('Large Peering Model is answering your mail')}
${tr('{price}/year. It never sleeps, never complains and is often wrong.',{price:fmt$(20e6)})}
${I.log.length?`
${I.log.slice(0,8).map(e=>esc(tr('Day {d}',{d:e.d})+': '+tr(e.m,e.a))).join('\n')}`:''}
${btn(tr('Fire the AI'),'inboxBot',{on:0},'ghost sm')}
`
:`
🤖 ${tr('Large Peering Model')}
${tr('An AI agent that answers every peering request and max-prefix alert for you, every day. {price}/year. Trained on twenty years of peering mailing lists.',{price:fmt$(20e6)})}
${btn(tr('Hire it
{mo}/mo',{mo:fmt$(AI_MO)}),'inboxBot',{on:1},'aibtn sm',S.cash
`}
- ${reqs>1?`
${btn(tr('Accept all requests'),'inboxAll',{a:'accept'},'sm')}${btn(tr('Decline all requests'),'inboxAll',{a:'decline'},'ghost sm')}
`:''}
+ ${reqs>1||mps>1?`
${reqs>1?btn(tr('Accept all requests'),'inboxAll',{a:'accept'},'sm')+btn(tr('Decline all requests'),'inboxAll',{a:'decline'},'ghost sm'):''}${mps>1?btn(tr('Raise all max-prefix limits'),'inboxRaiseAll',{},'sm'):''}
`:''}
${items.length?items.slice(0,40).map(card).join(''):`
${Object.keys(S.ixp).length?tr('Inbox zero. Enjoy it while it lasts.'):tr('No mail yet. Buy an IX port and it will come.')}
`}`);}
diff --git a/src/game/80-simulation/50-sanitize.js b/src/game/80-simulation/50-sanitize.js
index f863596..4c9d608 100644
--- a/src/game/80-simulation/50-sanitize.js
+++ b/src/game/80-simulation/50-sanitize.js
@@ -30,7 +30,7 @@ function sanitize(s){
const down={};for(const [k,v] of Object.entries(o(I.down)))if(typeof k==='string'&&k.length<80)down[k]=num(v,0);
const tiny={};for(const [k,v] of Object.entries(o(I.tiny)).slice(0,200))if(/^\d{1,10}$/.test(k)&&v&&typeof v==='object'&&isIx(v.ix))tiny[k]={nm:str(v.nm,40),ix:v.ix,stale:!!v.stale};
const log=(Array.isArray(I.log)?I.log:[]).filter(e=>e&&typeof e==='object'&&typeof e.m==='string').slice(0,40).map(e=>{const a={};for(const [k,v] of Object.entries(o(e.a)).slice(0,6))a[str(k,12)]=typeof v==='number'?v:str(v,60);return {d:num(e.d,0),m:str(e.m,200),a};});
- s.inbox={items,down,tiny,rep:clamp(num(I.rep,0),-10,5),bot:!!I.bot,log,seq:Math.max(int(I.seq,0,1e9,0),...items.map(x=>x.id))};}
+ s.inbox={items,down,tiny,rep:clamp(num(I.rep,0),-10,5),bot:!!I.bot,pol:PPOL.includes(I.pol)?I.pol:'open',log,seq:Math.max(int(I.seq,0,1e9,0),...items.map(x=>x.id))};}
{const sp={};if(s.spares&&typeof s.spares==='object')for(const k in s.spares)if(own(OPT,k)){const v=Math.floor(+s.spares[k]);if(v>0)sp[k]=Math.min(999,v);}s.spares=sp;}
s.caches=s.caches.filter(x=>x&&isCity(x.city)&&isNet(x.net)&&NET[x.net].cache).map(x=>(x.id=sid(x.id),x.site=x.site==='b'&&s.pops[x.city]&&s.pops[x.city].site2?'b':'a',x));
for(const c of Object.keys(s.ixp)){if(!isIx(c))delete s.ixp[c];else s.ixp[c]=tier(s.ixp[c]);}
diff --git a/src/game/88-days/10-day-tick.js b/src/game/88-days/10-day-tick.js
index 234d111..4623118 100644
--- a/src/game/88-days/10-day-tick.js
+++ b/src/game/88-days/10-day-tick.js
@@ -56,7 +56,7 @@ function dayTick(){
if(S.mode==='sandbox'&&S.cash<1e8)S.cash=1e9;
// offers
S.offers=S.offers.filter(o=>o.exp>d);
- if(S.offers.length<5&&Math.random()<0.05+0.01*(S.lvl||1))spawnOffer();
+ if(S.offers.length<5&&Math.random()<(0.05+0.01*(S.lvl||1))*(ppol()==='closed'?0.6:1))spawnOffer();
// failures & events
let dirty=false;
if(d>=S.nextFail){dirty=true;fireFailure();const size=S.links.length+Object.keys(S.pops).length;S.nextFail=d+Math.round((Math.max(22,50-size*1.5)+Math.floor(Math.random()*25))*(scnRule('chaos')?0.5:1));}
diff --git a/src/game/90-actions/40-sites-peering-caches.js b/src/game/90-actions/40-sites-peering-caches.js
index bceade6..8c35c8d 100644
--- a/src/game/90-actions/40-sites-peering-caches.js
+++ b/src/game/90-actions/40-sites-peering-caches.js
@@ -24,6 +24,9 @@ Object.assign(ACT,{
else toast(pick([tr('
“It is with the provisioning team.”Nobody has ever met the provisioning team.'),tr('
“We are waiting on the colo for the cross-connect.”The colo says it is waiting on them.'),tr('
Your ticket was merged into another ticket.That ticket was closed as a duplicate of yours.'),tr('
“Could you resend the LOA?”You have sent it four times.'),tr('
Your account manager is on paternity leave.His replacement is also on paternity leave.')]));after();},
inbox:()=>{inboxModal();},
inboxAct:({id,a})=>{if(!['accept','decline','raise','keep'].includes(a))return;ibxAnswer(+id,a);after();inboxModal();},
+ inboxPol:({p})=>{if(!PPOL.includes(p))return;ibx().pol=p;after();inboxModal();},
+ inboxRaiseAll:()=>{const I=ibx(),mp=I.items.filter(x=>x.k==='mp');if(!mp.length)return;const leaks=mp.filter(x=>x.leak).length;for(const x of mp)ibxAnswer(x.id,'raise',true);
+ toast(leaks?trn('
Raised {n} max-prefix limits.One of them was a route leak. It is in the NOC now.','
Raised {n} max-prefix limits.{k} of them were route leaks. They are in the NOC now.',leaks,{n:mp.length,k:leaks}):tr('
Raised {n} max-prefix limits.All growth, no leaks. Lucky.',{n:mp.length}),leaks?'bad':'good');after();inboxModal();},
inboxAll:({a})=>{if(a!=='accept'&&a!=='decline')return;const I=ibx();for(const x of I.items.filter(x=>x.k==='req'))ibxAnswer(x.id,a,true);after();inboxModal();},
inboxBot:({on})=>{const I=ibx();if(+on){if(I.bot||!spend(AI_MO))return;I.bot=true;ibxLog(N_('Hello! I am Large Peering Model. I have read your inbox and I already have opinions.'),{});toast(tr('
Large Peering Model is hired.Your inbox is its problem now. {price} a year, billed monthly.',{price:fmt$(20e6)}),'good');}else{I.bot=false;toast(tr('
The AI is gone.It left a 40-page handover document. It is mostly about itself.'));}after();inboxModal();},
cancelPni:({id,ok})=>{if(!ok&&UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.pni=S.pni.filter(p=>p.id!==id);UI.confirm=null;after();},
diff --git a/src/game/93-ui/70-link-panels.js b/src/game/93-ui/70-link-panels.js
index a9b152a..014cbb8 100644
--- a/src/game/93-ui/70-link-panels.js
+++ b/src/game/93-ui/70-link-panels.js
@@ -13,7 +13,7 @@ function ixBlock(c,multi){const city=ixCity(c),C=CITY[city],ix=ixName(c),X=XIXM[
for(const x of ad)h+=`
${esc(x.n)} ${tr('auto-enrolled')}
${esc(x.blurb)} · ${tr('{price}/mo',{price:fmt$(x.mo)})}
${btn(UI.confirm==='dk'+c+x.n?tr('Lose exclusive benefits?'):tr('Opt out'),'dkOptOut',{city:c,n:x.n},'ghost sm')}
`;}
if(isRemote(c))h+=`
${trn('Remote port via a reseller: 1.5× price, 80% usable, and {n} member here refuse remote peers.','Remote port via a reseller: 1.5× price, 80% usable, and {n} members here refuse remote peers.',ixMembers(c).filter(noRemote).length)}
`;
if(mine){const f=S.myIx[c].fab|0,N=MYIX_FAB[f+1];h+=`
${tr('Members paying you')}${tr('{n} of up to {max} · {price}/mo',{n:S.myIx[c].members.length,max:myFab(c).max,price:fmt$(S.myIx[c].members.length*MYIX_FEE)})}
${N?`
${btn(N.lvl>lvl()?tr('{name} fabric
level {lv}',{name:N.n,lv:N.lvl}):tr('Upgrade fabric to {name}
{cost} + {mo}/mo',{name:N.n,cost:fmt$(N.cost),mo:fmt$(N.mo)}),'myIxUp',{city:c},'pink sm',N.lvl>lvl()||S.cash
${tr('A bigger fabric carries more traffic and has room for more members. Your router here still has to keep up.')}
`:''+tr('Biggest fabric money can buy.')+'
'}`;}
- else h+=`${PORT.map((P2,i)=>i>S.ixp[c]&&portShown(i)?btn(tr('Upgrade {port} {price}',{port:P2.n,price:portMo(ixPortMo(c,i)*((S.ixn||{})[c]||1))}),'buyIx',{city:c,tier:i},'sm',(!!S.pops[city]&&!portOk(city,i))||(!S.pops[city]&&i>1)):'').join('')}${S.pops[city]&&((S.ixn||{})[c]||1){price}',{price:portMo(ixPortMo(c,S.ixp[c]))}),'lagIx',{city:c,d:1},'sm',S.cash1?btn(tr('− member'),'lagIx',{city:c,d:-1},'ghost sm'):''}${btn(S.rs[c]?tr('Leave route server'):tr('Join route server'),'rs',{city:c},S.rs[c]?'ghost sm':'pink sm')}${btn(UI.confirm==='ix'+c?tr('Really leave?'):tr('Leave IX'),'cancelIx',{city:c},'ghost sm')}
`;
+ else h+=`${PORT.map((P2,i)=>i>S.ixp[c]&&portShown(i)?btn(tr('Upgrade {port} {price}',{port:P2.n,price:portMo(ixPortMo(c,i)*((S.ixn||{})[c]||1))}),'buyIx',{city:c,tier:i},'sm',(!!S.pops[city]&&!portOk(city,i))||(!S.pops[city]&&i>1)):'').join('')}${S.pops[city]&&((S.ixn||{})[c]||1){price}',{price:portMo(ixPortMo(c,S.ixp[c]))}),'lagIx',{city:c,d:1},'sm',S.cash1?btn(tr('− member'),'lagIx',{city:c,d:-1},'ghost sm'):''}${btn(S.rs[c]?tr('Leave route server'):tr('Join route server'),'rs',{city:c},S.rs[c]?'ghost sm':'pink sm')}${S.rs[c]&&ppol()!=='open'?`${tr('Off while your peering policy is {pol}',{pol:tr(PPOL_N[ppol()])})}`:''}${btn(UI.confirm==='ix'+c?tr('Really leave?'):tr('Leave IX'),'cancelIx',{city:c},'ghost sm')}
`;
h+=``;
{const elig=mine?[]:ixMembers(c).filter(id=>!set.has(id)&&peerOk(id,'ix',c).ok);if(elig.length>1)h+=`
${btn(tr('Request all {n} willing peers',{n:elig.length}),'peerAll',{city:c},'pink sm')}
`;}
for(const id of ixMembers(c).sort((a,b)=>NSH[b]-NSH[a])){const n=NET[id],on=set.has(id),viaRs=on&&!S.peers[id+'@'+c]&&!mine,chk=peerOk(id,'ix',c);
diff --git a/tests/inbox.test.js b/tests/inbox.test.js
index 65e0f56..4146bfa 100644
--- a/tests/inbox.test.js
+++ b/tests/inbox.test.js
@@ -94,7 +94,7 @@ test('Microsnoft has no capacity on the US east coast, at any price', () => {
test('the peering inbox fills up, wants answers, and max-prefix alerts are growth or a leak', () => {
const { ev, errors } = load();
setup(ev);
- ev("ACT.buildPop({city:'ams'});S.pops.ams.rgen=3;ACT.buyIx({city:'ams',tier:1});compute()");
+ ev("ACT.buildPop({city:'ams'});S.pops.ams.rgen=3;ACT.buyIx({city:'ams',tier:1});S.inbox.pol='selective';compute()");
ev('for(let i=0;i<60;i++)dayTick()');
assert.ok(ev('S.inbox.items.length') >= 2, 'mail arrives with an exchange port');
assert.ok(ev('S.inbox.rep') < 0, 'and ignoring it has a price');
@@ -213,3 +213,40 @@ test('now and then a route is sold out of a wave size, for a while, and asking a
assert.match(ev("document.getElementById('toasts').textContent"), /No 400G capacity on this route/);
assert.deepEqual(errors, []);
});
+
+test('peering policy: open accepts everyone, selective is quieter but manual, closed scares customers; raise all limits at once', () => {
+ const { ev, errors } = load();
+ setup(ev);
+ ev("S.nextFail=S.nextEvent=1e9;ACT.buildPop({city:'ams'});S.pops.ams.rgen=3;ACT.buyIx({city:'ams',tier:1});ACT.rs({city:'ams'});compute()");
+ assert.equal(ev("ppol()"), 'open', 'open by default, as before');
+ const rsOpen = ev("ixSessions('ams').size");
+ assert.ok(rsOpen > 0, 'the route server works');
+ // open: requests are accepted as they come in
+ ev("Math.random=()=>0.01;inboxDay(S.day+1)");
+ assert.equal(ev("S.inbox.items.filter(x=>x.k==='req').length"), 0);
+ assert.ok(ev("Object.keys(S.inbox.tiny).length+Object.keys(S.peers).length") > 0, 'and they become sessions');
+ // selective: the route server stops counting, you ask yourself, and requests wait for you
+ ev("ACT.inboxPol({p:'selective'});compute()");
+ assert.ok(ev("ixSessions('ams').size") < rsOpen, 'no route server sessions');
+ ev("selectCity('ams');ACT.tab({t:'peer'})");
+ assert.match(ev("document.getElementById('panelBody').textContent"), /Off while your peering policy is Selective/);
+ ev("closeModal();S.inbox.items=[];inboxDay(S.day+1)");
+ assert.equal(ev("S.inbox.items.filter(x=>x.k==='req').length"), 1, 'it waits for an answer');
+ // closed: no requests, a sinking reputation, fewer customers calling
+ ev("ACT.inboxPol({p:'closed'});S.inbox.items=[];S.inbox.rep=0;for(let i=0;i<10;i++)inboxDay(S.day+1)");
+ assert.equal(ev("S.inbox.items.filter(x=>x.k==='req').length"), 0);
+ assert.ok(ev('S.inbox.rep') < 0);
+ // raise all: every alert at once, leaks included
+ const net = ev("ixMembers('ams').find(id=>{const n=NET[id];return n.type!=='cdn'&&n.type!=='t1'&&n.pol!=='paid'&&n.share<=0.006;})");
+ ev(`S.peers['${net}@ams']=true;S.inbox.items=[{id:71,k:'mp',key:'${net}@ams',net:'${net}',ix:'ams',day:S.day,lim:50,got:80,leak:false,yrs:2},{id:72,k:'mp',key:'t9',nm:'X',asn:9,ix:'ams',day:S.day,lim:50,got:990000,leak:true,yrs:2}];S.inbox.down['${net}@ams']=1e9;ACT.inbox()`);
+ assert.match(ev("document.getElementById('modalCard').textContent"), /Raise all max-prefix limits/);
+ ev('ACT.inboxRaiseAll()');
+ assert.equal(ev("S.inbox.items.length"), 0);
+ assert.equal(ev(`!!S.inbox.down['${net}@ams']`), false);
+ assert.ok(ev('S.ev.leak&&S.ev.leak.until>S.day'), 'one was a leak');
+ assert.match(ev("document.getElementById('toasts').textContent"), /One of them was a route leak/);
+ // saves keep the policy
+ ev("const o=JSON.parse(JSON.stringify(S));o.inbox.pol='weird';sanitize(o);window.__o=o");
+ assert.equal(ev('__o.inbox.pol'), 'open');
+ assert.deepEqual(errors, []);
+});