Translations keyed by labels instead of English text

tr('pnis.delivery_2_to_6_weeks') instead of tr('Delivery: 2 to 6 weeks'): the
English lives once, in src/i18n/en.js (inlined into the page at build, so no
extra request), and it/pt/fr map the same labels. Changing English wording no
longer renames a key in every dictionary.

- 2,899 labels, made from where each text is used and its first words; short
  shared words are common.*
- plurals are one label with {one, other}: trn('label', n)
- static markup: data-i18n="label", data-i18n-aria-label, data-i18n-title
- saves from 1.33 and older stored English text in a few places; tr() still
  resolves it
- i18n-check: undefined/unused labels, markup drift, plural shape; i18n-add.js
  works on labels and --rename updates src/ too
- the old-branch port tool gives old English-keyed code and dictionaries the
  same labels
This commit is contained in:
Frederic Jung 2026-10-27 11:05:09 +01:00
parent d0ba85ef8f
commit e817beed1a
No known key found for this signature in database
94 changed files with 13681 additions and 10633 deletions

View file

@ -7,7 +7,7 @@ const reachPct=x=>x>0.999?'100%':x>=0.99?(Math.floor(x*1000)/10).toFixed(1)+'%':
const clamp=(v,a,b)=>Math.max(a,Math.min(b,v));
const pick=a=>a[Math.floor(Math.random()*a.length)];
const esc=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
function dateStr(d){const y=1+Math.floor(d/360),m=Math.floor(d/30)%12,dd=d%30+1;return tr('Y{y} · {mon} {d}',{y,mon:MONTHS[m],d:dd});}
function dateStr(d){const y=1+Math.floor(d/360),m=Math.floor(d/30)%12,dd=d%30+1;return tr('helpers.y_y_mon_d',{y,mon:MONTHS[m],d:dd});}
function wrapDx(a,b){let dx=b-a;if(dx>W/2)dx-=W;if(dx<-W/2)dx+=W;return dx;}
function kmBetween(a,b){const A=CITY[a],B=CITY[b];return Math.max(20,Math.round(hav(A.lon,A.lat,B.lon,B.lat)));}
// Cities on a land bridge belong to two landmasses: Cairo reaches Asia overland across the Sinai, the way

View file

@ -10,7 +10,7 @@ function ixMembers(c){if(XIXM[c])return XIXM[c].members.slice();if(S.myIx[c])ret
// LAG: several identical ports bundled into one logical link. Flow hashing is never perfectly even, so a bundle carries ~95% of the sum.
const LAG_MAX=8;
function lagCap(g,n){n=n||1;return g*n*(n>1?0.95:1);}
function lagName(tier,n){return (n||1)>1?`${n}×${PORT[tier].n} LAG`:tr('{port} port',{port:PORT[tier].n});}
function lagName(tier,n){return (n||1)>1?`${n}×${PORT[tier].n} LAG`:tr('common.port_port',{port:PORT[tier].n});}
function ixCap(c){return ixLagF(c)*(S.myIx[c]?myFab(c).g*(myIxLive(c)?1:0):liveCap(PORT[S.ixp[c]].g,ixCity(c),(S.ixSite||{})[c],(S.ixn||{})[c])*(isRemote(c)?REMOTE_CAP:1));}
function ixSessions(c){
const s=new Set(); if(S.ixp[c]===undefined)return s;
@ -22,9 +22,9 @@ function ixSessions(c){
}
function t1Club(){
const miss=[];const pops=Object.keys(S.pops).length;
if(regionsCount()<3)miss.push(tr('POPs on 3+ continents'));
if(pops<10)miss.push(tr('10+ POPs ({n})',{n:pops}));
if(R.served<1500)miss.push(tr('serve 1.5 Tbps ({v})',{v:fmtG(R.served)}));
if(R.sessions<20)miss.push(tr('20+ peering sessions ({n})',{n:R.sessions}));
if(regionsCount()<3)miss.push(tr('exchanges.pops_on_3_continents'));
if(pops<10)miss.push(tr('exchanges.10_pops_n',{n:pops}));
if(R.served<1500)miss.push(tr('exchanges.serve_1_5_tbps_v',{v:fmtG(R.served)}));
if(R.sessions<20)miss.push(tr('exchanges.20_peering_sessions_n',{n:R.sessions}));
return {ok:!miss.length,missing:miss};
}

View file

@ -7,13 +7,13 @@ const pniG1=id=>id==='dtk';
// A beer with their peering coordinator at a conference halves the wait. It is how it really works.
const PNI_SLOW=0.15,pniLead=id=>{const n=pniBig(id)?(Math.random()<PNI_SLOW?180+Math.floor(Math.random()*186):30):14+Math.floor(Math.random()*29);return S.conf&&S.conf.until>S.day?Math.round(n/2):n;};
const pniG=p=>p.g1?1:PORT[p.tier].g,pniPN=p=>p.g1?'1G':PORT[p.tier].n,pniOn=p=>!(p.ready>S.day);
const pniEta=id=>pniBig(id)?tr('Delivery: about a month, sometimes 6 to 12 months'):tr('Delivery: 2 to 6 weeks');
const PNI_G1_COST=1200,pniWhen=n=>n>=60?tr('Their team quotes {m} months',{m:Math.round(n/30)}):tr('Ready in about {n} days',{n});
function pniWait(p,c){return `<div class="kv"><span>${(p.n||1)>1?p.n+'×':''}${pniPN(p)} PNI</span><b>${tr('on order')}</b></div><div class="meta">${tr('About {n} days to go. Nothing to do but wait, or chase it.',{n:Math.max(0,p.ready-S.day)})}</div><div class="btns">${btn(tr('Chase it'),'pniChase',{id:p.id},'ghost sm')}${btn(UI.confirm===p.id?tr('Really remove?'):tr('Cancel the order'),'cancelPni',{id:p.id},'ghost sm')}</div>`;}
const pniEta=id=>pniBig(id)?tr('pnis.delivery_about_a_month_sometimes_6'):tr('pnis.delivery_2_to_6_weeks');
const PNI_G1_COST=1200,pniWhen=n=>n>=60?tr('pnis.their_team_quotes_m_months',{m:Math.round(n/30)}):tr('pnis.ready_in_about_n_days',{n});
function pniWait(p,c){return `<div class="kv"><span>${(p.n||1)>1?p.n+'×':''}${pniPN(p)} PNI</span><b>${tr('common.on_order')}</b></div><div class="meta">${tr('pnis.about_n_days_to_go_nothing',{n:Math.max(0,p.ready-S.day)})}</div><div class="btns">${btn(tr('common.chase_it'),'pniChase',{id:p.id},'ghost sm')}${btn(UI.confirm===p.id?tr('common.really_remove'):tr('pnis.cancel_the_order'),'cancelPni',{id:p.id},'ghost sm')}</div>`;}
function pniDay(d){for(const p of S.pni){const nm=esc(NET[p.net].name),city=esc(CITY[p.city].name);
if(p.ready===d)toast(tr('<b>PNI with {net} is up in {city}.</b><br>A cross-connect in {dc}. Private and fast.',{net:nm,city,dc:esc(siteName(p.city,'a'))}),'good');
if(p.up&&p.up.ready<=d){p.tier=p.up.tier;p.n=p.up.n;if(p.up.g1)p.g1=true;else delete p.g1;delete p.up;toast(tr('<b>Augment with {net} delivered in {city}.</b><br>Now {port}.',{net:nm,city,port:((p.n||1)>1?p.n+'×':'')+pniPN(p)}),'good');}}}
if(p.ready===d)toast(tr('pnis.pni_with_net_is_up_in',{net:nm,city,dc:esc(siteName(p.city,'a'))}),'good');
if(p.up&&p.up.ready<=d){p.tier=p.up.tier;p.n=p.up.n;if(p.up.g1)p.g1=true;else delete p.g1;delete p.up;toast(tr('pnis.augment_with_net_delivered_in_city',{net:nm,city,port:((p.n||1)>1?p.n+'×':'')+pniPN(p)}),'good');}}}
// Microsnoft has no capacity on the US east coast. Not for a PNI, not at an exchange, not for anyone.
const US_EAST=['ash','nyc','bos','atn','mia'];
const MSF_NOPE=[N_('No capacity in US East. You can join the waitlist; the waitlist is also out of capacity.'),N_('US East is sold out until further notice. Further notice is also sold out.'),N_('Their peering team says US East is “capacity constrained”, which is cloud for “no”.'),N_('A new region is coming online soon. It has been coming online soon since 2019.')];
const MSF_NOPE=[N_('pnis.no_capacity_in_us_east_you'),N_('pnis.us_east_is_sold_out_until'),N_('pnis.their_peering_team_says_us_east'),N_('pnis.a_new_region_is_coming_online')];
const msfNope=(id,city)=>id==='msf'&&!!city&&US_EAST.includes(ixCity(city));

