Fabric ports at 10G, 100G or 400G, in LAGs; fabric customers only when they fit
A fabric (NNI) port comes in 10G, 100G or 400G, as fast as the router takes and no faster than 400G, and bundles into a LAG of up to eight members like transit, IX and PNIs. Each member takes a router port (10G on a breakout, a quarter of one) and pays the monthly price; upgrading moves and pays for every member. 10G and 100G keep their prices, 400G is $3,000/mo. A model change that would strand a 400G fabric port is refused, and saves drop fabric ports that make no sense. The NNI requirement counted what the port already carried but not the offer's own bandwidth, so an offer passed as long as the port was not already over and auto-accept took customers that did not fit. It now counts the offer too. Closes #140, closes #307.
This commit is contained in:
parent
4ec3fb4a1a
commit
85701dbb82
22 changed files with 184 additions and 27 deletions
|
|
@ -134,8 +134,11 @@ const API_CMD={
|
|||
doc:'Hold a link in reserve: its capacity fills last.'},
|
||||
/* ---------- fabrics and VXCs ---------- */
|
||||
buyNni:{args:[['city','cityId'],['prov','fabId'],['tier','nniTier']],
|
||||
quote:a=>({setup:NNI[a.tier]?NNI[a.tier].mo:undefined,monthly:NNI[a.tier]?NNI[a.tier].mo:undefined}),
|
||||
doc:'Take a port on an interconnection fabric. Monthly. A higher tier upgrades unless the circuits on it already exceed the smaller port.'},
|
||||
quote:a=>{const ex=nniPort(a.city,a.prov),n=ex?(ex.n||1):1,m=NNI[a.tier]?NNI[a.tier].mo*n:undefined;return {setup:m,monthly:m};},
|
||||
doc:'Take a port on an interconnection fabric, at any port speed the router takes. Monthly, the first month up front. A higher tier upgrades every member of the port.'},
|
||||
lagNni:{args:[['city','cityId'],['prov','fabId'],['d','step']],watch:['nni'],
|
||||
quote:a=>{const pt=nniPort(a.city,a.prov),m=pt&&a.d>0&&NNI[pt.tier]?NNI[pt.tier].mo:0;return {setup:m,monthly:m};},
|
||||
doc:'Add (d:1) or remove (d:-1) a member of the fabric port\'s LAG: same speed, one more router port, up to 8. Removing is rejected while the circuits would not fit.'},
|
||||
rmNni:{args:[['city','cityId'],['prov','fabId']],
|
||||
doc:'Give the fabric port back. Rejected while circuits still use it.'},
|
||||
buyVxc:{args:[['a','cityId'],['b','cityId'],['prov','fabId'],['t','vxcTier']],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Ports are finite. Every transit, IX, PNI and cache port, every wave and every fibre channel
|
||||
/* Ports are finite. Every transit, IX, PNI, fabric and cache port, every wave and every fibre channel
|
||||
takes a router port. 10G ports ride a breakout cable, four to a port. */
|
||||
const PORT_SLOT=i=>i===0?0.25:1;
|
||||
// Cache boxes sit behind an aggregation switch: one router port carries as many 100G boxes as its speed holds
|
||||
|
|
@ -21,7 +21,8 @@ function portsUsed(c,g){let u=0;
|
|||
for(const x of S.pni)if(x.city===c)u+=PORT_SLOT(x.tier)*(x.n||1);
|
||||
for(const x of ixIdsIn(c))if(S.ixp[x]!==undefined&&!S.myIx[x])u+=PORT_SLOT(S.ixp[x])*((S.ixn||{})[x]||1);
|
||||
if(S.myIx[c])u+=1;
|
||||
u+=cachePorts(c,[],g)+(S.nni||[]).filter(x=>x.city===c).length;
|
||||
for(const x of S.nni||[])if(x.city===c)u+=PORT_SLOT(x.tier)*(x.n||1);
|
||||
u+=cachePorts(c,[],g);
|
||||
return u;}
|
||||
function portsMax(c,g,rt){const p=S.pops[c];if(!p)return 0;return RG[g===undefined?(p.rgen||0):g].ports*(rt||p.routers||1);}
|
||||
function portGate(c,add){if(!S.pops[c]||add<=0)return true;const u=portsUsed(c),m=portsMax(c);if(u+add<=m+1e-9)return true;
|
||||
|
|
@ -31,6 +32,6 @@ const popIdle=c=>{const p=S.pops[c];return !!p&&!p.bb&&portsUsed(c)===0&&!S.biz.
|
|||
const fmtPorts=u=>Number.isInteger(u)?String(u):u.toFixed(2).replace(/0+$/,'');
|
||||
function modelFits(c,g){const G=RG[g],p=S.pops[c];if(!p)return '';
|
||||
if(S.links.some(l=>(l.a===c||l.b===c)&&l.kind==='wave'&&l.tier>G.maxLT))return tr('ports.a_wave_here_is_faster_than',{pn:G.pn});
|
||||
if([...S.transit,...S.pni].some(t=>t.city===c&&!t.pz&&t.tier>G.maxP)||ixIdsIn(c).some(x=>S.ixp[x]!==undefined&&!S.myIx[x]&&S.ixp[x]>G.maxP))return tr('ports.a_port_here_is_bigger_than',{pn:G.pn});
|
||||
if([...S.transit,...S.pni,...(S.nni||[])].some(t=>t.city===c&&!t.pz&&t.tier>G.maxP)||ixIdsIn(c).some(x=>S.ixp[x]!==undefined&&!S.myIx[x]&&S.ixp[x]>G.maxP))return tr('ports.a_port_here_is_bigger_than',{pn:G.pn});
|
||||
if(S.links.some(l=>(l.a===c||l.b===c)&&l.kind==='df'&&(l.ch||[]).some(o=>OPT[o]&&OPT[o].rg>G.cls)))return tr('ports.a_fibre_here_uses_optics_this');
|
||||
if(portsUsed(c,g)>portsMax(c,g))return tr('ports.you_use_u_ports_here_and',{u:fmtPorts(portsUsed(c,g)),r:p.routers||1,model:G.n,max:portsMax(c,g)});return '';}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,11 @@ const FABS=[
|
|||
{id:'ccn',name:'Consolation Connect',col:'#8E44AD',cities:['icn','lon','fra','ams','mrs','bom','sin','hkg','tok','syd','lag','jnb'],blurb:tr('dark_fiber.strong_in_asia_and_africa_every')},
|
||||
];
|
||||
const FAB=Object.fromEntries(FABS.map(f=>[f.id,f]));
|
||||
const NNI=[{n:'10G',g:10,mo:500},{n:'100G',g:100,mo:1200}];
|
||||
/* A fabric port (NNI) comes in 10G, 100G or 400G, as fast as the router takes (portOk), and bundles into a LAG like
|
||||
any other port (#140): more than 400G is more members. Fabrics sell nothing faster. Monthly, the first month up
|
||||
front; cheaper per Gbps the faster it is. 10G and 100G keep the prices they always had. */
|
||||
const NNI_MO=[500,1200,3000];
|
||||
const NNI=NNI_MO.map((mo,i)=>({n:PORT[i].n,g:PORT[i].g,mo}));
|
||||
const VXC=[{n:'10G',g:10,m:1},{n:'50G',g:50,m:2.4},{n:'100G',g:100,m:3.6}];
|
||||
const vxcMo=(km,sub,t)=>Math.round((150+km*0.12)*VXC[t].m*(sub?2:1));
|
||||
const MET={prefer:{l:tr('common.prefer'),f:0.5},normal:{l:tr('common.normal'),f:1},avoid:{l:tr('common.avoid'),f:4},backup:{l:tr('common.backup_only'),f:60}};
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ function computeMoney(R2){
|
|||
C.pops=Object.entries(S.pops).reduce((a,[c,p])=>a+popMo(c)+((p.routers||1)-1)*ROUTER_MO+cageMo(p.routers)+(p.routers||1)*RG[p.rgen||0].mo+(p.gen?GEN_MO:0),0);
|
||||
C.optical=S.links.filter(l=>l.kind==='df').reduce((a,l)=>a+(l.ready>S.day?0:ampCount(l.km)*AMP_MO*(l.own&&isRdm(l.sys)&&!l.sub?Math.max(1,l.pairs|0):1)+(l.regen|0)*REGEN_MO)+(l.spares?Math.round(150+(l.ch||[]).length*80):0),0);
|
||||
C.links=S.links.reduce((a,l)=>a+(l.mo||0),0);
|
||||
C.nni=(S.nni||[]).reduce((a,x)=>a+NNI[x.tier].mo,0);
|
||||
C.nni=(S.nni||[]).reduce((a,x)=>a+nniMo(x),0);
|
||||
const htd=histToday();C.transit=S.transit.reduce((a,t)=>{const q=p95(t,R2.useT[t.id]||0,htd);R2.p95[t.id]=q;return a+transitMo(t,q);},0);
|
||||
C.ix=Object.keys(S.ixp).reduce((a,c)=>a+ixMo(c),0);
|
||||
C.pni=S.pni.reduce((a,p)=>a+pniMo(p,R2.usePni[p.id]||0),0);
|
||||
|
|
|
|||
|
|
@ -12,4 +12,7 @@ const krFee=(t,q)=>CITY[t.city].kr&&scnRule('sender')?Math.round(q*KR_FEE):0;
|
|||
function pniMo(p,use){if(!pniOn(p))return 0;return (p.g1?Math.round(PORT[0].pni/2):PORT[p.tier].pni)*(p.n||1)+(NET[p.net].pol==='paid'&&!paidFree(NET[p.net])?NET[p.net].paidFee:0)+(NET[p.net].perG?Math.round(NET[p.net].perG*use):0);}
|
||||
function ixMo(c){return S.myIx[c]?Math.round(myFab(c).mo*((S.ixSite||{})[c]==='ab'?1.5:1)):ixPortMo(c,S.ixp[c])*((S.ixn||{})[c]||1)+dkAddonMo(c);}
|
||||
function nniPort(c,prov){return (S.nni||[]).find(x=>x.city===c&&x.prov===prov);}
|
||||
// What a fabric port can book: its speed times its members, a LAG at 95% like every bundle (lagCap).
|
||||
function nniCap(pt){return pt&&NNI[pt.tier]?lagCap(NNI[pt.tier].g,pt.n):0;}
|
||||
const nniMo=x=>NNI[x.tier]?NNI[x.tier].mo*(x.n||1):0;
|
||||
function repayCost(l,B){return B.equity?Math.round(l.amount*3):Math.round(Math.max(l.bal,B.crypto&&l.got?l.got:0)*1.02);}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ function migrate(s){sanitize(s);
|
|||
for(const b of [...s.biz,...s.offers])if(Array.isArray(b.reqs))b.reqs=b.reqs.filter(k=>!REQS[k]||!REQS[k].can||(isCity(b.city)&&(!b.city2||isCity(b.city2))&&REQS[k].can(b,s)));if(s.ltv!==2){for(const l of s.links)if(l.kind==='wave'&&l.tier>=3)l.tier=Math.min(LT.length-1,l.tier+1);s.ltv=2;}if(s.dk){s.dk.m=s.dk.m||{};s.dk.add=s.dk.add||{};s.dk.ret=s.dk.ret||{};s.dk.retUsed=s.dk.retUsed||{};}s.hist=s.hist||[];s.loans=s.loans||[];s.loanOffers=s.loanOffers||[];s.loanStrikes=s.loanStrikes||0;for(const l of s.links||[])if(!l.kind)l.kind='wave';
|
||||
for(const c in s.pops){const p=s.pops[c];if(p.rgen===undefined){let g=0;const need=(i,key)=>{const k=RG.findIndex(r=>r[key]>=i);if(k>g)g=k;};
|
||||
for(const l of s.links||[])if((l.a===c||l.b===c)&&l.kind==='wave')need(l.tier,'maxLT');
|
||||
for(const t of s.transit||[])if(t.city===c)need(t.tier,'maxP');for(const x of s.pni||[])if(x.city===c)need(x.tier,'maxP');if(s.ixp&&s.ixp[c]!==undefined)need(s.ixp[c],'maxP');p.rgen=g;}}for(const b of s.biz||[])if(!b.reqs)b.reqs=BIZ_T[b.type]&&BIZ_T[b.type].div?['diverse']:[];for(const o of s.offers||[])if(!o.reqs)o.reqs=[];if(!s.lvl)s.lvl=1;s.nni=s.nni||[];s.cnLic=s.cnLic||{state:'none'};s.ev=s.ev||{};for(const l of s.links){if(!l.kind)l.kind='wave';if(l.mo===undefined)l.mo=Math.round(waveMo(l.km,l.sub,l.tier)*(l.mult||1));}for(const c in s.pops){if(!s.pops[c].routers)s.pops[c].routers=1;}
|
||||
for(const t of s.transit||[])if(t.city===c)need(t.tier,'maxP');for(const x of s.pni||[])if(x.city===c)need(x.tier,'maxP');if(s.ixp&&s.ixp[c]!==undefined)need(s.ixp[c],'maxP');p.rgen=g;}}for(const b of s.biz||[])if(!b.reqs)b.reqs=BIZ_T[b.type]&&BIZ_T[b.type].div?['diverse']:[];for(const o of s.offers||[])if(!o.reqs)o.reqs=[];if(!s.lvl)s.lvl=1;s.nni=(Array.isArray(s.nni)?s.nni:[]).filter(x=>x&&own(FAB,x.prov)&&isCity(x.city)&&Number.isInteger(x.tier)&&!!NNI[x.tier]);for(const x of s.nni){const n=Math.floor(+x.n||1);if(n>1)x.n=Math.min(LAG_MAX,n);else delete x.n;}s.cnLic=s.cnLic||{state:'none'};s.ev=s.ev||{};for(const l of s.links){if(!l.kind)l.kind='wave';if(l.mo===undefined)l.mo=Math.round(waveMo(l.km,l.sub,l.tier)*(l.mult||1));}for(const c in s.pops){if(!s.pops[c].routers)s.pops[c].routers=1;}
|
||||
{const all=NETS.map(n=>n.id),seen=Array.isArray(s.seen)?s.seen.filter(x=>typeof x==='string'):null,fresh=seen?all.filter(id=>!seen.includes(id)):all;
|
||||
if(fresh.length&&(s.day||0)>0){const g=s.grace&&s.grace.until>s.day?s.grace:{nets:[]};s.grace={until:s.day+GRACE_DAYS,nets:[...new Set(g.nets.concat(fresh))],fresh:seen?fresh.length:0};}
|
||||
s.seen=all;}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const GRACE_DAYS=60;
|
||||
const REQS={
|
||||
lat:{only:true,l2:true,bonus:0,l:o=>tr('requirements.one_way_latency_within_max_ms',{max:o.latMax,best:(()=>{const v=R.l2lat[o.id]!==undefined?R.l2lat[o.id]:bestLat(o.city,o.city2);return isFinite(v)?v.toFixed(1)+' ms':tr('common.no_path')})()}),ok:b=>(R.l2lat[b.id]!==undefined?R.l2lat[b.id]:bestLat(b.city,b.city2))<=b.latMax},
|
||||
nni:{only:true,bonus:0,l:o=>tr('requirements.comes_in_over_fab_needs_your',{fab:FAB[o.prov]?FAB[o.prov].name:'?',city:CITY[o.city].name,bw:fmtG(o.bw)}),ok:b=>{const pt=nniPort(b.city,b.prov);return !!pt&&nniUsed(b.city,b.prov)<=NNI[pt.tier].g+1e-9;}},
|
||||
nni:{only:true,bonus:0,l:o=>tr('requirements.comes_in_over_fab_needs_your',{fab:FAB[o.prov]?FAB[o.prov].name:'?',city:CITY[o.city].name,bw:fmtG(o.bw)}),ok:b=>{const pt=nniPort(b.city,b.prov);return !!pt&&nniUsed(b.city,b.prov)+(S.biz.includes(b)?0:b.bw)<=nniCap(pt)+1e-9;}},
|
||||
diverse:{l:tr('requirements.two_paths_that_share_no_trench'),bonus:.25,l2:true,can:(b,s=S)=>diversityPossible(b.city,b.city2,s),ok:b=>R.div[b.id]!==undefined?!!R.div[b.id]:diversePaths(b.city,b.city2)},
|
||||
sharks:{l:tr('requirements.afraid_of_sharks_needs_a_path'),bonus:.2,l2:true,ok:b=>terrestrialPath(b.city,b.city2),can:b=>!!b.city2&&!isSub(b.city,b.city2)},
|
||||
nocog:{l:tr('requirements.refuses_cogentle_transit_anywhere_on'),bonus:.15,ok:()=>!S.transit.some(t=>t.net==='cog')},
|
||||
|
|
|
|||
|
|
@ -23,14 +23,22 @@ Object.assign(ACT,{
|
|||
const id=uid();const l={id,a,b,kind:'wave',border,premium:border&&!!UI.cnPrem&&(a==='hkg'||b==='hkg'),tier,km:wr.km,sub:wr.sub,cable:wr.cab,mo:base,mult:wr.wm,trench:wr.cab?'cab:'+wr.cab:(jn?jn.k:id),cut:0,day:S.day};S.links.push(l);closeModal();
|
||||
if(sib.length){UI.sel={type:'link',id};}else{UI.sel={type:'city',id:b};UI.tab='cust';}
|
||||
floater((CITY[a].x+CITY[a].x+wrapDx(CITY[a].x,CITY[b].x))/2,(CITY[a].y+CITY[b].y)/2-20,tr('links.wave_lit',{wave:LT[tier].n}),'#FF4F9A');after();},
|
||||
buyNni:({city,prov,tier})=>{tier=+tier;if(!NNI[tier]||!isCity(city)||!own(FAB,prov)||!FAB[prov].cities.includes(city)||!S.pops[city])return;const ex=nniPort(city,prov);if(ex&&tier<=ex.tier)return;if(!ex&&!portGate(city,1))return;if(ex&&nniUsed(city,prov)>NNI[tier].g){toast(tr('links.too_many_circuits_for_a_smaller'),'bad');return;}if(!spend(NNI[tier].mo))return;if(ex)ex.tier=tier;else S.nni.push({id:uid(),city,prov,tier});toast(tr('links.fab_port_is_up_in_city',{fab:esc(FAB[prov].name),city:CITY[city].name}),'good');after();},
|
||||
// A new fabric port, or every member of one upgraded to a faster speed (#140): as fast as the router takes.
|
||||
buyNni:({city,prov,tier})=>{tier=+tier;if(!NNI[tier]||!isCity(city)||!own(FAB,prov)||!FAB[prov].cities.includes(city)||!S.pops[city])return;const ex=nniPort(city,prov),n=ex?(ex.n||1):1;if(ex&&tier<=ex.tier)return;
|
||||
if(!portOk(city,tier)){toast(tr('actions.your_router_can_t_take_a',{port:NNI[tier].n}),'bad');sfx('err');return;}
|
||||
if(!portGate(city,(PORT_SLOT(tier)-(ex?PORT_SLOT(ex.tier):0))*n)||!spend(NNI[tier].mo*n))return;if(ex)ex.tier=tier;else S.nni.push({id:uid(),city,prov,tier});toast(tr('links.fab_port_is_up_in_city',{fab:esc(FAB[prov].name),city:CITY[city].name}),'good');after();},
|
||||
// A fabric port bundles into a LAG like transit and PNIs (#140): a member at the same speed, on a router port of its own.
|
||||
lagNni:({city,prov,d})=>{d=+d;if(d!==1&&d!==-1)return;const pt=nniPort(city,prov);if(!pt||!NNI[pt.tier])return;const n=(pt.n||1)+d;if(n<1||n>LAG_MAX)return;
|
||||
if(d>0){if(!portOk(city,pt.tier)){toast(tr('actions.your_router_can_t_take_a',{port:NNI[pt.tier].n}),'bad');sfx('err');return;}if(!portGate(city,PORT_SLOT(pt.tier))||!spend(NNI[pt.tier].mo))return;}
|
||||
else if(nniUsed(city,prov)>lagCap(NNI[pt.tier].g,n)+1e-9){toast(tr('links.too_many_circuits_for_a_smaller'),'bad');sfx('err');return;}
|
||||
if(n>1)pt.n=n;else delete pt.n;sfx('build');after();},
|
||||
rmNni:({city,prov})=>{if(nniUsed(city,prov)>0){toast(tr('links.cancel_the_circuits_on_this_port'),'bad');sfx('err');return;}S.nni=S.nni.filter(x=>!(x.city===city&&x.prov===prov));after();},
|
||||
openVxc:(a)=>openVxcModal(a),
|
||||
buyVxc:({a,b,prov,t})=>{t=+t;if(!CITY[a]||!CITY[b]||noTalk(a,b))return;const g=VXC[t].g,pa=nniPort(a,prov);if(!pa||nniUsed(a,prov)+g>NNI[pa.tier].g){toast(tr('links.not_enough_room_on_your_fabric'),'bad');sfx('err');return;}
|
||||
if(S.pops[b]){const pb=nniPort(b,prov);if(!pb||nniUsed(b,prov)+g>NNI[pb.tier].g){toast(tr('links.not_enough_room_on_your_fab',{fab:esc(FAB[prov].name),city:CITY[b].name}),'bad');sfx('err');return;}}
|
||||
buyVxc:({a,b,prov,t})=>{t=+t;if(!CITY[a]||!CITY[b]||noTalk(a,b))return;const g=VXC[t].g,pa=nniPort(a,prov);if(!pa||nniUsed(a,prov)+g>nniCap(pa)+1e-9){toast(tr('links.not_enough_room_on_your_fabric'),'bad');sfx('err');return;}
|
||||
if(S.pops[b]){const pb=nniPort(b,prov);if(!pb||nniUsed(b,prov)+g>nniCap(pb)+1e-9){toast(tr('links.not_enough_room_on_your_fab',{fab:esc(FAB[prov].name),city:CITY[b].name}),'bad');sfx('err');return;}}
|
||||
const km=kmBetween(a,b),sub=isSub(a,b),mo=vxcMo(km,sub,t);if(!spend(mo))return;S.links.push({id:uid(),a,b,kind:'vxc',prov,vt:t,km,sub,mo,cut:0,day:S.day});closeModal();
|
||||
toast(tr('links.circuit_up_in_59_seconds_vxc',{vxc:VXC[t].n,fab:esc(FAB[prov].name),a:CITY[a].name,b:CITY[b].name})+(S.pops[b]?'':' '+tr('links.now_grab_an_ix_port_there')),'good');if(!S.pops[b])selectCity(b);after();},
|
||||
upVxc:({id,t})=>{t=+t;const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='vxc'||!VXC[t]||t<=l.vt)return;const extra=VXC[t].g-VXC[l.vt].g;for(const c of [l.a,l.b]){const pt=nniPort(c,l.prov);if(pt&&nniUsed(c,l.prov)+extra>NNI[pt.tier].g){toast(tr('links.fabric_port_in_city_is_full',{city:CITY[c].name}),'bad');sfx('err');return;}}const mo=vxcMo(l.km,l.sub,t);if(!spend(mo))return;l.vt=t;l.mo=mo;after();},
|
||||
upVxc:({id,t})=>{t=+t;const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='vxc'||!VXC[t]||t<=l.vt)return;const extra=VXC[t].g-VXC[l.vt].g;for(const c of [l.a,l.b]){const pt=nniPort(c,l.prov);if(pt&&nniUsed(c,l.prov)+extra>nniCap(pt)+1e-9){toast(tr('links.fabric_port_in_city_is_full',{city:CITY[c].name}),'bad');sfx('err');return;}}const mo=vxcMo(l.km,l.sub,t);if(!spend(mo))return;l.vt=t;l.mo=mo;after();},
|
||||
cancelVxc:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.links=S.links.filter(l=>l.id!==id);prunePairMet();const rem=remoteCities();for(const c in S.ixp){if(!S.pops[ixCity(c)]&&!rem.includes(ixCity(c))){delete S.ixp[c];delete S.rs[c];for(const k in S.peers)if(k.endsWith('@'+c))delete S.peers[k];}}UI.sel=null;UI.confirm=null;after();},
|
||||
setPref:({kind,id,v})=>{if(!own(PREF,v))return;if(kind!=='t'&&kind!=='p'&&!(isIx(id)&&S.ixp[id]!==undefined))return;if(kind==='t'){const t=S.transit.find(x=>x.id===id);if(t)t.pref=v;}else if(kind==='p'){const x=S.pni.find(y=>y.id===id);if(x)x.pref=v;}else{S.ixPref=S.ixPref||{};S.ixPref[id]=v;}sfx('click');after();},
|
||||
setMetric:({id,v})=>{if(v!=='custom'&&!own(MET,v))return;const l=S.links.find(x=>x.id===id);if(!l)return;const m=S.pairMet||(S.pairMet={}),k=edgeKey(l);
|
||||
|
|
|
|||
|
|
@ -97,8 +97,10 @@ function cityPanel(c){
|
|||
if(fabs.length){h+=`<section><h3>${tr('city_panel.interconnection_fabrics_nni')}</h3><p class="lead">${tr('city_panel.buy_a_port_on_a_fabric')}</p>`;
|
||||
for(const f of fabs){const pt=nniPort(c,f.id),used=nniUsed(c,f.id);
|
||||
h+=`<div class="row"><span class="logo" style="--c:${f.col}">${initials(f)}</span><div class="grow"><div class="nm">${esc(f.name)}</div><div class="meta">${esc(f.blurb)}</div>`;
|
||||
if(pt){const cap=NNI[pt.tier].g;h+=`<div class="kv"><span>${tr('city_panel.port_port_price_mo',{port:NNI[pt.tier].n,price:fmt$(NNI[pt.tier].mo)})}</span><b>${tr('city_panel.g_of_circuits',{g:fmtG(used)})}</b></div><div class="bar ${barCls(used/cap)}"><i style="width:${used/cap*100}%"></i></div><div class="btns">${btn(tr('common.new_circuit'),'openVxc',{from:c,prov:f.id},'pink sm')}${pt.tier<1?btn(tr('common.upgrade_port_price_mo',{port:NNI[1].n,price:fmt$(NNI[1].mo)}),'buyNni',{city:c,prov:f.id,tier:1},'sm'):''}${btn(tr('common.remove_port'),'rmNni',{city:c,prov:f.id},'ghost sm')}</div>`;}
|
||||
else h+=`<div class="btns">${NNI.map((N,i)=>btn(tr('city_panel.port_port_price_mo_197d',{port:N.n,price:fmt$(N.mo)}),'buyNni',{city:c,prov:f.id,tier:i},'sm',S.cash<N.mo)).join('')}</div>`;
|
||||
// Every speed the router takes, every member a LAG may have (#140), as for transit and PNIs.
|
||||
if(pt){const n=pt.n||1,N=NNI[pt.tier],cap=nniCap(pt),up=(N2,i)=>{const a={port:N2.n,cost:fmt$(N2.mo*n),mo:fmt$(N2.mo*n)};return btn(n>1?tr('common.upgrade_all_to_port_cost_mo',a):tr('common.upgrade_port_price_mo',{port:N2.n,price:fmt$(N2.mo)}),'buyNni',{city:c,prov:f.id,tier:i},'sm',S.cash<N2.mo*n||!portOk(c,i));};
|
||||
h+=`<div class="kv"><span>${lagName(pt.tier,n)} · ${portMo(N.mo*n)}</span><b>${tr('city_panel.g_of_circuits',{g:fmtG(used)})} / ${fmtG(cap)}</b></div><div class="bar ${barCls(used/cap)}"><i style="width:${Math.min(100,used/cap*100)}%"></i></div><div class="btns">${btn(tr('common.new_circuit'),'openVxc',{from:c,prov:f.id},'pink sm')}${NNI.map((N2,i)=>i>pt.tier&&portShown(i)?up(N2,i):'').join('')}${n<LAG_MAX?btn(tr('common.lag_member_price',{price:portMo(N.mo)}),'lagNni',{city:c,prov:f.id,d:1},'sm',S.cash<N.mo||!portOk(c,pt.tier)):''}${n>1?btn(tr('common.member'),'lagNni',{city:c,prov:f.id,d:-1},'ghost sm'):''}${btn(tr('common.remove_port'),'rmNni',{city:c,prov:f.id},'ghost sm')}</div>`;}
|
||||
else h+=`<div class="btns">${NNI.map((N,i)=>portShown(i)?btn(tr('city_panel.port_port_price_mo_197d',{port:N.n,price:fmt$(N.mo)}),'buyNni',{city:c,prov:f.id,tier:i},'sm',S.cash<N.mo||!portOk(c,i)):'').join('')}</div>`;
|
||||
h+=`</div></div>`;}
|
||||
h+=`</section>`;}
|
||||
h+=`<section><h3>${tr('city_panel.fiber_from_city',{city:C.name})}</h3><p class="lead">${tr('city_panel.drag_from_this_router_to_any')}</p>`;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function conns(){const out=[],pn=(tier,n)=>(n||1)>1?`${n}×${PORT[tier].n} LAG`:
|
|||
for(const c in S.ixp){const ses=ixSessions(c),mine=!!S.myIx[c];out.push({k:'ix',id:c,city:ixCity(c),net:null,nets:[...ses],name:ixName(c),port:mine?tr('common.your_exchange'):pn(S.ixp[c],(S.ixn||{})[c]),cap:ixCap(c),use:R.useIx[c]||0,mo:ixMo(c),mine,down:!!(S.ev.ixdown&&S.ev.ixdown[c]>S.day),low:(S.ixPref&&S.ixPref[c])==='low',note:trn('connections.n_peering_session',ses.size)+(isRemote(c)?' · '+tr('common.remote'):'')});}
|
||||
const cg={};for(const x of S.caches){const key=x.city+'|'+x.net;(cg[key]=cg[key]||[]).push(x);}
|
||||
for(const key in cg){const g=cg[key],x=g[0];out.push({k:'c',id:x.id,n:g.length,city:x.city,net:x.net,name:NET[x.net].cache.name,port:trn('common.n_box',g.length),cap:g.reduce((a,y)=>a+cacheG(y),0),use:g.reduce((a,y)=>a+(R.useCache[y.id]||0),0),mo:g.reduce((a,y)=>a+cacheMo(y),0),down:!popUp(x.city),low:false,note:tr('common.from_net',{net:NET[x.net].name})});}
|
||||
for(const x of S.nni||[])if(FAB[x.prov]&&NNI[x.tier])out.push({k:'nni',id:x.city+'|'+x.prov,city:x.city,net:null,name:FAB[x.prov].name,port:NNI[x.tier].n,cap:NNI[x.tier].g,use:nniUsed(x.city,x.prov),mo:NNI[x.tier].mo,down:!popUp(x.city),low:false,note:tr('connections.virtual_circuits_and_fabric')});
|
||||
for(const x of S.nni||[])if(FAB[x.prov]&&NNI[x.tier])out.push({k:'nni',id:x.city+'|'+x.prov,city:x.city,net:null,name:FAB[x.prov].name,port:pn(x.tier,x.n),cap:nniCap(x),use:nniUsed(x.city,x.prov),mo:nniMo(x),down:!popUp(x.city),low:false,note:tr('connections.virtual_circuits_and_fabric')});
|
||||
return out;}
|
||||
// Cancel straight from the list, with the same "Really?" step as the POP panel.
|
||||
// Grow a connection from the list: the next port size and one more LAG member, same actions and prices as the POP panel.
|
||||
|
|
@ -26,7 +26,9 @@ function connUp(r){if(r.mine)return '';const nx=t=>PORT[t+1]&&portShown(t+1)?t+1
|
|||
if(i>=0)h+=btn(tr('common.upgrade_port_price',{port:PORT[i].n,price:portMo(ixPortMo(c,i)*n)}),'buyIx',{city:c,tier:i},'sm',(!!S.pops[city]&&!portOk(city,i))||(!S.pops[city]&&i>1));
|
||||
if(S.pops[city]&&!S.myIx[c]&&n<LAG_MAX)h+=btn(tr('common.lag_member_price',{price:portMo(ixPortMo(c,S.ixp[c]))}),'lagIx',{city:c,d:1},'sm',S.cash<ixPortMo(c,S.ixp[c]));}
|
||||
else if(r.k==='c')h+=btn(tr('common.box'),'cache',{city:r.city,net:r.net},'sm');
|
||||
else if(r.k==='nni'){const [city,prov]=r.id.split('|'),pt=nniPort(city,prov);if(pt&&pt.tier<NNI.length-1)h+=btn(tr('common.upgrade_port_price_mo',{port:NNI[pt.tier+1].n,price:fmt$(NNI[pt.tier+1].mo)}),'buyNni',{city,prov,tier:pt.tier+1},'sm');}
|
||||
else if(r.k==='nni'){const [city,prov]=r.id.split('|'),pt=nniPort(city,prov);if(!pt)return '';const n=pt.n||1,i=nx(pt.tier);
|
||||
if(i>=0){const c=NNI[i].mo*n;h+=btn(n>1?tr('common.upgrade_all_to_port_cost_mo',{port:NNI[i].n,cost:fmt$(c),mo:fmt$(c)}):tr('common.upgrade_port_price_mo',{port:NNI[i].n,price:fmt$(c)}),'buyNni',{city,prov,tier:i},'sm',S.cash<c||!portOk(city,i));}
|
||||
if(n<LAG_MAX)h+=btn(tr('common.lag_member_price',{price:portMo(NNI[pt.tier].mo)}),'lagNni',{city,prov,d:1},'sm',S.cash<NNI[pt.tier].mo||!portOk(city,pt.tier));}
|
||||
return h;}
|
||||
function connX(r){if(r.mine)return '';const on=UI.confirm==='cc:'+r.k+':'+r.id;
|
||||
return btn(on?(r.k==='ix'?tr('common.really_leave'):r.k==='t'?tr('common.really_cancel'):tr('common.really_remove')):r.k==='ix'?tr('common.leave_ix'):r.k==='t'?tr('common.cancel'):r.k==='c'&&r.n>1?tr('common.box_6ee3'):r.k==='nni'?tr('common.remove_port'):tr('common.remove'),'connCancel',{k:r.k,id:r.id},on?'red sm':'ghost sm');}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
const NOC_HB=3000,NOC_LOST=10000,NOC_GAP=1000;
|
||||
// What a click in the window does: changes only its own view, or runs in the game. Every button the dashboard draws is in one list.
|
||||
const NOC_LOCAL=['chartToggle','connCity','connF','connNet','connSort','custCity','custF','custSort','dashClose','dashSort','dashTab','listMore','popsReg','popsSort'];
|
||||
const NOC_GO=['buyIx','buyNni','buyTransit','cache','connCancel','custGo','dashLink','goConn','lagIx','lagP','lagT','leaseSwap','netFocus','opsOpen','pni','pniAllOpen','popGo'];
|
||||
const NOC_GO=['buyIx','buyNni','buyTransit','cache','connCancel','custGo','dashLink','goConn','lagIx','lagNni','lagP','lagT','leaseSwap','netFocus','opsOpen','pni','pniAllOpen','popGo'];
|
||||
const NOC={win:false,id:null,ctl:null,st:null,stId:null,peer:false,until:0,dirty:false,sent:0,speed:1,hid:false,yoAt:0,gone:false};
|
||||
{const id=RW_IN?null:new URLSearchParams(location.search).get('noc');if(slotOkId(id)){NOC.win=true;NOC.id=id;}}
|
||||
if(!RW_IN)try{if(typeof BroadcastChannel==='function'){NOC.ctl=new BroadcastChannel('sot-noc');NOC.ctl.onmessage=e=>{const m=e.data;if(!m||typeof m!=='object'||!slotOkId(m.id))return;if(NOC.win)nocWinMsg(m);else nocGameMsg(m);};}}catch(e){}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ function dfModalBody(a,b,km,pop){
|
|||
function openVxcModal({from,to,prov}){
|
||||
let rows='';const row=(f,a,b)=>{const km=kmBetween(a,b),sub=isSub(a,b),pb=S.pops[b]?nniPort(b,f.id):null,remote=!S.pops[b];
|
||||
const label=remote?tr('fiber_modals.remote_peering_at_ix_discouraged',{ix:esc(CITY[b].ix)}):pb?tr('common.your_pop'):tr('fiber_modals.your_pop_needs_a_fabric_port');
|
||||
const freeA=nniPort(a,f.id)?NNI[nniPort(a,f.id).tier].g-nniUsed(a,f.id):0,freeB=remote?1e9:pb?NNI[pb.tier].g-nniUsed(b,f.id):0;
|
||||
const freeA=nniCap(nniPort(a,f.id))-nniUsed(a,f.id),freeB=remote?1e9:pb?nniCap(pb)-nniUsed(b,f.id):0;
|
||||
return `<div class="row"><span class="logo" style="--c:${f.col}">${initials(f)}</span><div class="grow"><div class="nm">${CITY[a].name} → ${CITY[b].name}</div><div class="meta">${label} · ${km.toLocaleString()} km${sub?' '+tr('common.subsea'):''}</div>
|
||||
<div class="btns">${VXC.map((V,t)=>btn(`${V.n} <small>${tr('common.price_mo',{price:fmt$(vxcMo(km,sub,t))})}</small>`,'buyVxc',{a,b,prov:f.id,t},'sm',(!remote&&!pb)||V.g>freeA||V.g>freeB||S.cash<vxcMo(km,sub,t))).join('')}</div></div></div>`;};
|
||||
for(const f of FABS){if(prov&&f.id!==prov)continue;
|
||||
|
|
|
|||
|
|
@ -1017,7 +1017,6 @@
|
|||
"city_panel.pay_a_bigger_network_per_gbps":"Pay a bigger network per Gbps and it carries your traffic to the whole internet. Billed on the 95th percentile of the last 30 days, with a 20% commit and a port fee. Spikes like DDoS raise your bill.",
|
||||
"city_panel.peer_at_ix_without_building_a":"Peer at {ix} without building a POP. Order a virtual circuit here from one of your POPs over {fabs}.",
|
||||
"city_panel.port_cost_mo_mo":"{port} <small>{cost} + {mo}/mo</small>",
|
||||
"city_panel.port_port_price_mo":"{port} port · {price}/mo",
|
||||
"city_panel.port_port_price_mo_197d":"{port} port <small>{price}/mo</small>",
|
||||
"city_panel.power_cuts_are_covered":"Power cuts are covered.",
|
||||
"city_panel.price_per_gbps_month_billed_on":"${price} per Gbps / month · billed on 95th percentile",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue