reset repository for public consumption 🍽️
This commit is contained in:
14 files changed
+376
No files matched your search
@@ -0,0 +1,19 @@
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: cloudflare/wrangler-action@master
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
- uses: jakejarvis/cloudflare-purge-action@master
|
||||
env:
|
||||
CLOUDFLARE_ZONE: "92e2ec634800f776ec4f3e983491c349"
|
||||
CLOUDFLARE_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
||||
@@ -0,0 +1,6 @@
|
||||
node_modules/
|
||||
worker/
|
||||
dist/
|
||||
|
||||
package-lock.json
|
||||
*.img
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-present Jake Jarvis <jake@jarv.is>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,26 @@
|
||||
# 💾 [y2k.lol](https://y2k.lol/)
|
||||
|
||||
Nostalgic time machine powered by on-demand Windows Me VMs and [my first website](https://jarv.is/y2k/). Inspired by [charlie.bz](https://charlie.bz/) (and quarantine boredom).
|
||||
|
||||
The backend isn't quite ready to be open-sourced (read: it's still a fatally embarrassing ball of spaghetti) but will be moved here very soon! 🍝
|
||||
|
||||
<p align="center"><a href="https://y2k.lol/"><img width="600" src="screenshot.png"></a></p>
|
||||
|
||||
## Requirements
|
||||
|
||||
- Ruby
|
||||
- [QEMU 4.x](https://www.qemu.org/) (target i386)
|
||||
- [websocketd](https://github.com/joewalnes/websocketd)
|
||||
- [noVNC](https://github.com/novnc/noVNC)
|
||||
- [Cloudflare Workers](https://workers.cloudflare.com/) & [Argo Tunnel](https://www.cloudflare.com/products/argo-tunnel/)
|
||||
|
||||
## To-Do
|
||||
|
||||
- [x] Sync user's mouse cursor/movements with VM
|
||||
- [ ] Error messages: no websockets, server down, etc.
|
||||
- [ ] Usage limits
|
||||
- [ ] Responsive browser sizing
|
||||
|
||||
## License
|
||||
|
||||
This project is distributed under the [MIT license](LICENSE.md).
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
/*!
|
||||
* noVNC: HTML5 VNC client
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Copyright (C) 2013 Samuel Mannehed for Cendio AB
|
||||
* Copyright (C) 2013 NTT corp.
|
||||
* Licensed under MPL 2.0 (see https://github.com/novnc/noVNC/blob/master/LICENSE.txt)
|
||||
*/
|
||||
"use strict";var Util={};Array.prototype.push8=function(num){this.push(255&num)};Array.prototype.push16=function(num){this.push(num>>8&255,255&num)};Array.prototype.push32=function(num){this.push(num>>24&255,num>>16&255,num>>8&255,255&num)};Array.prototype.map||(Array.prototype.map=function(fun){var len=this.length;if("function"!=typeof fun)throw new TypeError;for(var res=new Array(len),thisp=arguments[1],i=0;i<len;i++)i in this&&(res[i]=fun.call(thisp,this[i],i,this));return res});Array.prototype.indexOf||(Array.prototype.indexOf=function(elt){var len=this.length>>>0,from=Number(arguments[1])||0;(from=from<0?Math.ceil(from):Math.floor(from))<0&&(from+=len);for(;from<len;from++)if(from in this&&this[from]===elt)return from;return-1});window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback){window.setTimeout(callback,1e3/60)};Util._log_level="warn";Util.init_logging=function(level){void 0===level?level=Util._log_level:Util._log_level=level;void 0===window.console&&(void 0!==window.opera?window.console={log:window.opera.postError,warn:window.opera.postError,error:window.opera.postError}:window.console={log:function(){},warn:function(){},error:function(){}});Util.Debug=Util.Info=Util.Warn=Util.Error=function(){};switch(level){case"debug":Util.Debug=function(){};case"info":Util.Info=function(){};case"warn":Util.Warn=function(){};case"error":Util.Error=function(){};case"none":break;default:throw"invalid logging type '"+level+"'"}};Util.get_logging=function(){return Util._log_level};Util.init_logging();Util.conf_default=function(cfg,api,defaults,v,mode,type,defval,desc){var getter,setter;getter=function(idx){return type in{arr:1,array:1}&&void 0!==idx?cfg[v][idx]:cfg[v]};setter=function(val,idx){type in{boolean:1,bool:1}?val=!(!val||val in{0:1,no:1,false:1}):type in{integer:1,int:1}?val=parseInt(val,10):"str"===type?val=String(val):"func"===type&&(val||(val=function(){}));void 0!==idx?cfg[v][idx]=val:cfg[v]=val};api[v+"_description"]=desc;void 0===api["get_"+v]&&(api["get_"+v]=getter);void 0===api["set_"+v]&&(api["set_"+v]=function(val,idx){if(mode in{RO:1,ro:1})throw v+" is read-only";if(mode in{WO:1,wo:1}&&void 0!==cfg[v])throw v+" can only be set once";setter(val,idx)});void 0!==defaults[v]?defval=defaults[v]:!(type in{arr:1,array:1})||defval instanceof Array||(defval=[]);setter(defval)};Util.conf_defaults=function(cfg,api,defaults,arr){var i;for(i=0;i<arr.length;i++)Util.conf_default(cfg,api,defaults,arr[i][0],arr[i][1],arr[i][2],arr[i][3],arr[i][4])};Util.decodeUTF8=function(utf8string){return decodeURIComponent(escape(utf8string))};Util.get_include_uri=function(){return"undefined"!=typeof INCLUDE_URI?INCLUDE_URI:"include/"};Util._loading_scripts=[];Util._pending_scripts=[];Util.load_scripts=function(files){for(var script,head=document.getElementsByTagName("head")[0],ls=Util._loading_scripts,ps=Util._pending_scripts,f=0;f<files.length;f++){(script=document.createElement("script")).type="text/javascript";script.src=Util.get_include_uri()+files[f];script.onload=script.onreadystatechange=function(){for(;ls.length>0&&("loaded"===ls[0].readyState||"complete"===ls[0].readyState);){var s=ls.shift();head.appendChild(s)}if((!this.readyState||Util.Engine.presto&&"loaded"===this.readyState||"complete"===this.readyState)&&ps.indexOf(this)>=0){this.onload=this.onreadystatechange=null;ps.splice(ps.indexOf(this),1);0===ps.length&&window.onscriptsload&&window.onscriptsload()}};if(Util.Engine.trident)ls.push(script);else{script.async=!1;head.appendChild(script)}ps.push(script)}};Util.getPosition=function(obj){var x=0,y=0;if(obj.offsetParent)do{x+=obj.offsetLeft;y+=obj.offsetTop;obj=obj.offsetParent}while(obj);return{x:x,y:y}};Util.getEventPosition=function(e,obj,scale){var evt,docX,docY,pos;if((evt=(evt=e||window.event).changedTouches?evt.changedTouches[0]:evt.touches?evt.touches[0]:evt).pageX||evt.pageY){docX=evt.pageX;docY=evt.pageY}else if(evt.clientX||evt.clientY){docX=evt.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;docY=evt.clientY+document.body.scrollTop+document.documentElement.scrollTop}void 0===scale&&(scale=1);var realx=docX-(pos=Util.getPosition(obj)).x,realy=docY-pos.y;return{x:Math.max(Math.min(realx,obj.width-1),0)/scale,y:Math.max(Math.min(realy,obj.height-1),0)/scale,realx:realx/scale,realy:realy/scale}};Util.addEvent=function(obj,evType,fn){if(obj.attachEvent)return obj.attachEvent("on"+evType,fn);if(obj.addEventListener){obj.addEventListener(evType,fn,!1);return!0}throw"Handler could not be attached"};Util.removeEvent=function(obj,evType,fn){if(obj.detachEvent)return obj.detachEvent("on"+evType,fn);if(obj.removeEventListener){obj.removeEventListener(evType,fn,!1);return!0}throw"Handler could not be removed"};Util.stopEvent=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0;e.preventDefault?e.preventDefault():e.returnValLine truncated
|
||||
/*!
|
||||
* This DES class has been extracted from package Acme.Crypto for use in VNC.
|
||||
* The unnecessary odd parity code has been removed.
|
||||
*
|
||||
* These changes are:
|
||||
* Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* DesCipher - the DES encryption method
|
||||
*
|
||||
* The meat of this code is by Dave Zimmerman <dzimm@widget.com>, and is:
|
||||
*
|
||||
* Copyright (c) 1996 Widget Workshop, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
|
||||
* without fee is hereby granted, provided that this copyright notice is kept
|
||||
* intact.
|
||||
*
|
||||
* WIDGET WORKSHOP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
|
||||
* OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WIDGET WORKSHOP SHALL NOT BE LIABLE
|
||||
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
|
||||
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
|
||||
*
|
||||
* THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
|
||||
* CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
|
||||
* PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
|
||||
* NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
|
||||
* SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
|
||||
* SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
|
||||
* PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). WIDGET WORKSHOP
|
||||
* SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
|
||||
* HIGH RISK ACTIVITIES.
|
||||
*
|
||||
*
|
||||
* The rest is:
|
||||
*
|
||||
* Copyright (C) 1996 by Jef Poskanzer <jef@acme.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Visit the ACME Labs Java page for up-to-date versions of this and other
|
||||
* fine Java utilities: http://www.acme.com/java/
|
||||
*/
|
||||
function DES(passwd){var a,b,c,d,e,f,SP1,SP2,SP3,SP4,SP5,SP6,SP7,SP8,PC2=[13,16,10,23,0,4,2,27,14,5,20,9,22,18,11,3,25,7,15,6,26,19,12,1,40,51,30,36,46,54,29,39,50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31],totrot=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],keys=[];SP1=[(c=(a=65536)|(b=1<<24))|(e=1024),0,0|a,c|(f=(d=4)|e),c|d,a|f,0|d,0|a,0|e,c|e,c|f,0|e,b|f,c|d,0|b,0|d,0|f,b|e,b|e,a|e,a|e,0|c,0|c,b|f,a|d,b|d,b|d,a|d,0,0|f,a|f,0|b,0|a,c|f,0|d,0|c,c|e,0|b,0|b,0|e,c|d,0|a,a|e,b|d,0|e,0|d,b|f,a|f,c|f,a|d,0|c,b|f,b|d,0|f,a|f,c|e,0|f,b|e,b|e,0,a|d,a|e,0,c|d];SP2=[(c=(a=1<<20)|(b=1<<31))|(f=(d=32)|(e=32768)),b|e,0|e,a|f,0|a,0|d,c|d,b|f,b|d,c|f,c|e,0|b,b|e,0|a,0|d,c|d,a|e,a|d,b|f,0,0|b,0|e,a|f,0|c,a|d,b|d,0,a|e,0|f,c|e,0|c,0|f,0,a|f,c|d,0|a,b|f,0|c,c|e,0|e,0|c,b|e,0|d,c|f,a|f,0|d,0|e,0|b,0|f,c|e,0|a,b|d,a|d,b|f,b|d,a|d,a|e,0,b|e,0|f,0|b,c|d,c|f,a|e];SP3=[0|(f=(d=8)|(e=512)),(c=(a=1<<17)|(b=1<<27))|e,0,c|d,b|e,0,a|f,b|e,a|d,b|d,b|d,0|a,c|f,a|d,0|c,0|f,0|b,0|d,c|e,0|e,a|e,0|c,c|d,a|f,b|f,a|e,0|a,b|f,0|d,c|f,0|e,0|b,c|e,0|b,a|d,0|f,0|a,c|e,b|e,0,0|e,a|d,c|f,b|e,b|d,0|e,0,c|d,b|f,0|a,0|b,c|f,0|d,a|f,a|e,b|d,0|c,b|f,0|f,0|c,a|f,0|d,c|d,a|e];SP4=[(c=(a=8192)|(b=1<<23))|(d=1),a|(f=d|(e=128)),a|f,0|e,c|e,b|f,b|d,a|d,0,0|c,0|c,c|f,0|f,0,b|e,b|d,0|d,0|a,0|b,c|d,0|e,0|b,a|d,a|e,b|f,0|d,a|e,b|e,0|a,c|e,c|f,0|f,b|e,b|d,0|c,c|f,0|f,0,0,0|c,a|e,b|e,b|f,0|d,c|d,a|f,a|f,0|e,c|f,0|f,0|d,0|a,b|d,a|d,c|e,b|f,a|d,a|e,0|b,c|d,0|e,0|b,0|a,c|e];SP5=[0|(d=256),(a=1<<25)|(f=d|(e=1<<19)),a|e,(c=a|(b=1<<30))|d,0|e,0|d,0|b,a|e,b|f,0|e,a|d,b|f,c|d,c|e,0|f,0|b,0|a,b|e,b|e,0,b|d,c|f,c|f,a|d,c|e,b|d,0,0|c,a|f,0|a,0|c,0|f,0|e,c|d,0|d,0|a,0|b,a|e,c|d,b|f,a|d,0|b,c|e,a|f,b|f,0|d,0|a,c|e,c|f,0|f,0|c,c|f,a|e,0,b|e,0|c,0|f,a|d,b|d,0|e,0,b|e,a|f,b|d];SP6=[(b=1<<29)|(d=16),0|(c=(a=1<<22)|b),0|(e=16384),c|(f=d|e),0|c,0|d,c|f,0|a,b|e,a|f,0|a,b|d,a|d,b|e,0|b,0|f,0,a|d,b|f,0|e,a|e,b|f,0|d,c|d,c|d,0,a|f,c|e,0|f,a|e,c|e,0|b,b|e,0|d,c|d,a|e,c|f,0|a,0|f,b|d,0|a,b|e,0|b,0|f,b|d,c|f,a|e,0|c,a|f,c|e,0,c|d,0|d,0|e,0|c,a|f,0|e,a|d,b|f,0,c|e,0|b,a|d,b|f];SP7=[0|(a=1<<21),(c=a|(b=1<<26))|(d=2),b|(f=d|(e=2048)),0,0|e,b|f,a|f,c|e,c|f,0|a,0,b|d,0|d,0|b,c|d,0|f,b|e,a|f,a|d,b|e,b|d,0|c,c|e,a|d,0|c,0|e,0|f,c|f,a|e,0|d,0|b,a|e,0|b,a|e,0|a,b|f,b|f,c|d,c|d,0|d,a|d,0|b,b|e,0|a,c|e,0|f,a|f,c|e,0|f,b|d,c|f,0|c,a|e,0,0|d,c|f,0,a|f,0|c,0|e,b|d,b|e,0|e,a|d];SP8=[(b=1<<28)|(f=(d=64)|(e=4096)),0|e,0|(a=1<<18),(c=a|b)|f,0|b,b|f,0|d,0|b,a|d,0|c,c|f,a|e,c|e,a|f,0|e,0|d,0|c,b|d,b|e,0|f,a|e,a|d,c|d,c|e,0|f,0,0,c|d,b|d,b|e,a|f,0|a,a|f,0|a,c|e,0|e,0|d,c|d,0|e,a|f,b|e,0|d,b|d,0|c,c|d,0|b,0|a,b|f,0,c|f,a|d,b|d,0|c,b|e,b|f,0,c|f,a|e,a|e,0|f,0|f,a|d,0|b,c|e];function enc8(text){var fval,l,r,x,i=0,b=text.slice(),keysi=0;l=b[i++]<<24|b[i++]<<16|b[i++]<<8|b[i++];r=b[i++]<<24|b[i++]<<16|b[i++]<<8|b[i++];r^=x=252645135&(l>>>4^r);r^=x=65535&((l^=x<<4)>>>16^r);r^=(x=858993459&(r>>>2^(l^=x<<16)))<<2;r=(r^=(x=16711935&(r>>>8^(l^=x)))<<8)<<1|r>>>31&1;r^=x=2863311530&((l^=x)^r);l=(l^=x)<<1|l>>>31&1;for(i=0;i<8;++i){x=r<<28|r>>>4;x^=keys[keysi++];fval=SP7[63&x];fval|=SP5[x>>>8&63];fval|=SP3[x>>>16&63];fval|=SP1[x>>>24&63];x=r^keys[keysi++];fval|=SP8[63&x];fval|=SP6[x>>>8&63];fval|=SP4[x>>>16&63];x=(l^=fval|=SP2[x>>>24&63])<<28|l>>>4;x^=keys[keysi++];fval=SP7[63&x];fval|=SP5[x>>>8&63];fval|=SP3[x>>>16&63];fval|=SP1[x>>>24&63];x=l^keys[keysi++];fval|=SP8[63&x];fval|=SP6[x>>>8&63];fval|=SP4[x>>>16&63];r^=fval|=SP2[x>>>24&63]}r=r<<31|r>>>1;r^=x=2863311530&(l^r);r^=x=16711935&((l=(l^=x)<<31|l>>>1)>>>8^r);r^=x=858993459&((l^=x<<8)>>>2^r);r^=(x=65535&(r>>>16^(l^=x<<2)))<<16;x=[r^=(x=252645135&(r>>>4^(l^=x)))<<4,l^=x];for(i=0;i<8;i++){b[i]=(x[i>>>2]>>>8*(3-i%4))%256;b[i]<0&&(b[i]+=256)}return b}(function(keyBlock){var i,j,l,m,n,o,raw0,raw1,rawi,KnLi,pc1m=[],pcr=[],kn=[];for(j=0,l=56;j<56;++j,l-=8){m=7&(l+=l<-5?65:l<-3?31:l<-1?63:27===l?35:0);pc1m[j]=0!=(keyBlock[l>>>3]&1<<m)?1:0}for(i=0;i<16;++i){n=1+(m=i<<1);kn[m]=kn[n]=0;for(o=28;o<59;o+=28)for(j=o-28;j<o;++j){l=j+totrot[i];pcr[j]=l<o?pc1m[l]:pc1m[l-28]}for(j=0;j<24;++j){0!==pcr[PC2[j]]&&(kn[m]|=1<<23-j);0!==pcr[PC2[j+24]]&&(kn[n]|=1<<23-j)}}for(i=0,rawi=0,KnLi=0;i<16;++i){raw0=kn[rawi++];raw1=kn[rawi++];keys[KnLi]=(16515072&raw0)<<6;keys[KnLi]|=(4032&raw0)<<10;keys[KnLi]|=(16515072&raw1)>>>10;keys[KnLi]|=(4032&raw1)>>>6;++KnLi;keys[KnLi]=(258048&raw0)<<12;keys[KnLi]|=(63&raw0)<<16;keys[KnLi]|=(258048&raw1)>>>4;keys[KnLi]|=63&raw1;++KnLi}})(passwd);return{encrypt:function(t){return enc8(t.slice(0,8)).concat(enc8(t.slice(8,16)))}}}function Display(defaults){var rgbImageData,bgrxImageData,cmapImageData,setFillColor,rescale,scan_renderQ,that={},conf={},c_ctx=null,renderQ=[],fb_width=0,fb_height=0,viewport={x:0,y:0,w:0,h:0},cleanRect={x1:0,y1:0,x2:-1,y2:-1},c_prevStyle="",tile=null,tile16x16=null,tile_x=0,tile_y=0;Util.conf_defaults(conf,that,defaults,[["target","wo","dom",null,"Canvas element for rendering"],["context","ro","raw",null,"Canvas 2D context for rendering (read-only)"],["logo","rw","raw",null,'Logo to display when cleared: {"width": width, "height": hLine truncated
|
||||
/*!
|
||||
* JSUnzip
|
||||
*
|
||||
* Copyright (c) 2011 by Erik Moller
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This software is provided 'as-is', without any express
|
||||
* or implied warranty. In no event will the authors be
|
||||
* held liable for any damages arising from the use of
|
||||
* this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software
|
||||
* for any purpose, including commercial applications,
|
||||
* and to alter it and redistribute it freely, subject to
|
||||
* the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be
|
||||
* misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this
|
||||
* software in a product, an acknowledgment in
|
||||
* the product documentation would be appreciated
|
||||
* but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked
|
||||
* as such, and must not be misrepresented as
|
||||
* being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from
|
||||
* any source distribution.
|
||||
*/
|
||||
function JSUnzip(){this.getInt=function(offset,size){switch(size){case 4:return(255&this.data.charCodeAt(offset+3))<<24|(255&this.data.charCodeAt(offset+2))<<16|(255&this.data.charCodeAt(offset+1))<<8|255&this.data.charCodeAt(offset+0);case 2:return(255&this.data.charCodeAt(offset+1))<<8|255&this.data.charCodeAt(offset+0);default:return 255&this.data.charCodeAt(offset)}};this.getDOSDate=function(dosdate,dostime){hour=dostime>>11&31;return new Date(1980+(dosdate>>9&127),(dosdate>>5&15)-1,31&dosdate,hour,dostime>>5&63,2*(31&dostime))};this.open=function(data){this.data=data;this.files=[];if(this.data.length<22)return{status:!1,error:"Invalid data"};for(var endOfCentralDirectory=this.data.length-22;endOfCentralDirectory>=0&&101010256!=this.getInt(endOfCentralDirectory,4);)--endOfCentralDirectory;if(endOfCentralDirectory<0)return{status:!1,error:"Invalid data"};if(0!=this.getInt(endOfCentralDirectory+4,2)||0!=this.getInt(endOfCentralDirectory+6,2))return{status:!1,error:"No multidisk support"};var entriesInThisDisk=this.getInt(endOfCentralDirectory+8,2),centralDirectoryOffset=this.getInt(endOfCentralDirectory+16,4),globalCommentLength=this.getInt(endOfCentralDirectory+20,2);this.comment=this.data.slice(endOfCentralDirectory+22,endOfCentralDirectory+22+globalCommentLength);for(var fileOffset=centralDirectoryOffset,i=0;i<entriesInThisDisk;++i){if(33639248!=this.getInt(fileOffset+0,4))return{status:!1,error:"Invalid data"};if(this.getInt(fileOffset+6,2)>20)return{status:!1,error:"Unsupported version"};if(1&this.getInt(fileOffset+8,2))return{status:!1,error:"Encryption not implemented"};var compressionMethod=this.getInt(fileOffset+10,2);if(0!=compressionMethod&&8!=compressionMethod)return{status:!1,error:"Unsupported compression method"};var lastModFileTime=this.getInt(fileOffset+12,2),lastModFileDate=this.getInt(fileOffset+14,2),lastModifiedDate=this.getDOSDate(lastModFileDate,lastModFileTime),compressedSize=(this.getInt(fileOffset+16,4),this.getInt(fileOffset+20,4)),uncompressedSize=this.getInt(fileOffset+24,4),fileNameLength=this.getInt(fileOffset+28,2),extraFieldLength=this.getInt(fileOffset+30,2),fileCommentLength=this.getInt(fileOffset+32,2),relativeOffsetOfLocalHeader=this.getInt(fileOffset+42,4),fileName=this.data.slice(fileOffset+46,fileOffset+46+fileNameLength),fileComment=this.data.slice(fileOffset+46+fileNameLength+extraFieldLength,fileOffset+46+fileNameLength+extraFieldLength+fileCommentLength);if(67324752!=this.getInt(relativeOffsetOfLocalHeader+0,4))return{status:!1,error:"Invalid data"};var localFileContent=relativeOffsetOfLocalHeader+30+this.getInt(relativeOffsetOfLocalHeader+26,2)+this.getInt(relativeOffsetOfLocalHeader+28,2);this.files[fileName]={fileComment:fileComment,compressionMethod:compressionMethod,compressedSize:compressedSize,uncompressedSize:uncompressedSize,localFileContent:localFileContent,lastModifiedDate:lastModifiedDate};fileOffset+=46+fileNameLength+extraFieldLength+fileCommentLength}return{status:!0}};this.read=function(fileName){var fileInfo=this.files[fileName];if(fileInfo){if(8==fileInfo.compressionMethod){tinf||(tinf=new TINF).init();var result=tinf.uncompress(this.data,fileInfo.localFileContent);return result.status==tinf.OK?{status:!0,data:result.data}:{status:!1,error:result.error}}return{status:!0,data:this.data.slice(fileInfo.localFileContent,fileInfo.localFileContent+fileInfo.uncompressedSize)}}return{status:!1,error:"File '"+fileName+"' doesn't exist in zip"}}}
|
||||
/*!
|
||||
* tinflate - tiny inflate
|
||||
*
|
||||
* Copyright (c) 2003 by Joergen Ibsen / Jibz
|
||||
* All Rights Reserved
|
||||
*
|
||||
* http://www.ibsensoftware.com/
|
||||
*
|
||||
* This software is provided 'as-is', without any express
|
||||
* or implied warranty. In no event will the authors be
|
||||
* held liable for any damages arising from the use of
|
||||
* this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software
|
||||
* for any purpose, including commercial applications,
|
||||
* and to alter it and redistribute it freely, subject to
|
||||
* the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be
|
||||
* misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this
|
||||
* software in a product, an acknowledgment in
|
||||
* the product documentation would be appreciated
|
||||
* but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked
|
||||
* as such, and must not be misrepresented as
|
||||
* being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from
|
||||
* any source distribution.
|
||||
*
|
||||
*
|
||||
* tinflate javascript port by Erik Moller in May 2011.
|
||||
* emoller@opera.com
|
||||
*
|
||||
* read_bits() patched by mike@imidio.com to allow
|
||||
* reading more then 8 bits (needed in some zlib streams)
|
||||
*/
|
||||
function TINF(){this.OK=0;this.DATA_ERROR=-3;this.WINDOW_SIZE=32768;this.TREE=function(){this.table=new Array(16);this.trans=new Array(288)};this.DATA=function(that){this.source="";this.sourceIndex=0;this.tag=0;this.bitcount=0;this.dest=[];this.history=[];this.ltree=new that.TREE;this.dtree=new that.TREE};this.sltree=new this.TREE;this.sdtree=new this.TREE;this.length_bits=new Array(30);this.length_base=new Array(30);this.dist_bits=new Array(30);this.dist_base=new Array(30);this.clcidx=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];this.build_bits_base=function(bits,base,delta,first){var i,sum;for(i=0;i<delta;++i)bits[i]=0;for(i=0;i<30-delta;++i)bits[i+delta]=Math.floor(i/delta);for(sum=first,i=0;i<30;++i){base[i]=sum;sum+=1<<bits[i]}};this.build_fixed_trees=function(lt,dt){var i;for(i=0;i<7;++i)lt.table[i]=0;lt.table[7]=24;lt.table[8]=152;lt.table[9]=112;for(i=0;i<24;++i)lt.trans[i]=256+i;for(i=0;i<144;++i)lt.trans[24+i]=i;for(i=0;i<8;++i)lt.trans[168+i]=280+i;for(i=0;i<112;++i)lt.trans[176+i]=144+i;for(i=0;i<5;++i)dt.table[i]=0;dt.table[5]=32;for(i=0;i<32;++i)dt.trans[i]=i};this.build_tree=function(t,lengths,loffset,num){var i,sum,offs=new Array(16);for(i=0;i<16;++i)t.table[i]=0;for(i=0;i<num;++i)t.table[lengths[loffset+i]]++;t.table[0]=0;for(sum=0,i=0;i<16;++i){offs[i]=sum;sum+=t.table[i]}for(i=0;i<num;++i)lengths[loffset+i]&&(t.trans[offs[lengths[loffset+i]]++]=i)};this.getbit=function(d){var bit;if(!d.bitcount--){d.tag=255&d.source[d.sourceIndex++];d.bitcount=7}bit=1&d.tag;d.tag>>=1;return bit};this.read_bits=function(d,num,base){if(!num)return base;var ret=function(source,bitcount,tag,idx,num){for(var val;bitcount<24;){tag|=(255&source[idx++])<<bitcount;bitcount+=8}val=tag&65535>>16-num;return[bitcount-=num,tag>>=num,idx,val]}(d.source,d.bitcount,d.tag,d.sourceIndex,num);d.bitcount=ret[0];d.tag=ret[1];d.sourceIndex=ret[2];return ret[3]+base};this.decode_symbol=function(d,t){for(;d.bitcount<16;){d.tag=d.tag|(255&d.source[d.sourceIndex++])<<d.bitcount;d.bitcount+=8}var sum=0,cur=0,len=0;do{cur=2*cur+((d.tag&1<<len)>>len);++len;sum+=t.table[len];cur-=t.table[len]}while(cur>=0);d.tag>>=len;d.bitcount-=len;return t.trans[sum+cur]};this.decode_trees=function(d,lt,dt){var hlit,hdist,hclen,i,num,length,code_tree=new this.TREE,lengths=new Array(320);hlit=this.read_bits(d,5,257);hdist=this.read_bits(d,5,1);hclen=this.read_bits(d,4,4);for(i=0;i<19;++i)lengths[i]=0;for(i=0;i<hclen;++i){var clen=this.read_bits(d,3,0);lengths[this.clcidx[i]]=clen}this.build_tree(code_tree,lengths,0,19);for(num=0;num<hlit+hdist;){var sym=this.decode_symbol(d,code_tree);switch(sym){case 16:var prev=lengths[num-1];for(length=this.read_bits(d,2,3);length;--length)lengths[num++]=prev;break;case 17:for(length=this.read_bits(d,3,3);length;--length)lengths[num++]=0;break;case 18:for(length=this.read_bits(d,7,11);length;--length)lengths[num++]=0;break;default:lengths[num++]=sym}}this.build_tree(lt,lengths,0,hlit);this.build_tree(dt,lengths,hlit,hdist)};this.inflate_block_data=function(d,lt,dt){for(var ddest=d.dest,ddestlength=ddest.length;;){var sym=this.decode_symbol(d,lt);if(256==sym)return this.OK;if(sym<256){ddest[ddestlength++]=sym;d.history.push(sym)}else{var length,dist,offs,i;sym-=257;length=this.read_bits(d,this.length_bits[sym],this.length_base[sym]);dist=this.decode_symbol(d,dt);if((offs=d.history.length-this.read_bits(d,this.dist_bits[dist],this.dist_base[dist]))<0)throw"Invalid zlib offset "+offs;for(i=offs;i<offs+length;++i){ddest[ddestlength++]=d.history[i];d.history.push(d.history[i])}}}};this.inflate_uncompressed_block=function(d){var length,i;if(d.bitcount>7){var overflow=Math.floor(d.bitcount/8);d.sourceIndex-=overflow;d.bitcount=0;d.tag=0}if((length=256*(length=d.source[d.sourceIndex+1])+d.source[d.sourceIndex])!=(65535&~(256*d.source[d.sourceIndex+3]+d.source[d.sourceIndex+2])))return this.DATA_ERROR;d.sourceIndex+=4;for(i=length;i;--i){d.history.push(d.source[d.sourceIndex]);d.dest[d.dest.length]=d.source[d.sourceIndex++]}d.bitcount=0;return this.OK};this.inflate_fixed_block=function(d){return this.inflate_block_data(d,this.sltree,this.sdtree)};this.inflate_dynamic_block=function(d){this.decode_trees(d,d.ltree,d.dtree);return this.inflate_block_data(d,d.ltree,d.dtree)};this.init=function(){this.build_fixed_trees(this.sltree,this.sdtree);this.build_bits_base(this.length_bits,this.length_base,4,3);this.build_bits_base(this.dist_bits,this.dist_base,2,1);this.length_bits[28]=0;this.length_base[28]=258;this.reset()};this.reset=function(){this.d=new this.DATA(this);delete this.header};this.uncompress=function(source,offset){var bfinal,d=this.d;d.source=source;d.sourceIndex=offset;d.bitcount=0;d.dest=[];void 0===this.header&&(this.header=this.read_bits(d,16,0));do{var res;bfinal=this.getbit(d);switch(this.read_bits(d,2,0)){case 0:res=this.inflate_uncompressed_block(d);break;case 1:res=this.inflate_fixed_block(d);break;case 2:res=this.inflate_dynamic_block(d);break;default:return{status:this.DATA_ERROR}}if(res!=this.OK)retuLine truncated
|
||||
/*!
|
||||
* Websock: high-performance binary WebSockets
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Licensed under MPL 2.0 (see https://github.com/novnc/noVNC/blob/master/LICENSE.txt)
|
||||
*/
|
||||
window.Websock_native=!0;window.MozWebSocket&&(window.WebSocket=window.MozWebSocket);function Websock(){var api={},websocket=null,mode="base64",rQ=[],rQi=0,sQ=[],eventHandlers={message:function(){},open:function(){},close:function(){},error:function(){}},test_mode=!1;function get_sQ(){return sQ}function get_rQ(){return rQ}function get_rQi(){return rQi}function set_rQi(val){rQi=val}function rQlen(){return rQ.length-rQi}function rQpeek8(){return rQ[rQi]}function rQshift8(){return rQ[rQi++]}function rQunshift8(num){0===rQi?rQ.unshift(num):rQ[rQi-=1]=num}function rQshift16(){return(rQ[rQi++]<<8)+rQ[rQi++]}function rQshift32(){return(rQ[rQi++]<<24)+(rQ[rQi++]<<16)+(rQ[rQi++]<<8)+rQ[rQi++]}function rQshiftStr(len){void 0===len&&(len=rQlen());var arr=rQ.slice(rQi,rQi+len);rQi+=len;return String.fromCharCode.apply(null,arr)}function rQshiftBytes(len){void 0===len&&(len=rQlen());rQi+=len;return rQ.slice(rQi-len,rQi)}function rQslice(start,end){return end?rQ.slice(rQi+start,rQi+end):rQ.slice(rQi+start)}function rQwait(msg,num,goback){if(rQ.length-rQi<num){if(goback){if(rQi<goback)throw"rQwait cannot backup "+goback+" bytes";rQi-=goback}return!0}return!1}function flush(){websocket.bufferedAmount;if(websocket.bufferedAmount<api.maxBufferedAmount){if(sQ.length>0){websocket.send("binary"===mode?new Uint8Array(sQ).buffer:Base64.encode(sQ));sQ=[]}return!0}Util.Info("Delaying send, bufferedAmount: "+websocket.bufferedAmount);return!1}function send(arr){sQ=sQ.concat(arr);return flush()}function send_string(str){api.send(str.split("").map((function(chr){return chr.charCodeAt(0)})))}function recv_message(e){try{(function(data){if("binary"===mode)for(var u8=new Uint8Array(data),i=0;i<u8.length;i++)rQ.push(u8[i]);else rQ=rQ.concat(Base64.decode(data,0))})(e.data);if(rQlen()>0){eventHandlers.message();if(rQ.length>1e4){rQ=rQ.slice(rQi);rQi=0}}}catch(exc){void 0!==exc.stack?Util.Warn("recv_message, caught exception: "+exc.stack):void 0!==exc.description?Util.Warn("recv_message, caught exception: "+exc.description):Util.Warn("recv_message, caught exception:"+exc);void 0!==exc.name?eventHandlers.error(exc.name+": "+exc.message):eventHandlers.error(exc)}}function on(evt,handler){eventHandlers[evt]=handler}function init(protocols){rQ=[];rQi=0;sQ=[];websocket=null;"Uint8Array"in window&&Uint8Array.prototype;void 0===protocols&&(protocols=["binary","base64"]);return protocols}function open(uri,protocols){protocols=init(protocols);if(test_mode)websocket={};else{websocket=new WebSocket(uri,protocols);protocols.indexOf("binary")>=0&&(websocket.binaryType="arraybuffer")}websocket.onmessage=recv_message;websocket.onopen=function(){if(websocket.protocol){mode=websocket.protocol;Util.Info("Server chose sub-protocol: "+websocket.protocol)}else{mode="base64";Util.Error("Server select no sub-protocol!: "+websocket.protocol)}eventHandlers.open()};websocket.onclose=function(e){eventHandlers.close(e)};websocket.onerror=function(e){eventHandlers.error(e)}}function close(){if(websocket){if(websocket.readyState===WebSocket.OPEN||websocket.readyState===WebSocket.CONNECTING){Util.Info("Closing WebSocket connection");websocket.close()}websocket.onmessage=function(){}}}function testMode(override_send,data_mode){test_mode=!0;mode=data_mode;api.send=override_send;api.close=function(){};return recv_message}return function(){api.maxBufferedAmount=200;api.get_sQ=get_sQ;api.get_rQ=get_rQ;api.get_rQi=get_rQi;api.set_rQi=set_rQi;api.rQlen=rQlen;api.rQpeek8=rQpeek8;api.rQshift8=rQshift8;api.rQunshift8=rQunshift8;api.rQshift16=rQshift16;api.rQshift32=rQshift32;api.rQshiftStr=rQshiftStr;api.rQshiftBytes=rQshiftBytes;api.rQslice=rQslice;api.rQwait=rQwait;api.flush=flush;api.send=send;api.send_string=send_string;api.on=on;api.init=init;api.open=open;api.close=close;api.testMode=testMode;return api}()}var $D,WebUtil={};window.$D||(window.$D=function(id){return document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers?document.layers[id]:void 0});WebUtil.init_logging=function(level){Util._log_level=void 0!==level?level:(document.location.href.match(/logging=([A-Za-z0-9\._\-]*)/)||["",Util._log_level])[1];Util.init_logging()};
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,36 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
|
||||
_.-;;-._
|
||||
'-..-'| || | Made with love & sarcasm by Jake Jarvis.
|
||||
'-..-'|_.-;;-._| https://jarv.is/
|
||||
'-..-'| || | https://github.com/jakejarvis
|
||||
'-..-'|_.-''-._|
|
||||
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>y2k.lol – Powered by Windows Me 💾</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="description" content="My first website on a Windows Me-powered time machine. You've been warned.">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="canonical" href="https://y2k.lol/">
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="display"></canvas>
|
||||
<a class="github" href="https://github.com/jakejarvis/y2k" title="GitHub Repository" target="_blank" rel="noopener">
|
||||
<svg viewBox="0 0 16 16" width="32" height="32"><path fill="#222222" d="M8 0a8 8 0 00-2.5 15.6c.4 0 .5-.2.5-.4v-1.5c-2 .4-2.5-.5-2.7-1 0-.1-.5-.9-.8-1-.3-.2-.7-.6 0-.6.6 0 1 .6 1.2.8.7 1.2 1.9 1 2.4.7 0-.5.2-.9.5-1-1.8-.3-3.7-1-3.7-4 0-.9.3-1.6.8-2.2 0-.2-.3-1 .1-2 0 0 .7-.3 2.2.7a7.4 7.4 0 014 0c1.5-1 2.2-.8 2.2-.8.5 1.1.2 2 .1 2.1.5.6.8 1.3.8 2.2 0 3-1.9 3.7-3.6 4 .3.2.5.7.5 1.4v2.2c0 .2.1.5.5.4A8 8 0 0016 8a8 8 0 00-8-8z"/></svg>
|
||||
</a>
|
||||
<script src="app.js"></script>
|
||||
<script>
|
||||
if (window.WebSocket) {
|
||||
var display = document.getElementById("display");
|
||||
var rfb = new RFB({ target: display, encrypt: true });
|
||||
rfb.connect("sandbox.y2k.lol", 443);
|
||||
}
|
||||
</script>
|
||||
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js" data-skip-dnt="true"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,32 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
margin: 25px auto;
|
||||
|
||||
/* VM resolution is 800x600 */
|
||||
width: 800px;
|
||||
height: 600px;
|
||||
|
||||
/* fix fuzziness: https://stackoverflow.com/a/13492784 */
|
||||
image-rendering: optimizeSpeed;
|
||||
image-rendering: -moz-crisp-edges;
|
||||
image-rendering: -o-crisp-edges;
|
||||
image-rendering: -webkit-optimize-contrast;
|
||||
image-rendering: crisp-edges;
|
||||
-ms-interpolation-mode: nearest-neighbor;
|
||||
}
|
||||
a.github {
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
bottom: 16px;
|
||||
text-decoration: none;
|
||||
}
|
||||
a.github, a.github svg {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 469 KiB |
Whitespace-only changes.
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
worker
|
||||
@@ -0,0 +1,57 @@
|
||||
import { getAssetFromKV, mapRequestToAsset } from '@cloudflare/kv-asset-handler'
|
||||
|
||||
/**
|
||||
* The DEBUG flag will do two things that help during development:
|
||||
* 1. we will skip caching on the edge, which makes it easier to
|
||||
* debug.
|
||||
* 2. we will return an error message on exception in your Response rather
|
||||
* than the default 404.html page.
|
||||
*/
|
||||
const DEBUG = false
|
||||
|
||||
addEventListener('fetch', event => {
|
||||
try {
|
||||
event.respondWith(handleEvent(event))
|
||||
} catch (e) {
|
||||
if (DEBUG) {
|
||||
return event.respondWith(
|
||||
new Response(e.message || e.toString(), {
|
||||
status: 500,
|
||||
}),
|
||||
)
|
||||
}
|
||||
event.respondWith(new Response('Internal Error', { status: 500 }))
|
||||
}
|
||||
})
|
||||
|
||||
async function handleEvent(event) {
|
||||
const url = new URL(event.request.url)
|
||||
let options = {
|
||||
cacheControl: {
|
||||
edgeTTL: 60 * 60 * 1, // 1 hour
|
||||
browserTTL: 60 * 60 * 1, // 1 hour
|
||||
bypassCache: false,
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (DEBUG) {
|
||||
// customize caching
|
||||
options.cacheControl.bypassCache = true
|
||||
}
|
||||
return await getAssetFromKV(event, options)
|
||||
} catch (e) {
|
||||
// if an error is thrown try to serve the asset at 404.html
|
||||
if (!DEBUG) {
|
||||
try {
|
||||
let notFoundResponse = await getAssetFromKV(event, {
|
||||
mapRequestToAsset: req => new Request(`${new URL(req.url).origin}/404.html`, req),
|
||||
})
|
||||
|
||||
return new Response(notFoundResponse.body, { ...notFoundResponse, status: 404 })
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return new Response(e.message || e.toString(), { status: 500 })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "worker",
|
||||
"version": "1.0.0",
|
||||
"description": "A template for kick starting a Cloudflare Workers project",
|
||||
"main": "index.js",
|
||||
"author": "Ashley Lewis <ashleymichal@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@cloudflare/kv-asset-handler": "^0.0.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
name = "y2k"
|
||||
type = "webpack"
|
||||
account_id = "bd1a636a30a817137ce1e91c9e407373"
|
||||
zone_id = "92e2ec634800f776ec4f3e983491c349"
|
||||
route = "y2k.lol/*"
|
||||
# workers_dev = true
|
||||
|
||||
[site]
|
||||
bucket = "public"
|
||||
entry-point = "workers-site"
|
||||
Reference in new issue
Block a user