View file

@ -1,11 +1,11 @@
/* ---------- The peering inbox ----------
Every exchange port brings mail: peering requests from networks nobody has heard of, and sessions that drop
because someone's PeeringDB says 50 prefixes and they now send 400 (or a full table). Answer it, or hire an AI. */
const PPOL_N={open:N_('Open to all'),selective:N_('Selective'),closed:N_('Closed')},PPOL_D={open:N_('Everyone who asks gets a session, and the route servers work. Lots of tiny peers, and lots of max-prefix alerts.'),selective:N_('Fewer requests, and you answer them yourself. No route servers: go to each exchange and request the networks you want.'),closed:N_('Nobody asks, and no route servers. Customers hear that you are hard to reach, so fewer of them call, and your reputation sinks.')};
const PPOL_N={open:N_('peering_inbox.open_to_all'),selective:N_('common.selective'),closed:N_('common.closed')},PPOL_D={open:N_('peering_inbox.everyone_who_asks_gets_a_session'),selective:N_('peering_inbox.fewer_requests_and_you_answer_them'),closed:N_('peering_inbox.nobody_asks_and_no_route_servers')};
const AI_MO=Math.round(20e6/12),INBOX_MAX=80,IBX_LEAKS=['nfx','ggl','fbk','amz','msf'];
const TINY=['Basement Broadband','Uncle Dave’s WISP','Fibre Fiesta','Raspberry Pi Transit','Vanity ASN Ltd','Moonshot Crypto Hosting','Minecraft Collective','Bob’s Bits','Homelab Heroes','Hackerspace Uplink','Tiny Tower Networks','Pigeon Post IP','Retro BBS Revival','Overkill Home Network','Two Guys and a Rack','Big Dreams Small Prefix','Mesh-y Business','Garden Shed Datacenter','Carrier-Grade NAT Fan Club','LIR in a Box','Yet Another VPN','Grandma’s Fibre Co-op','Seedbox Society','The /24 That Could'];
const REQ_SAY=[N_('Hi! We would like to peer with you at {ix}. Our PeeringDB record is up to date.'),N_('Dear Sir or Madam, please peer. We have three prefixes and very big plans.'),N_('We noticed you are at {ix}. So are we. Shall we?'),N_('Hello, please find attached our peering request as a Word document, scanned from a printout.'),N_('Peering request, fifth attempt. Is anyone there?'),N_('Hey, quick one: can you peer with us at {ix}? We have a very important Minecraft server.'),N_('Greetings. We are a fast-growing network. Last year we had one customer; this year we have two.'),N_('Please configure sessions with us at {ix}. We will do ours next week, or the week after.')];
const IBX_AI=[N_('Replied to a peering request with a haiku about BGP. No answer yet.'),N_('Signed you up for a webinar on “Peering in the Age of AI”.'),N_('Opened a ticket with itself to review its own decisions. It approved them.'),N_('Wrote a thousand-word apology to a network you never peered with.'),N_('Updated your PeeringDB record. Your NOC phone number is now a pizza place.'),N_('Asked NetChill’s peering team to “please provide more Netchill”.')];
const REQ_SAY=[N_('peering_inbox.hi_we_would_like_to_peer'),N_('peering_inbox.dear_sir_or_madam_please_peer'),N_('peering_inbox.we_noticed_you_are_at_ix'),N_('peering_inbox.hello_please_find_attached_our'),N_('peering_inbox.peering_request_fifth_attempt_is'),N_('peering_inbox.hey_quick_one_can_you_peer'),N_('peering_inbox.greetings_we_are_a_fast_growing'),N_('peering_inbox.please_configure_sessions_with_us_at')];
const IBX_AI=[N_('peering_inbox.replied_to_a_peering_request_with'),N_('peering_inbox.signed_you_up_for_a_webinar'),N_('peering_inbox.opened_a_ticket_with_itself_to'),N_('peering_inbox.wrote_a_thousand_word_apology_to'),N_('peering_inbox.updated_your_peeringdb_record_your'),N_('peering_inbox.asked_netchill_s_peering_team_to')];
function ibx(){if(!S.inbox||typeof S.inbox!=='object')S.inbox={items:[],down:{},tiny:{},rep:0,bot:false,log:[],seq:0};return S.inbox;}
// Reputation nudges selective networks by up to 10% either way: worth caring about, never a wall.
// Your peering policy. Open: everyone who asks gets a session and the route servers work. Selective: fewer requests,
@ -13,7 +13,7 @@ function ibx(){if(!S.inbox||typeof S.inbox!=='object')S.inbox={items:[],down:{},
// and customers hear that you are hard to reach.
const PPOL=['open','selective','closed'],ppol=()=>(S&&S.inbox&&PPOL.includes(S.inbox.pol))?S.inbox.pol:'open';
const repMul=()=>1-clamp((S.inbox&&S.inbox.rep)||0,-10,5)*0.01;
const repName=r=>r>=1?tr('Responsive'):r>=-2?tr('Average'):r>=-6?tr('Mostly ignores email'):tr('Black hole');
const repName=r=>r>=1?tr('common.responsive'):r>=-2?tr('common.average'):r>=-6?tr('peering_inbox.mostly_ignores_email'):tr('common.black_hole');
const ibxOpen=()=>S.inbox?S.inbox.items.length:0,ibxUrgent=()=>S.inbox?S.inbox.items.filter(x=>x.k==='mp').length:0;
const mpDown=(id,c)=>{const t=S.inbox&&S.inbox.down[id+'@'+c];return !!t&&t>S.day;};
const ibxWho=x=>x.net?NET[x.net].name:x.nm,ibxAsn=x=>x.net?NET[x.net].asn:x.asn;
@ -33,13 +33,13 @@ function inboxDay(d){const I=ibx(),ixs=Object.keys(S.ixp);
const lim=pick([10,20,50,100,200,500,1000]),leak=Math.random()<0.3,yrs=1+Math.floor(Math.random()*9);
I.items.push({id:++I.seq,k:'mp',key:x.key,net:x.net,nm:x.nm,asn:x.asn,ix:x.ix,day:d,lim,got:leak?940000+Math.floor(Math.random()*90000):Math.ceil(lim*(1.15+Math.random()*1.6)),leak,yrs});
// A session that blows its limit is down for at most a few weeks: the other side eventually notices too.
if(x.net){I.down[x.key]=d+20+Math.floor(Math.random()*20);toast(tr('<b>Max-prefix limit hit: {who} at {ix}.</b><br>The session is down until you look at it.',{who:esc(ibxWho(x)),ix:esc(ixName(x.ix))}),'bad',[{l:tr('Inbox'),act:'inbox',args:{}}]);}}}
if(x.net){I.down[x.key]=d+20+Math.floor(Math.random()*20);toast(tr('peering_inbox.max_prefix_limit_hit_who_at',{who:esc(ibxWho(x)),ix:esc(ixName(x.ix))}),'bad',[{l:tr('common.inbox'),act:'inbox',args:{}}]);}}}
// unanswered mail: requests go stale and people start asking around about you
for(const x of I.items){if(x.k==='mp')I.rep-=0.05;else if(d-x.day===14)x.bump=1;}
// A max-prefix alert nobody answers resolves itself in the end: the other side raises it, or gives up.
I.items=I.items.filter(x=>x.k!=='mp'||(x.net?(I.down[x.key]||0)>d:d-x.day<=30));
const old=I.items.filter(x=>x.k==='req'&&d-x.day>30);if(old.length){I.rep-=0.25*old.length;I.items=I.items.filter(x=>!old.includes(x));
if(old.some(x=>x.net))toast(tr('<b>{who} asked a mailing list whether anyone has a working contact at {me}.</b><br>Their peering request sat in your inbox for a month.',{who:esc(ibxWho(old.find(x=>x.net))),me:esc(S.name)}),'bad',[{l:tr('Inbox'),act:'inbox',args:{}}]);}
if(old.some(x=>x.net))toast(tr('peering_inbox.who_asked_a_mailing_list_whether',{who:esc(ibxWho(old.find(x=>x.net))),me:esc(S.name)}),'bad',[{l:tr('common.inbox'),act:'inbox',args:{}}]);}
while(I.items.length>INBOX_MAX){const i=I.items.findIndex(x=>x.k==='req');if(i<0)break;I.items.splice(i,1);I.rep-=0.5;}
I.rep=clamp(I.rep,-10,5);
if(I.bot)inboxBot();}
@ -47,37 +47,37 @@ function inboxDay(d){const I=ibx(),ixs=Object.keys(S.ixp);
function ibxAnswer(id,a,bot){const I=ibx(),i=I.items.findIndex(x=>x.id===id);if(i<0)return false;const x=I.items[i];I.items.splice(i,1);const who=ibxWho(x),ix=ixName(x.ix);
if(x.k==='req'){if(a==='accept'){if(x.net){if(S.ixp[x.ix]!==undefined)S.peers[x.net+'@'+x.ix]=true;}else if(Object.keys(I.tiny).length<200)I.tiny[x.asn]={nm:x.nm,ix:x.ix,stale:!!x.stale};I.rep+=0.3;}else I.rep+=0.2;}
else if(a==='raise'){delete I.down[x.key];if(x.leak){const n=pick(IBX_LEAKS);S.ev.leak={net:n,until:S.day+4};
addInc({type:'leak',ref:n,until:S.day+4,msg:tr('{who} at {ix} was sending a full table, and the max-prefix limit was the only thing stopping it. With the limit raised, {net}’s prefixes point at their basement. Traffic to {net} over transit is black-holed for a few days.',{who,ix,net:NET[n].name}),cost:0});
if(!bot)toast(tr('<b>That was a route leak.</b><br>{who} was announcing {n} prefixes: a full table. Next time, keep it down.',{who:esc(who),n:x.got.toLocaleString()}),'bad');I.rep-=1;}
else{I.rep+=0.3;if(!bot)toast(tr('<b>Session with {who} is back up.</b><br>New limit: {n} prefixes. They promise to update PeeringDB.',{who:esc(who),n:Math.ceil(x.got*1.5).toLocaleString()}),'good');}}
addInc({type:'leak',ref:n,until:S.day+4,msg:tr('peering_inbox.who_at_ix_was_sending_a',{who,ix,net:NET[n].name}),cost:0});
if(!bot)toast(tr('peering_inbox.that_was_a_route_leak_who',{who:esc(who),n:x.got.toLocaleString()}),'bad');I.rep-=1;}
else{I.rep+=0.3;if(!bot)toast(tr('peering_inbox.session_with_who_is_back_up',{who:esc(who),n:Math.ceil(x.got*1.5).toLocaleString()}),'good');}}
else{const back=S.day+(x.leak?3:10)+Math.floor(Math.random()*(x.leak?8:21));if(x.net)I.down[x.key]=back;I.rep+=x.leak?0.3:0.1;
if(!bot)toast(x.leak?tr('<b>Good call: it was a route leak.</b><br>{who} found a fat-fingered route map. The session comes back on its own in a few days.',{who:esc(who)}):tr('<b>The session stays down.</b><br>{who} will update PeeringDB and ask again. Eventually.',{who:esc(who)}),x.leak?'good':'');}
if(!bot)toast(x.leak?tr('peering_inbox.good_call_it_was_a_route',{who:esc(who)}):tr('peering_inbox.the_session_stays_down_who_will',{who:esc(who)}),x.leak?'good':'');}
I.rep=clamp(I.rep,-10,5);return true;}
// The AI agent clears the inbox every day. It is fast, polite and wrong about a third of the time.
function inboxBot(){const I=ibx();let acc=0,dec=0;
for(const x of I.items.slice()){const oops=Math.random()<0.3;
if(x.k==='req'){const want=!x.stale||!!x.net;const a=(want!==oops)?'accept':'decline';ibxAnswer(x.id,a,true);a==='accept'?acc++:dec++;if(oops&&a==='decline'&&x.net)ibxLog(N_('Declined {who} at {ix}: “not a strategic fit”. They were.'),{who:ibxWho(x),ix:ixName(x.ix)});}
if(x.k==='req'){const want=!x.stale||!!x.net;const a=(want!==oops)?'accept':'decline';ibxAnswer(x.id,a,true);a==='accept'?acc++:dec++;if(oops&&a==='decline'&&x.net)ibxLog(N_('peering_inbox.declined_who_at_ix_not_a'),{who:ibxWho(x),ix:ixName(x.ix)});}
else{const a=(x.leak!==oops)?'keep':'raise';ibxAnswer(x.id,a,true);
if(a==='raise'&&x.leak)ibxLog(N_('Raised the max-prefix limit for {who} at {ix} to {n}. They seemed nice.'),{who:ibxWho(x),ix:ixName(x.ix),n:Math.ceil(x.got*1.5).toLocaleString()});
else if(a==='keep'&&!x.leak)ibxLog(N_('Kept {who} down at {ix} for “suspicious growth”. They had grown by one customer.'),{who:ibxWho(x),ix:ixName(x.ix)});
else ibxLog(a==='raise'?N_('Raised the max-prefix limit for {who} at {ix}. Correctly, this time.'):N_('Kept {who} down at {ix}: it was a route leak. Nailed it.'),{who:ibxWho(x),ix:ixName(x.ix)});}}
if(acc||dec)ibxLog(N_('Answered your mail: {a} accepted, {d} declined.'),{a:acc,d:dec});
if(Math.random()<0.01){const ks=Object.keys(S.peers);if(ks.length){const k=pick(ks),[id,c]=k.split('@');delete S.peers[k];ibxLog(N_('Tidied up a session it decided was unused: de-peered {who} at {ix}.'),{who:NET[id].name,ix:ixName(c)});}}
if(a==='raise'&&x.leak)ibxLog(N_('peering_inbox.raised_the_max_prefix_limit_for'),{who:ibxWho(x),ix:ixName(x.ix),n:Math.ceil(x.got*1.5).toLocaleString()});
else if(a==='keep'&&!x.leak)ibxLog(N_('peering_inbox.kept_who_down_at_ix_for'),{who:ibxWho(x),ix:ixName(x.ix)});
else ibxLog(a==='raise'?N_('peering_inbox.raised_the_max_prefix_limit_for_7b4b'):N_('peering_inbox.kept_who_down_at_ix_it'),{who:ibxWho(x),ix:ixName(x.ix)});}}
if(acc||dec)ibxLog(N_('peering_inbox.answered_your_mail_a_accepted_d'),{a:acc,d:dec});
if(Math.random()<0.01){const ks=Object.keys(S.peers);if(ks.length){const k=pick(ks),[id,c]=k.split('@');delete S.peers[k];ibxLog(N_('peering_inbox.tidied_up_a_session_it_decided'),{who:NET[id].name,ix:ixName(c)});}}
if(Math.random()<0.08)ibxLog(pick(IBX_AI),{});}
function inboxModal(){const I=ibx(),items=I.items.slice().sort((a,b)=>(b.k==='mp')-(a.k==='mp')||b.day-a.day),reqs=items.filter(x=>x.k==='req').length,mps=items.length-reqs;
const age=x=>{const n=S.day-x.day;return n?trn('{n} day ago','{n} days ago',n):tr('today');};
const pdb=x=>x.stale?trn('PeeringDB last updated {n} year ago','PeeringDB last updated {n} years ago',x.yrs):tr('PeeringDB updated last month');
const card=x=>x.k==='mp'?`<div class="ibx mp"><div class="nm">⚠️ ${tr('Max-prefix limit hit: {who} at {ix}',{who:esc(ibxWho(x)),ix:esc(ixName(x.ix))})}</div>
<div class="meta">AS${ibxAsn(x)} · ${age(x)}</div><p class="note">${tr('Configured: {lim} prefixes. Received: {got}.',{lim:x.lim.toLocaleString(),got:x.got.toLocaleString()})} ${trn('Their PeeringDB says {lim}, last updated {n} year ago.','Their PeeringDB says {lim}, last updated {n} years ago.',x.yrs,{lim:x.lim.toLocaleString()})}</p>
<div class="btns">${btn(tr('Raise the limit'),'inboxAct',{id:x.id,a:'raise'},'sm')}${btn(tr('Keep it down'),'inboxAct',{id:x.id,a:'keep'},'ghost sm')}</div></div>`
:`<div class="ibx"><div class="nm">${esc(ibxWho(x))} <span class="meta">AS${ibxAsn(x)}</span>${x.bump?` <span class="tag">${tr('bumped')}</span>`:''}</div><div class="meta">${esc(ixName(x.ix))} · ${age(x)} · ${pdb(x)}</div>
<p class="note">“${esc(tr(REQ_SAY[x.say]||REQ_SAY[0],{ix:ixName(x.ix)}))}”</p><div class="btns">${btn(tr('Accept'),'inboxAct',{id:x.id,a:'accept'},'sm')}${btn(tr('Decline'),'inboxAct',{id:x.id,a:'decline'},'ghost sm')}</div></div>`;
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('Peering inbox')}</div><h2 style="font-size:26px">📬 ${trn('{n} unanswered','{n} unanswered',items.length)}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('Close')}">×</button></div>
<p class="tagline">${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.')}</p>
<div class="kv"><span>${tr('Your reputation')}</span><b>${repName(I.rep)}</b></div>
<div class="kv"><span>${tr('Peering policy')}</span><b>${tr(PPOL_N[ppol()])}</b></div><div class="seg">${PPOL.map(p=>btn(tr(PPOL_N[p]),'inboxPol',{p},ppol()===p?'sm':'ghost sm')).join('')}</div><p class="meta">${tr(PPOL_D[ppol()])}</p>
<div class="ibx ai">${I.bot?`<div class="nm">🤖 ${tr('Large Peering Model is answering your mail')}</div><div class="meta">${tr('{price}/year. It never sleeps, never complains and is often wrong.',{price:fmt$(20e6)})}</div>
${I.log.length?`<pre class="term">${I.log.slice(0,8).map(e=>esc(tr('Day {d}',{d:e.d})+': '+tr(e.m,e.a))).join('\n')}</pre>`:''}<div class="btns">${btn(tr('Fire the AI'),'inboxBot',{on:0},'ghost sm')}</div>`
:`<div class="nm">🤖 ${tr('Large Peering Model')}</div><div class="meta">${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)})}</div><div class="btns">${btn(tr('Hire it <small>{mo}/mo</small>',{mo:fmt$(AI_MO)}),'inboxBot',{on:1},'aibtn sm',S.cash<AI_MO)}</div>`}</div>
${reqs>1||mps>1?`<div class="btns">${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'):''}</div>`:''}
${items.length?items.slice(0,40).map(card).join(''):`<p class="empty">${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.')}</p>`}`);}
const age=x=>{const n=S.day-x.day;return n?trn('peering_inbox.n_day_ago',n):tr('common.today_4203');};
const pdb=x=>x.stale?trn('peering_inbox.peeringdb_last_updated_n_year_ago',x.yrs):tr('peering_inbox.peeringdb_updated_last_month');
const card=x=>x.k==='mp'?`<div class="ibx mp"><div class="nm">⚠️ ${tr('peering_inbox.max_prefix_limit_hit_who_at_5c56',{who:esc(ibxWho(x)),ix:esc(ixName(x.ix))})}</div>
<div class="meta">AS${ibxAsn(x)} · ${age(x)}</div><p class="note">${tr('peering_inbox.configured_lim_prefixes_received_got',{lim:x.lim.toLocaleString(),got:x.got.toLocaleString()})} ${trn('peering_inbox.their_peeringdb_says_lim_last',x.yrs,{lim:x.lim.toLocaleString()})}</p>
<div class="btns">${btn(tr('peering_inbox.raise_the_limit'),'inboxAct',{id:x.id,a:'raise'},'sm')}${btn(tr('peering_inbox.keep_it_down'),'inboxAct',{id:x.id,a:'keep'},'ghost sm')}</div></div>`
:`<div class="ibx"><div class="nm">${esc(ibxWho(x))} <span class="meta">AS${ibxAsn(x)}</span>${x.bump?` <span class="tag">${tr('common.bumped')}</span>`:''}</div><div class="meta">${esc(ixName(x.ix))} · ${age(x)} · ${pdb(x)}</div>
<p class="note">“${esc(tr(REQ_SAY[x.say]||REQ_SAY[0],{ix:ixName(x.ix)}))}”</p><div class="btns">${btn(tr('common.accept'),'inboxAct',{id:x.id,a:'accept'},'sm')}${btn(tr('common.decline'),'inboxAct',{id:x.id,a:'decline'},'ghost sm')}</div></div>`;
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('common.peering_inbox')}</div><h2 style="font-size:26px">📬 ${trn('peering_inbox.n_unanswered',items.length)}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>
<p class="tagline">${tr('peering_inbox.every_exchange_port_brings_mail')}</p>
<div class="kv"><span>${tr('common.your_reputation')}</span><b>${repName(I.rep)}</b></div>
<div class="kv"><span>${tr('common.peering_policy')}</span><b>${tr(PPOL_N[ppol()])}</b></div><div class="seg">${PPOL.map(p=>btn(tr(PPOL_N[p]),'inboxPol',{p},ppol()===p?'sm':'ghost sm')).join('')}</div><p class="meta">${tr(PPOL_D[ppol()])}</p>
<div class="ibx ai">${I.bot?`<div class="nm">🤖 ${tr('peering_inbox.large_peering_model_is_answering')}</div><div class="meta">${tr('peering_inbox.price_year_it_never_sleeps_never',{price:fmt$(20e6)})}</div>
${I.log.length?`<pre class="term">${I.log.slice(0,8).map(e=>esc(tr('peering_inbox.day_d',{d:e.d})+': '+tr(e.m,e.a))).join('\n')}</pre>`:''}<div class="btns">${btn(tr('peering_inbox.fire_the_ai'),'inboxBot',{on:0},'ghost sm')}</div>`
:`<div class="nm">🤖 ${tr('peering_inbox.large_peering_model')}</div><div class="meta">${tr('peering_inbox.an_ai_agent_that_answers_every',{price:fmt$(20e6)})}</div><div class="btns">${btn(tr('peering_inbox.hire_it_mo_mo',{mo:fmt$(AI_MO)}),'inboxBot',{on:1},'aibtn sm',S.cash<AI_MO)}</div>`}</div>
${reqs>1||mps>1?`<div class="btns">${reqs>1?btn(tr('peering_inbox.accept_all_requests'),'inboxAll',{a:'accept'},'sm')+btn(tr('peering_inbox.decline_all_requests'),'inboxAll',{a:'decline'},'ghost sm'):''}${mps>1?btn(tr('peering_inbox.raise_all_max_prefix_limits'),'inboxRaiseAll',{},'sm'):''}</div>`:''}
${items.length?items.slice(0,40).map(card).join(''):`<p class="empty">${Object.keys(S.ixp).length?tr('peering_inbox.inbox_zero_enjoy_it_while_it'):tr('peering_inbox.no_mail_yet_buy_an_ix')}</p>`}`);}

