diff --git a/site/i18n/it.js b/site/i18n/it.js index ad3b2e5..6c26962 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2193,4 +2193,26 @@ "Spares shelf":"Scaffale ricambi", "Sell one {price}":"Vendine uno {price}", "New networks on the map.
This update added networks you are not connected to yet. For {n} days a free courtesy route reaches them, so your reach does not drop overnight. Peer with them, or buy transit, before it ends.":"Nuove reti sulla mappa.
Questo aggiornamento ha aggiunto reti a cui non sei ancora collegato. Per {n} giorni un percorso di cortesia gratuito le raggiunge, così la tua raggiungibilità non crolla da un giorno all’altro. Fai peering con loro, o compra transit, prima che finisca.", +"Flood Season":"Stagione delle piene", +"Amsterdam, hosting capital of Europe, in peak botnet season. Every smart toaster, baby monitor and unpatched fridge on Earth has picked a side, and it is not yours. A flood every few days, more and more of them in the terabits, while everything else keeps breaking too. You start with bigger gear unlocked, and you will need it.":"Amsterdam, capitale europea dell’hosting, in piena stagione delle botnet. Ogni tostapane smart, baby monitor e frigo mai aggiornato della Terra ha scelto da che parte stare, e non è la tua. Un’ondata ogni pochi giorni, sempre più spesso nei terabit, mentre tutto il resto continua a rompersi. Parti con l’attrezzatura più grossa già sbloccata, e ti servirà.", +"Hold 20 floods, 5 of them over 1 Tbps, keeping the city under attack at 97% or better":"Reggi 20 ondate, 5 sopra 1 Tbps, tenendo la città sotto attacco al 97% o meglio", +"Attacker: {who}.":"Attaccante: {who}.", +"Flood held: {g}.
{who} gave up and went back to mining crypto.":"Ondata respinta: {g}.
{who} si è arreso ed è tornato a minare cripto.", +"That one got through: {g}.
{city} sank to {p}. Somewhere, {who} is very proud of itself.":"Questa è passata: {g}.
{city} è scesa al {p}. Da qualche parte, {who} è molto fiero di sé.", +"a botnet of 40,000 smart toasters":"una botnet di 40.000 tostapane smart", +"every unpatched baby monitor in Europe":"ogni baby monitor non aggiornato d’Europa", +"a gaming clan that lost one match":"un clan di gamer che ha perso una partita", +"a fridge that achieved sentience and chose violence":"un frigo diventato senziente che ha scelto la violenza", +"a crypto bro shorting your stock":"un cripto-bro che scommette contro le tue azioni", +"a teenager with a stolen credit card and a grudge":"un adolescente con una carta di credito rubata e un rancore", +"a rival ISP’s “stress test”":"lo “stress test” di un ISP rivale", +"ten thousand smart light bulbs, blinking in unison":"diecimila lampadine smart che lampeggiano all’unisono", +"a printer. Just one printer. Nobody knows how":"una stampante. Una sola stampante. Nessuno sa come", +"a botnet run from a cloud you also host":"una botnet che gira in un cloud che ospiti anche tu", +"somebody who did not like your network name":"qualcuno a cui non piaceva il nome della tua rete", +"the internet-connected kettles of a whole country":"i bollitori connessi di un intero paese", +"Floods held":"Ondate respinte", +"Terabit floods held":"Ondate terabit respinte", +"Floods that got through":"Ondate passate", +"Under attack now":"Sotto attacco ora", }; diff --git a/site/index.html b/site/index.html index aa4f78d..9e9d7c1 100644 --- a/site/index.html +++ b/site/index.html @@ -1284,6 +1284,7 @@ const SCN=[ {id:'carnaval',n:tr('Carnaval'),city:'rio',cash:600000,days:100,rules:{},setup:()=>{S.biz.push({id:uid(),scripted:true,city:'rio',city2:null,reqs:[],name:'Carnaval Parade in Rio de Janeiro',type:'event',bw:400,rate:0,mood:100,since:0,start:90,dur:5,fee:400*5*70});},d:tr('Rio from scratch. Carnaval starts in 90 days and wants 400 Gbps for five days straight. The whole world is watching.'),goal:tr('Deliver Carnaval in full'),ok:()=>(S.stats.evFull||0)>=1}, {id:'darien',n:tr('Mind the Gap'),city:'pan',cash:900000,days:730,rules:{},d:tr('Start in Panama City. Nothing crosses the Darién Gap by land, and the Andes are in the way of everything else.'),goal:tr('POPs in Bogotá, Lima, Santiago and São Paulo, and 150 Gbps served'),ok:()=>['bog','lim','scl','sao'].every(c=>S.pops[c])&&R.served>=150}, {id:'gangnam',n:tr('Gangnam Style Peering'),city:'icn',cash:900000,days:365,rules:{},d:tr('Seoul. The fastest, hungriest eyeballs on Earth, transit at four times the price, and three incumbents who bill you for every gigabit you send them.'),goal:tr('99% reach and 200 Gbps served without going broke'),ok:()=>R.reach>=0.99&&R.served>=200}, + {id:'flood',n:tr('Flood Season'),city:'ams',cash:2000000,days:365,rules:{ddos:true},setup:()=>{S.lvl=Math.max(S.lvl||1,3);},d:tr('Amsterdam, hosting capital of Europe, in peak botnet season. Every smart toaster, baby monitor and unpatched fridge on Earth has picked a side, and it is not yours. A flood every few days, more and more of them in the terabits, while everything else keeps breaking too. You start with bigger gear unlocked, and you will need it.'),goal:tr('Hold 20 floods, 5 of them over 1 Tbps, keeping the city under attack at 97% or better'),ok:()=>(S.stats.ddosOk||0)>=20&&(S.stats.ddosOkBig||0)>=5}, {id:'baltic',n:tr('Anchors Away'),city:'tll',cash:500000,days:540,rules:{anchors:3},d:tr('Tallinn. Ships drag their anchors over Baltic cables three times as often as usual.'),goal:tr('90 days in a row with 99.5% of demand served'),ok:()=>(S.stats.clean||0)>=90}, ]; const WEEK_CITIES=['fra','ams','lon','nyc','ash','sjc','sin','tok','syd','sao','jnb','bom','waw','ist','scl','hkg']; @@ -2037,7 +2038,7 @@ function fireFailure(){ if(S.transit.some(t=>!(t.down>S.day)))opts.push(['transit',3]); if(Object.keys(S.ixp).length)opts.push(['ixloop',2]); if(S.transit.length&&S.day>60)opts.push(['leak',2]); - if(S.day>40)opts.push(['ddos',2]); + if(S.day>40&&!scnRule('ddos'))opts.push(['ddos',2]); // Flood Season brings its own if(fabsUsed.length)opts.push(['fabric',1.5]); const lit=S.links.filter(l=>l.kind==='df'&&dfCap(l)>0&&!linkDown(l));if(lit.length)opts.push(['amp',1.5+lit.length*0.3],['optic',1.5+lit.length*0.3]); opts.push(['funny',4]); @@ -2132,21 +2133,7 @@ function fireFailure(){ }else if(type==='fabric'){ const f=pick(fabsUsed);S.ev.fab=S.ev.fab||{};S.ev.fab[f]=S.day+2+Math.floor(Math.random()*3); addInc({type,ref:f,until:S.ev.fab[f],msg:tr('{fabric} is having a bad day. Every virtual circuit on their fabric is down.',{fabric:FAB[f].name}),cost:0}); - }else if(type==='ddos'){ - const c=pick(Object.keys(S.pops)),vec=pick(Object.keys(DDOS_VEC)),V=DDOS_VEC[vec]; - // Mostly short, modest spikes; now and then a "botnet of toasters" monster into the terabits. - const monster=Math.random()<0.15,base=Math.max(R.cityDem[c]||0,4); - const gbps=monster?Math.round(800+Math.random()*2600):Math.round(2+Math.random()*Math.max(18,base*0.9)); - const dur=2+Math.floor(Math.random()*4),entry=ddosEntry(c); - S.ev.ddos={city:c,vec,gbps,until:S.day+dur,entry,bh:false,start:S.day}; - const soaked=(V.fs&&fsAt(c))||S.scrubAt; - const how=entry&&entry.lab?tr(', in via {e}',{e:entry.lab}):''; - const msg=tr('A {size} {vec} attack is hitting {city}{how}.',{size:fmtG(gbps),vec:V.n,city:CITY[c].name,how})+' '+(soaked?tr('Your mitigation is eating most of it.'):tr('Junk traffic is eating your capacity. Open the NOC to fight back.')); - addInc({type,ref:c,until:S.day+dur,msg,cost:0}); - if(soaked){S.stats.survived++;S.stats.ddosHeld=(S.stats.ddosHeld||0)+1;if(gbps>=1000)S.stats.ddosMonster=(S.stats.ddosMonster||0)+1;} - compute(); - toast(`${incTitle('ddos')}: ${esc(CITY[c].name)}
${esc(msg)}`,soaked?'goal':'bad',[{l:tr('Open NOC'),act:'leftTab',args:{t:'noc'}}]); - sfx('alert');return; + }else if(type==='ddos'){ddosAttack();return; } compute(); const last=S.inc[S.inc.length-1]; @@ -2155,6 +2142,28 @@ function fireFailure(){ else{const paused=pref('pauseIncident')&&autoPause();toast(`${incTitle(type)}
${esc(last.msg)}${paused?`
${tr('Game paused.')}`:''}`,'bad',(last.cost?[{l:`${last.fix||tr('Rush repair')} ${fmt$(last.cost)}`,act:'fixInc',args:{id:last.id}}]:[]).concat(paused?[resumeAct()]:[]));} sfx('alert'); } +// A DDoS attack: mostly short, modest spikes; now and then a "botnet of toasters" monster into the terabits. +// In Flood Season (scenario rule ddos) they come more often, a third are monsters, and they grow over the year. +function ddosAttack(){const type='ddos',fl=scnRule('ddos'),grow=fl?1+S.day/180:1;if(S.ev.ddos&&S.ev.ddos.until>S.day)ddosDone(S.ev.ddos); + const c=pick(Object.keys(S.pops)),vec=pick(Object.keys(DDOS_VEC)),V=DDOS_VEC[vec]; + const monster=Math.random()<(fl?0.33:0.15),base=Math.max(R.cityDem[c]||0,4); + const gbps=Math.round((monster?800+Math.random()*2600:2+Math.random()*Math.max(18,base*0.9))*grow); + const dur=2+Math.floor(Math.random()*4),entry=ddosEntry(c); + S.ev.ddos={city:c,vec,gbps,until:S.day+dur,entry,bh:false,start:S.day}; + const soaked=(V.fs&&fsAt(c))||S.scrubAt; + const how=entry&&entry.lab?tr(', in via {e}',{e:entry.lab}):''; + const msg=tr('A {size} {vec} attack is hitting {city}{how}.',{size:fmtG(gbps),vec:V.n,city:CITY[c].name,how})+' '+(soaked?tr('Your mitigation is eating most of it.'):tr('Junk traffic is eating your capacity. Open the NOC to fight back.')); + if(fl)S.ev.ddos.who=pick(FLOOD_WHO); + addInc({type,ref:c,until:S.day+dur,msg:fl?msg+' '+tr('Attacker: {who}.',{who:tr(S.ev.ddos.who)}):msg,cost:0}); + if(soaked){S.stats.survived++;S.stats.ddosHeld=(S.stats.ddosHeld||0)+1;if(gbps>=1000)S.stats.ddosMonster=(S.stats.ddosMonster||0)+1;} + compute(); + toast(`${incTitle('ddos')}: ${esc(CITY[c].name)}
${esc(msg)}${fl?`
${esc(tr('Attacker: {who}.',{who:tr(S.ev.ddos.who)}))}`:''}`,soaked?'goal':'bad',[{l:tr('Open NOC'),act:'leftTab',args:{t:'noc'}}]); + sfx('alert');} +// When an attack is over: was it held? Held means the city under attack got at least 97% of its traffic every day. +function ddosDone(a){if(!a||a.done)return;a.done=1;if(a.worst===undefined&&S.pops[a.city])a.worst=sfOf(R,a.city);const ok=(a.worst===undefined?1:a.worst)>=0.97; + if(ok){S.stats.ddosOk=(S.stats.ddosOk||0)+1;if(a.gbps>=1000)S.stats.ddosOkBig=(S.stats.ddosOkBig||0)+1;}else S.stats.ddosLost=(S.stats.ddosLost||0)+1; + if(scnRule('ddos')){const who=tr(a.who||FLOOD_WHO[0]);toast(ok?tr('Flood held: {g}.
{who} gave up and went back to mining crypto.',{g:fmtG(a.gbps),who:who.charAt(0).toUpperCase()+who.slice(1)}):tr('That one got through: {g}.
{city} sank to {p}. Somewhere, {who} is very proud of itself.',{g:fmtG(a.gbps),city:CITY[a.city]?CITY[a.city].name:tr('Your network'),p:pct(a.worst||0),who}),ok?'goal':'bad');}} +const FLOOD_WHO=[N_('a botnet of 40,000 smart toasters'),N_('every unpatched baby monitor in Europe'),N_('a gaming clan that lost one match'),N_('a fridge that achieved sentience and chose violence'),N_('a crypto bro shorting your stock'),N_('a teenager with a stolen credit card and a grudge'),N_('a rival ISP’s “stress test”'),N_('ten thousand smart light bulbs, blinking in unison'),N_('a printer. Just one printer. Nobody knows how'),N_('a botnet run from a cloud you also host'),N_('somebody who did not like your network name'),N_('the internet-connected kettles of a whole country')]; function incTitle(t){return {ring:tr('Metro ring cut'),site:tr('Site outage'),cut:tr('Fiber cut'),crash:tr('Router crash'),power:tr('Power outage'),transit:tr('Upstream outage'),ixloop:tr('IX meltdown'),leak:tr('Route leak'),ddos:tr('DDoS attack'),fabric:tr('Fabric outage'),depeer:tr('Peering spat'),fatwave:tr('Fat-fingered wave'),label:tr('Patch panel mishap'),mtu:tr('MTU mismatch'),krroute:tr('Rerouted via Hong Kong'),ctrlplane:tr('Control plane meltdown'),lacp:tr('LACP trouble'),loss:tr('Packet loss'),pmtud:tr('PMTUD black hole'),oops:tr('Oops'),cleaner:tr('Vacuum incident'),maxpfx:tr('Max-prefix meltdown'),prepend:tr('Prepend-ageddon'),rpki:tr('RPKI invalid'),amp:tr('Amplifier failure'),roadmff:tr('Fat-fingered ROADM'),optic:tr('Dead optic'),maint:tr('Maintenance window'),ac:tr('Cooling failure'),hijack:tr('BGP hijack'),shutdown:tr('Government shutdown'),redsea:tr('Geopolitical cable cut')}[t]||tr('Incident');} const LINKCUT_TR=['cut','redsea'],LINKCUT_ID=['fatwave','label'],POPDOWN=['crash','power','oops','cleaner','maint','shutdown'],IXDOWN=['ixloop','maxpfx'],TDOWN=['transit','prepend'],LINKEQ=['mtu','amp','roadmff','optic']; function remainUntil(pred){let u=0;for(const x of S.inc)if(pred(x))u=Math.max(u,x.until);return u;} @@ -2168,7 +2177,7 @@ function clearInc(i){ else if(TDOWN.includes(T)){const t=S.transit.find(x=>x.id===i.ref);if(t)t.down=remainUntil(x=>TDOWN.includes(x.type)&&x.ref===i.ref);} else if(T==='rpki'||T==='hijack'){if(!S.inc.some(x=>x.type==='rpki'||x.type==='hijack'))S.ev.rpki=null;} else if(T==='leak'){S.ev.leak=null;} - else if(T==='ddos'){S.ev.ddos=null;} + else if(T==='ddos'){const a=S.ev.ddos;if(a&&a.city===i.ref&&(a.start===undefined||a.start===i.start)){ddosDone(a);S.ev.ddos=null;}} else if(T==='fabric'){if(S.ev.fab)S.ev.fab[i.ref]=remainUntil(x=>x.type==='fabric'&&x.ref===i.ref);} else if(T==='mtu'){const l=S.links.find(x=>x.id===i.ref);if(l)l.deg=remainUntil(x=>x.type==='mtu'&&x.ref===i.ref);} else if(T==='loss'){const l=S.links.find(x=>x.id===i.ref);if(l&&!S.inc.some(x=>x.type==='loss'&&x.ref===i.ref))l.loss=null;} @@ -2244,6 +2253,8 @@ function dayTick(){ if(R&&R.teMoved)S.stats.teMax=Math.max(S.stats.teMax||0,R.teMoved); {const t1=!!S.won&&isTier1();if(S.t1Now&&!t1)toast(tr('You are no longer Tier 1.
Because {why}. Your Tier 1 badge stays; win the status back to show it again.',{why:t1Why()}),'bad');S.t1Now=t1;} if(S.grace&&S.grace.until===d){toast(tr('The courtesy route has ended.
New networks you have not connected to are now only reachable through your own peering and transit.'),'bad',[{l:tr('Open NOC'),act:'leftTab',args:{t:'noc'}}]);} + {const a=S.ev.ddos;if(a&&a.until>d&&R&&S.pops[a.city])a.worst=Math.min(a.worst===undefined?1:a.worst,sfOf(R,a.city));} + if(scnRule('ddos')&&!(S.scn.done||S.scn.failed)&&d>=(+S.scn.nextDdos||3)&&!(S.ev.ddos&&S.ev.ddos.until>d)){ddosAttack();S.scn.nextDdos=d+3+Math.floor(Math.random()*5);} if(R&&R.demand>0)S.stats.clean=R.served/R.demand>=0.995?(S.stats.clean||0)+1:0; if(S.ev.php===d)toast(tr('The internet is back.
Half of it, anyway. Everything was patched in a hurry and nobody learned anything.'),'good'); for(const k in S.peers){const [id,c]=k.split('@'),sn=snub(id,c);if(!sn)continue;delete S.peers[k];S.stats.depeered=(S.stats.depeered||0)+1; @@ -3109,11 +3120,13 @@ const pReach=()=>({l:tr('Reach'),v:R.reach,max:0.99,txt:`${pct(R.reach)} / 99%`} const pChk=(l,ok)=>({l,v:ok?1:0,max:1,txt:ok?'✓':'—'}); const SCN_PROG={stg:()=>[pSrv(200)],redsea:()=>[pChk(tr('A path from Marseille to Singapore'),pathExists('mrs','sin')),pSrv(300)],spat:()=>[pReach(),pSrv(150)], carnaval:()=>[pChk(tr('Carnaval delivered in full'),(S.stats.evFull||0)>=1)],darien:()=>[...['bog','lim','scl','sao'].map(c=>pChk(tr('POP in {city}',{city:CITY[c].name}),!!S.pops[c])),pSrv(150)], - gangnam:()=>[pReach(),pSrv(200)],baltic:()=>[{l:tr('Days in a row with 99.5% served'),v:S.stats.clean||0,max:90,txt:tr('{n} of {m}',{n:S.stats.clean||0,m:90})}]}; + gangnam:()=>[pReach(),pSrv(200)], + flood:()=>{const ok=S.stats.ddosOk||0,big=S.stats.ddosOkBig||0,a=S.ev.ddos&&S.ev.ddos.until>S.day?S.ev.ddos:null; + return [{l:tr('Floods held'),v:ok,max:20,txt:`${ok} / 20`},{l:tr('Terabit floods held'),v:big,max:5,txt:`${big} / 5`},{l:tr('Floods that got through'),v:0,max:0,txt:String(S.stats.ddosLost||0)}].concat(a?[{l:tr('Under attack now'),v:0,max:0,txt:`${fmtG(a.gbps)} · ${CITY[a.city].name} · ${pct(a.worst===undefined?1:a.worst)}`}]:[]);},baltic:()=>[{l:tr('Days in a row with 99.5% served'),v:S.stats.clean||0,max:90,txt:tr('{n} of {m}',{n:S.stats.clean||0,m:90})}]}; function scnProg(){const sc=S&&S.scn;if(!sc)return null; if(sc.id==='weekly')return {goal:tr('Serve as much traffic as you can in one year.'),items:[{l:tr('Your score: peak traffic'),v:0,max:0,txt:fmtG(S.stats.peak||0)}],f:Math.min(1,S.day/sc.days)}; const def=SCN.find(x=>x.id===sc.id),fn=SCN_PROG[sc.id];if(!def)return null;let items=[];try{items=fn?fn():[];}catch(e){items=[];} - const f=sc.done?1:items.length?items.reduce((a,x)=>a+Math.min(1,x.max?x.v/x.max:0),0)/items.length:0;return {goal:def.goal,items,f};} + const meas=items.filter(x=>x.max),f=sc.done?1:meas.length?meas.reduce((a,x)=>a+Math.min(1,x.v/x.max),0)/meas.length:0;return {goal:def.goal,items,f};} const pRow=x=>`
${esc(x.l)}${esc(x.txt)}
${x.max?`
`:''}`; function scnCard(){const sc=S.scn,P=scnProg();if(!sc||!P)return '';const left=Math.max(0,sc.days-S.day); const st=sc.done?`${tr('Done in {d} days!',{d:sc.done})}`:sc.failed?`${tr("Time's up")}`:tr('{n} days left',{n:left}); diff --git a/tests/modes.test.js b/tests/modes.test.js index d08439c..1660f2d 100644 --- a/tests/modes.test.js +++ b/tests/modes.test.js @@ -310,3 +310,25 @@ test('a brand-new phone player can click through the install pitch and the title assert.equal(ev('!!(S&&UI.started)'), true, 'Play in the browser anyway really starts the game'); assert.deepEqual(errors, []); }); + +test('Flood Season: attacks keep coming, grow, and only count when service held', () => { + const { ev, errors } = load(); + ev("ACT.startScn({id:'flood',sure:1})"); + assert.equal(ev("S.scn.id"), 'flood'); + assert.ok(ev('S.lvl') >= 3, 'starts with bigger gear unlocked'); + // a few weeks in: several attacks start on their own schedule + let n = 0; + for (let i = 0; i < 40; i++) { ev('dayTick()'); if (ev('!!(S.ev.ddos&&S.ev.ddos.start===S.day)')) n++; } + assert.ok(n >= 4, `attacks keep coming (${n} in 40 days)`); + assert.ok(ev('(S.stats.ddosOk||0)+(S.stats.ddosLost||0)') >= 3, 'finished attacks are scored'); + // scoring: held only if service stayed at 97%+ + ev("S.stats.ddosOk=0;S.stats.ddosOkBig=0;S.stats.ddosLost=0;ddosDone({city:'ams',gbps:1500,worst:0.99});ddosDone({city:'ams',gbps:20,worst:0.5});ddosDone({city:'xyz',gbps:30,worst:1})"); + assert.equal(ev('S.stats.ddosOk'), 2); + assert.equal(ev('S.stats.ddosOkBig'), 1); + assert.equal(ev('S.stats.ddosLost'), 1); + const P = JSON.parse(ev('JSON.stringify(scnProg())')); + assert.match(P.items.map((x) => x.l).join(' '), /Floods held.*Terabit floods held/); + ev('S.stats.ddosOk=20;S.stats.ddosOkBig=5;scnTick(S.day)'); + assert.ok(ev('!!S.scn.done'), 'the goal completes'); + assert.deepEqual(errors, []); +});