View file

@ -1,8 +1,8 @@
/* Big networks sometimes refuse to peer in a particular city, for a while. Each (network, city)
pair gets a stable verdict per window, derived from a hash, so asking again does not reroll it. */
const SNUB_WIN=150,SNUB_P=0.22;
const SNUB_IX=[tr('Only peers over PNIs in this metro. Order a cross-connect instead.'),tr('Their IX port here is full until the next upgrade. They promise it is soon.'),tr('Moved everything in this city to PNIs. Please read their PearingDB page, all 40 pages of it.'),tr('The peering coordinator for this city is on a six-month sabbatical.'),tr('Their policy here says "IX peering by invitation only". You were not invited.')];
const SNUB_ALL=[tr('Not accepting new peers in this region right now.'),tr('Region frozen while they renegotiate with the local incumbent.'),tr('Their routers in this city are "at capacity". They are not.'),tr('Already reach you through your transit provider here and think that is fine.'),tr('Their lawyers are reviewing every peering agreement in this country. Again.'),tr('A new VP wants to "monetise interconnection" in this market.')];
const SNUB_IX=[tr('peering_policy.only_peers_over_pnis_in_this'),tr('peering_policy.their_ix_port_here_is_full'),tr('peering_policy.moved_everything_in_this_city_to'),tr('peering_policy.the_peering_coordinator_for_this'),tr('peering_policy.their_policy_here_says_ix_peering')];
const SNUB_ALL=[tr('peering_policy.not_accepting_new_peers_in_this'),tr('peering_policy.region_frozen_while_they_renegotiate'),tr('peering_policy.their_routers_in_this_city_are'),tr('peering_policy.already_reach_you_through_your'),tr('peering_policy.their_lawyers_are_reviewing_every'),tr('peering_policy.a_new_vp_wants_to_monetise')];
function hstr(t){let h=2166136261;for(let i=0;i<t.length;i++){h^=t.charCodeAt(i);h=Math.imul(h,16777619);}return h>>>0;}
function bigPeer(n){return !!n&&n.pol==='selective'&&n.share>=0.03;}
function snub(id,c){
@ -15,8 +15,8 @@ function snub(id,c){
/* Remote peering: offered, but discouraged. A reseller marks up the port, oversubscribes it,
and many selective networks refuse members who are not physically in the building. */
const REMOTE_FEE=1.5,REMOTE_CAP=0.8;
const REMOTE_WARN=`<p class="note" style="color:var(--bad)">${tr('<b>Remote peering is a last resort.</b> Ports come through a reseller at 1.5× the price, only 80% of the port is really yours, latency rides the fabric, one fabric outage drops every session, and many selective networks refuse remote members. A POP here is better.')}</p>`;
const REMOTE_WHY=[tr('Policy: no remote peers. Be in the building or be in the transit bill.'),tr('Saw your session come in over a fabric and said "we can smell the VXC from here".'),tr('Only peers with members they can reach without a 1,500 km hairpin.'),tr('Their PearingDB entry says "Remote peering: No (we mean it)".'),tr('Tried a remote peer once. It flapped during a product launch. Never again.')];
const REMOTE_WARN=`<p class="note" style="color:var(--bad)">${tr('peering_policy.remote_peering_is_a_last_resort')}</p>`;
const REMOTE_WHY=[tr('peering_policy.policy_no_remote_peers_be_in'),tr('peering_policy.saw_your_session_come_in_over'),tr('peering_policy.only_peers_with_members_they_can'),tr('peering_policy.their_pearingdb_entry_says_remote'),tr('peering_policy.tried_a_remote_peer_once_it')];
function isRemote(c){return S.ixp[c]!==undefined&&!S.pops[ixCity(c)]&&!S.myIx[c];}
function noRemote(id){const n=NET[id];if(!n||n.pol!=='selective')return false;return hstr(id+'|remote')%100<(n.share>=0.03?60:30);}
/* Europe's peering market is crowded and competitive: ports are cheaper, and incumbents cut prices
@ -27,6 +27,6 @@ function ixPortMo(c,tier){const X=XIXM[c];if(X&&tier<=(X.freeTo??-1))return 0;re
function ixPriceWar(d){if(!S.ixp||Math.random()>=1/120)return;
const mine=Object.keys(S.ixp).filter(x=>{const c=ixCity(x);return CITY[c].reg==='EU'&&ixStatic(c).length>1;});if(!mine.length)return;
const x=pick(mine),c=ixCity(x),rival=pick(ixStatic(c).filter(y=>y!==x));
if(isDk(x)){toast(tr('<b>{rival} is poaching DE-KICKS members in {city}.</b><br>DE-KICKS responded with a webinar about "the value of premium interconnection". Prices unchanged.',{rival:esc(ixName(rival)),city:esc(CITY[c].name)}),'bad');return;}
if(isDk(x)){toast(tr('peering_policy.rival_is_poaching_de_kicks_members',{rival:esc(ixName(rival)),city:esc(CITY[c].name)}),'bad');return;}
S.ixCut=S.ixCut||{};const cur=S.ixCut[x]||1;if(cur<=0.62)return;S.ixCut[x]=+Math.max(0.6,cur*0.9).toFixed(3);
toast(tr('<b>Price war in {city}!</b><br>{ix} cut its port prices 10% to stop members drifting to {rival}. Your invoice just got smaller.',{city:esc(CITY[c].name),ix:esc(ixName(x)),rival:esc(ixName(rival))}),'good');}
toast(tr('peering_policy.price_war_in_city_ix_cut',{city:esc(CITY[c].name),ix:esc(ixName(x)),rival:esc(ixName(rival))}),'good');}

View file

@ -3,28 +3,28 @@
you have to opt out of, and a retention offer when you try to leave. */
const DK_CITIES=['fra','mad','mrs','dxb','bom','nyc'];
const isDk=c=>(DK_CITIES.includes(c)||scnRule('dkAll'))&&!!CITY[c]&&!!CITY[c].ix&&!S.myIx[c];
const DK_ADDONS=[['Blackholing Plus™',tr('Like blackholing, but with a Plus.')],['Route Server Gold',tr('The same route server, in a gold-coloured portal.')],['Premium Port LEDs',tr('Your port light now blinks in brand colours.')],['Strategic Peering Insights',tr('A monthly PDF of your own traffic graphs.')],['GlobePeer Ready™',tr('Makes your port "ready" for a product you did not buy.')],['Cloud Exchange Readiness Fee',tr('A fee for being ready for the cloud.')],['Account Manager Lunch Fund',tr('Your account manager is hungry.')]];
const DK_STALL=[tr('Your account manager would love to "align on value" first. Strategic call booked for next week.'),tr('Pricing is reviewed by the Global Commercial Council, who meet on the next full moon.'),tr('They sent a 14-page NDA before they can even repeat the price. Lawyers estimate a week.'),tr('Your account manager is at a conference in Dubai. And then one in Madrid.')];
const DK_ADDONS=[['Blackholing Plus™',tr('de_kicks.like_blackholing_but_with_a_plus')],['Route Server Gold',tr('de_kicks.the_same_route_server_in_a')],['Premium Port LEDs',tr('de_kicks.your_port_light_now_blinks_in')],['Strategic Peering Insights',tr('de_kicks.a_monthly_pdf_of_your_own')],['GlobePeer Ready™',tr('de_kicks.makes_your_port_ready_for_a')],['Cloud Exchange Readiness Fee',tr('de_kicks.a_fee_for_being_ready_for')],['Account Manager Lunch Fund',tr('de_kicks.your_account_manager_is_hungry')]];
const DK_STALL=[tr('de_kicks.your_account_manager_would_love_to'),tr('de_kicks.pricing_is_reviewed_by_the_global'),tr('de_kicks.they_sent_a_14_page_nda'),tr('de_kicks.your_account_manager_is_at_a')];
function dkMult(c){if(!S||!isDk(c)||!S.dk||!S.dk.m[c])return 1;const ret=S.dk.ret[c];return S.dk.m[c]*(ret&&ret>S.day?0.6:1);}
function dkAddonMo(c){return S.dk&&S.dk.add[c]?S.dk.add[c].reduce((a,x)=>a+x.mo,0):0;}
function dkState(){S.dk=S.dk||{m:{},add:{},ret:{},retUsed:{},stall:0,q:null};return S.dk;}
function dkQuoteMult(){const pops=Object.keys(S.pops).length,big=Math.min(1.2,pops*0.04+(R.served||0)/20000);return +(0.95+Math.random()*0.45+big).toFixed(2);}
function dkQuoteModal(){const q=S.dk.q,c=q.city,mo=Math.round(PORT[q.tier].ix*(S.pops[c]?1:REMOTE_FEE)*q.m*ixMul(c));
openModal(`<div class="eyebrow">${tr('DE-KICKS Group · Sales')}</div><h2 style="font-size:26px">${tr('Your personalised {port} quote for {ix}',{port:PORT[q.tier].n,ix:esc(ixName(c))})}</h2>
<p class="tagline">${tr("“Thanks for your interest! We don't publish prices, because every customer is unique.”")}</p>
<div class="kv"><span>${tr('Monthly price, just for you')}</span><b>${tr('{price}/mo',{price:fmt$(mo)})}</b></div>
<div class="kv"><span>${tr('List price')}</span><b>${tr('Confidential')}</b></div>
<div class="kv"><span>${tr('What others pay')}</span><b>${tr('Covered by NDA')}</b></div>
<p class="note">${tr('Quotes go up with how big you look.')} ${q.h>=3?tr('Your account manager has stopped replying to haggling.'):tr('Haggles left: {n}.',{n:3-q.h})}</p>
<div class="btns">${btn(tr('Sign <small>{price}/mo</small>',{price:fmt$(mo)}),'dkAccept',{},'pink',S.cash<mo)}${btn(tr('Haggle'),'dkHaggle',{},'',q.h>=3)}${btn(tr('Walk away'),'dkWalk',{},'ghost')}</div>`);}
openModal(`<div class="eyebrow">${tr('de_kicks.de_kicks_group_sales')}</div><h2 style="font-size:26px">${tr('de_kicks.your_personalised_port_quote_for_ix',{port:PORT[q.tier].n,ix:esc(ixName(c))})}</h2>
<p class="tagline">${tr('de_kicks.thanks_for_your_interest_we_don')}</p>
<div class="kv"><span>${tr('de_kicks.monthly_price_just_for_you')}</span><b>${tr('common.price_mo',{price:fmt$(mo)})}</b></div>
<div class="kv"><span>${tr('common.list_price')}</span><b>${tr('common.confidential')}</b></div>
<div class="kv"><span>${tr('de_kicks.what_others_pay')}</span><b>${tr('de_kicks.covered_by_nda')}</b></div>
<p class="note">${tr('de_kicks.quotes_go_up_with_how_big')} ${q.h>=3?tr('de_kicks.your_account_manager_has_stopped'):tr('de_kicks.haggles_left_n',{n:3-q.h})}</p>
<div class="btns">${btn(tr('de_kicks.sign_price_mo',{price:fmt$(mo)}),'dkAccept',{},'pink',S.cash<mo)}${btn(tr('common.haggle'),'dkHaggle',{},'',q.h>=3)}${btn(tr('common.walk_away'),'dkWalk',{},'ghost')}</div>`);}
function dkTick(d){if(!S.dk)return;const dk=S.dk;
for(const c in S.ixp){if(!isDk(c))continue;
if(dk.ret[c]&&dk.ret[c]===d){dk.m[c]=+(dk.m[c]*1.1).toFixed(3);toast(tr('<b>Your {ix} promo ended.</b><br>Price is back, plus 10% for "loyalty programme administration".',{ix:esc(ixName(c))}),'bad');}
if(dk.m[c]&&(d+hstr(c)%90)%365===0){const f=1.08+Math.random()*0.07;dk.m[c]=+(dk.m[c]*f).toFixed(3);toast(tr('<b>DE-KICKS has harmonised its prices.</b><br>Harmonised means up: {ix} now costs {p}% more. Thank you for your continued partnership.',{ix:esc(ixName(c)),p:Math.round((f-1)*100)}),'bad');}
if(dk.ret[c]&&dk.ret[c]===d){dk.m[c]=+(dk.m[c]*1.1).toFixed(3);toast(tr('de_kicks.your_ix_promo_ended_price_is',{ix:esc(ixName(c))}),'bad');}
if(dk.m[c]&&(d+hstr(c)%90)%365===0){const f=1.08+Math.random()*0.07;dk.m[c]=+(dk.m[c]*f).toFixed(3);toast(tr('de_kicks.de_kicks_has_harmonised_its_prices',{ix:esc(ixName(c)),p:Math.round((f-1)*100)}),'bad');}
const add=dk.add[c]=dk.add[c]||[];
if(add.length<3&&Math.random()<1/150){const a=DK_ADDONS.filter(x=>!add.some(y=>y.n===x[0]));if(a.length){const [n,blurb]=pick(a),mo=Math.round((300+Math.random()*1200)/50)*50;add.push({n,blurb,mo,day:d});
toast(tr("<b>Good news! You've been enrolled in {addon}.</b><br>{blurb} {price}/mo, added to your {ix} invoice. Opt out any time in the IX panel.",{addon:esc(n),blurb:esc(blurb),price:fmt$(mo),ix:esc(ixName(c))}),'bad');}}}
toast(tr('de_kicks.good_news_you_ve_been_enrolled',{addon:esc(n),blurb:esc(blurb),price:fmt$(mo),ix:esc(ixName(c))}),'bad');}}}
}
function elephant(){S.phpDone=true;S.ev.php=S.day+4;
toast(tr(`<b>🐘 BREAKING: CVE-2026-31337 just took down half the internet.</b><br>A bug in PHP turned every WordPress-ish site on Earth into a crypto miner. Eyeball traffic is down 30% for a few days while the world patches. Your hosting customers are doing it at 3 a.m.`),'bad');sfx('alert');renderMega();}
toast(tr('de_kicks.breaking_cve_2026_31337_just_took'),'bad');sfx('alert');renderMega();}

View file

@ -1,11 +1,11 @@
/* Sold out: now and then a carrier has no spare capacity of a size on a route. Each route, size and 90-day window
gets a stable verdict from a hash, so asking again does not reroll it, and bigger waves sell out more often. */
const SOLD_WIN=90,SOLD_WHY=[N_('A hyperscaler bought every wave of that size on this route last week.'),N_('The carrier is out of spectrum here until its next line-system upgrade.'),N_('The transponders for this route are on a container ship. The ship is somewhere near Singapore.'),N_('The capacity is “available in the system”. Nobody can find it in the system.'),N_('Their capacity planner is on holiday, and he took the spreadsheet with him.'),N_('The upgrade is planned for Q3. Which year, the email does not say.')];
const SOLD_WIN=90,SOLD_WHY=[N_('sold_out.a_hyperscaler_bought_every_wave_of'),N_('sold_out.the_carrier_is_out_of_spectrum'),N_('sold_out.the_transponders_for_this_route_are'),N_('sold_out.the_capacity_is_available_in_the'),N_('sold_out.their_capacity_planner_is_on_holiday'),N_('sold_out.the_upgrade_is_planned_for_q3')];
const soldP=tier=>Math.min(0.1,0.02+0.012*tier);
// Never in the first 90 days: a new network has enough on its plate. Never in the tutorial or a scenario's first quarter either.
function soldOut(a,b,tier,via){if(!S||S.day<SOLD_WIN||S.tut)return null;const k=(a<b?a+b:b+a)+'|'+(via||'')+'|'+tier,off=hstr(k)%SOLD_WIN,ep=Math.floor((S.day+off)/SOLD_WIN),h=hstr(S.asn+'|'+k+'|'+ep);
if(h%1000>=soldP(tier)*1000)return null;return {why:SOLD_WHY[(h>>>10)%SOLD_WHY.length],until:(ep+1)*SOLD_WIN-off};}
function snubWhy(sn){const d=Math.max(1,sn.until-S.day);return sn.why+' '+trn('They will reconsider in {n} day.','They will reconsider in {n} days.',d);}
function snubWhy(sn){const d=Math.max(1,sn.until-S.day);return sn.why+' '+trn('sold_out.they_will_reconsider_in_n_day',d);}
// Paid-peering giants drop the fee for networks too big to ignore (freeLv: the customer level that does it).
const paidFree=n=>!!(n&&n.freeLv&&lvl()>=n.freeLv);
function peerOk(id,via,city){
@ -14,10 +14,10 @@ function peerOk(id,via,city){
if(msfNope(id,city))return {ok:false,why:tr(MSF_NOPE[hstr(ixCity(city)+S.day)%MSF_NOPE.length])};
if(via==='ix'&&city&&isRemote(city)&&noRemote(id))return {ok:false,remote:true,why:REMOTE_WHY[hstr(id)%REMOTE_WHY.length]};
if(n.pol==='open')return {ok:true};
if(n.pol==='selective'){const need=Math.round((via==='pni'?n.minPni:n.minIx)*confBoost(id)*repMul());return dem>=need?{ok:true}:{ok:false,why:tr('Wants ≥ {need} Gbps of traffic from you (you send {dem})',{need,dem:dem.toFixed(1)})};}
if(n.pol==='paid'&&paidFree(n))return via==='pni'?{ok:true,free:true}:{ok:false,why:tr('Peers with you for free now, but only over a PNI')};
if(n.pol==='paid')return via==='pni'?{ok:true,fee:n.paidFee}:{ok:false,why:n.perG?tr('Sender pays: a paid PNI only, {fee}/mo plus {g} per Gbps you send',{fee:fmt$(n.paidFee),g:fmt$(n.perG)}):tr('Paid peering only, over a PNI')};
if(n.type!=='t1'){if(via!=='pni')return {ok:false,why:tr('Only peers over PNIs, and only with networks it considers important')};const need=Math.round(60*confBoost(id));return dem>=need||isTier2()?{ok:true}:{ok:false,why:tr('Wants you to be a Tier 2, or send ≥ {need} Gbps to it (you send {dem})',{need,dem:dem.toFixed(1)})};}
if(via!=='pni')return {ok:false,why:tr('Tier 1s never peer at IXs')};
const c=t1Club();return c.ok?{ok:true}:{ok:false,why:tr('Not big enough yet: {list}',{list:c.missing.join(', ')})};
if(n.pol==='selective'){const need=Math.round((via==='pni'?n.minPni:n.minIx)*confBoost(id)*repMul());return dem>=need?{ok:true}:{ok:false,why:tr('sold_out.wants_need_gbps_of_traffic_from',{need,dem:dem.toFixed(1)})};}
if(n.pol==='paid'&&paidFree(n))return via==='pni'?{ok:true,free:true}:{ok:false,why:tr('sold_out.peers_with_you_for_free_now')};
if(n.pol==='paid')return via==='pni'?{ok:true,fee:n.paidFee}:{ok:false,why:n.perG?tr('sold_out.sender_pays_a_paid_pni_only',{fee:fmt$(n.paidFee),g:fmt$(n.perG)}):tr('sold_out.paid_peering_only_over_a_pni')};
if(n.type!=='t1'){if(via!=='pni')return {ok:false,why:tr('sold_out.only_peers_over_pnis_and_only')};const need=Math.round(60*confBoost(id));return dem>=need||isTier2()?{ok:true}:{ok:false,why:tr('sold_out.wants_you_to_be_a_tier',{need,dem:dem.toFixed(1)})};}
if(via!=='pni')return {ok:false,why:tr('sold_out.tier_1s_never_peer_at_ixs')};
const c=t1Club();return c.ok?{ok:true}:{ok:false,why:tr('sold_out.not_big_enough_yet_list',{list:c.missing.join(', ')})};
}

View file

@ -1,12 +1,12 @@
// Everything that can fill up at a POP: transit ports, IX ports, PNIs, caches and the routers themselves.
const HOT=0.9,HOTL={t:'T',ix:'IX',p:'P',c:'C',r:'R'},HOTC={t:'#7B61FF',ix:'#FFD23F',p:'#2C7A7B',c:'#C8102E',r:'#FF4F9A'};
function hotPorts(){const out=[];if(!R||!S)return out;
for(const t of S.transit){if(t.down>S.day)continue;const cap=lagCap(PORT[t.tier].g,t.n),u=(R.useT[t.id]||0)/cap;if(u>=HOT)out.push({k:'t',city:t.city,lab:tr('{net} transit · {lag}',{net:NET[t.net].name,lag:lagName(t.tier,t.n)}),u,tip:tr('Add a LAG member, upgrade the port or buy a second upstream.')});}
for(const c in S.ixp){const cap=ixCap(c);if(!cap)continue;const u=(R.useIx[c]||0)/cap;if(u>=HOT)out.push({k:'ix',city:ixCity(c),lab:tr('{port} port',{port:ixName(c)}),u,tip:tr('Upgrade the IX port or add a LAG member.')});}
for(const p of S.pni){if(!pniOn(p))continue;const cap=lagCap(pniG(p),p.n),u=(R.usePni[p.id]||0)/cap;if(u>=HOT)out.push({k:'p',city:p.city,lab:tr('PNI with {net}',{net:NET[p.net].name}),u,tip:tr('Add a LAG member or upgrade the PNI.')});}
for(const t of S.transit){if(t.down>S.day)continue;const cap=lagCap(PORT[t.tier].g,t.n),u=(R.useT[t.id]||0)/cap;if(u>=HOT)out.push({k:'t',city:t.city,lab:tr('hot_ports_and_rank.net_transit_lag',{net:NET[t.net].name,lag:lagName(t.tier,t.n)}),u,tip:tr('hot_ports_and_rank.add_a_lag_member_upgrade_the')});}
for(const c in S.ixp){const cap=ixCap(c);if(!cap)continue;const u=(R.useIx[c]||0)/cap;if(u>=HOT)out.push({k:'ix',city:ixCity(c),lab:tr('common.port_port',{port:ixName(c)}),u,tip:tr('hot_ports_and_rank.upgrade_the_ix_port_or_add')});}
for(const p of S.pni){if(!pniOn(p))continue;const cap=lagCap(pniG(p),p.n),u=(R.usePni[p.id]||0)/cap;if(u>=HOT)out.push({k:'p',city:p.city,lab:tr('common.pni_with_net',{net:NET[p.net].name}),u,tip:tr('hot_ports_and_rank.add_a_lag_member_or_upgrade')});}
const cc={};for(const x of S.caches){const k=x.city+'|'+x.net;(cc[k]=cc[k]||{city:x.city,net:x.net,used:0,cap:0});cc[k].used+=R.useCache[x.id]||0;cc[k].cap+=CACHE_CAP;}
for(const k in cc){const x=cc[k],u=x.used/x.cap;if(u>=HOT)out.push({k:'c',city:x.city,lab:x.cap>CACHE_CAP?tr('{name} caches',{name:NET[x.net].cache.name}):tr('{name} cache',{name:NET[x.net].cache.name}),u,tip:tr('Ask for another box. The overflow goes out over peering or transit.')});}
for(const c in S.pops){const cap=R.nodeCap[c];if(!cap)continue;const u=(R.nodeLoad[c]||0)/cap;if(u>=HOT)out.push({k:'r',city:c,lab:tr('Routers'),u,tip:tr('Upgrade the router or add a second one in the Infra tab.')});}
for(const k in cc){const x=cc[k],u=x.used/x.cap;if(u>=HOT)out.push({k:'c',city:x.city,lab:x.cap>CACHE_CAP?tr('hot_ports_and_rank.name_caches',{name:NET[x.net].cache.name}):tr('common.name_cache',{name:NET[x.net].cache.name}),u,tip:tr('hot_ports_and_rank.ask_for_another_box_the_overflow')});}
for(const c in S.pops){const cap=R.nodeCap[c];if(!cap)continue;const u=(R.nodeLoad[c]||0)/cap;if(u>=HOT)out.push({k:'r',city:c,lab:tr('common.routers'),u,tip:tr('hot_ports_and_rank.upgrade_the_router_or_add_a')});}
return out.sort((a,b)=>b.u-a.u);}
function hotByCity(){const m={};for(const h of hotPorts())(m[h.city]=m[h.city]||{})[h.k]=Math.max((m[h.city]||{})[h.k]||0,h.u);return m;}
function isTier2(){return Object.keys(S.pops).length>=5&&Object.keys(S.ixp).length>=3&&R.sessions>=15;}
@ -15,5 +15,5 @@ const t1Need=()=>NETS.filter(n=>n.type==='t1'&&(n.id!=='skl'||(S&&S.t1v>=2)));
function isTier1(){return t1Need().every(n=>S.pni.some(p=>p.net===n.id&&pniOn(p)))&&S.transit.length===0&&R.reach>0.999;}
// What you are now, not what you once were (#46): buying transit again or losing reach drops the label.
function tierLabel(){return S.won&&isTier1()?'Tier 1':isTier2()?'Tier 2':'Tier 3';}
function t1Why(){if(S.transit.length)return tr('you buy transit again');const miss=t1Need().filter(n=>!S.pni.some(p=>p.net===n.id&&pniOn(p)));if(miss.length)return tr('no PNI with {list}',{list:miss.map(n=>n.name).join(', ')});{const lost=NETS.filter(n=>!R.reachable[n.id]).sort((a,b)=>NSH[b.id]-NSH[a.id]);if(lost.length)return tr('you cannot reach {list}',{list:lost.slice(0,3).map(n=>n.name).join(', ')+(lost.length>3?' '+tr('and {n} more',{n:lost.length-3}):'')});}return tr('your reach is {p}, not 100%',{p:reachPct(R.reach)});}
function t1Why(){if(S.transit.length)return tr('hot_ports_and_rank.you_buy_transit_again');const miss=t1Need().filter(n=>!S.pni.some(p=>p.net===n.id&&pniOn(p)));if(miss.length)return tr('hot_ports_and_rank.no_pni_with_list',{list:miss.map(n=>n.name).join(', ')});{const lost=NETS.filter(n=>!R.reachable[n.id]).sort((a,b)=>NSH[b.id]-NSH[a.id]);if(lost.length)return tr('hot_ports_and_rank.you_cannot_reach_list',{list:lost.slice(0,3).map(n=>n.name).join(', ')+(lost.length>3?' '+tr('hot_ports_and_rank.and_n_more',{n:lost.length-3}):'')});}return tr('hot_ports_and_rank.your_reach_is_p_not_100',{p:reachPct(R.reach)});}