diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 90a3b00..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Deploy - -on: - push: - branches: - - main - -jobs: - deploy: - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[skip ci]')" - env: - CF_ZONE_ID: "8a79e5c61c0a7033d7b0eca176665cd1" - CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 12 - - run: | - mkdir -p $HOME/.wrangler - chmod -R 770 $HOME/.wrangler - - run: npm install --global @cloudflare/wrangler - - run: wrangler publish - - run: | - curl -X POST "https://api.cloudflare.com/client/v4/zones/$CF_ZONE_ID/purge_cache" \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $CF_API_TOKEN" \ - --data '{"purge_everything":true}' diff --git a/README.md b/README.md index c5f4609..8f9a800 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ -# 💾 [Y2K Land](https://y2k.land/) [![Uptime Robot status](https://img.shields.io/uptimerobot/status/m785127956-49458d510e68142930db872d?logo=windows%2095)](https://y2k.land/) [![Uptime Robot ratio (7 days)](https://img.shields.io/uptimerobot/ratio/7/m785127956-49458d510e68142930db872d?color=%23638ebd&logo=zeit)](https://status.jrvs.io/785127956) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/jakejarvis/y2k/Deploy?color=orange&logo=github)](https://github.com/jakejarvis/y2k/actions?query=workflow%3ADeploy) +# 💾 [Y2K Sandbox](https://y2k.jarv.is/) [![Uptime Robot status](https://img.shields.io/uptimerobot/status/m785127956-49458d510e68142930db872d?logo=windows%2095)](https://y2k.jarv.is/) [![Uptime Robot ratio (7 days)](https://img.shields.io/uptimerobot/ratio/7/m785127956-49458d510e68142930db872d?color=%23638ebd&logo=zeit)](https://status.jrvs.io/785127956) -Nostalgic time machine powered by on-demand Windows Me® VMs, [my first website](https://jarv.is/y2k/), and quarantine boredom. 📟 +Nostalgic time machine powered by on-demand Windows Me® VMs, [my first website](https://github.com/jakejarvis/my-first-website), and quarantine boredom. 📟 + +This branch contains the backend scripts and Windows Me container. The frontend website code is in [the `gh-pages` branch](https://github.com/jakejarvis/y2k/tree/gh-pages). [**📝 Read the blog post here.**](https://jarv.is/notes/y2k-land/) -

+

## Requirements diff --git a/backend/container/.gitignore b/container/.gitignore similarity index 100% rename from backend/container/.gitignore rename to container/.gitignore diff --git a/backend/container/Dockerfile b/container/Dockerfile similarity index 97% rename from backend/container/Dockerfile rename to container/Dockerfile index 2dd2751..d63e9f8 100644 --- a/backend/container/Dockerfile +++ b/container/Dockerfile @@ -2,7 +2,7 @@ FROM docker.io/ubuntu:20.04 LABEL maintainer="Jake Jarvis " LABEL repository="https://github.com/jakejarvis/y2k" -LABEL homepage="https://y2k.land/" +LABEL homepage="https://y2k.jarv.is/" ARG DEBIAN_FRONTEND=noninteractive diff --git a/backend/container/bin/boot.rb b/container/bin/boot.rb similarity index 100% rename from backend/container/bin/boot.rb rename to container/bin/boot.rb diff --git a/backend/container/hdd/.gitkeep b/container/hdd/.gitkeep similarity index 100% rename from backend/container/hdd/.gitkeep rename to container/hdd/.gitkeep diff --git a/backend/container/make.sh b/container/make.sh similarity index 100% rename from backend/container/make.sh rename to container/make.sh diff --git a/public/404.html b/public/404.html deleted file mode 100644 index 36b3491..0000000 --- a/public/404.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - -Page Not Found - - - -
-

Windows

-

A fatal exception 404_NOT_FOUND has occured at 0x69ABC420. The current application will be terminated.

- -

  Click here to return to Windows _

-
- - diff --git a/public/app.js b/public/app.js deleted file mode 100644 index 2595079..0000000 --- a/public/app.js +++ /dev/null @@ -1,160 +0,0 @@ -/*! - * 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={},addFunc=function(cl,name,func){cl.prototype[name]||Object.defineProperty(cl.prototype,name,{enumerable:!1,value:func})};addFunc(Array,"push8",(function(num){this.push(255&num)}));addFunc(Array,"push16",(function(num){this.push(num>>8&255,255&num)}));addFunc(Array,"push32",(function(num){this.push(num>>24&255,num>>16&255,num>>8&255,255&num)}));addFunc(Array,"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>>0,from=Number(arguments[1])||0;(from=from<0?Math.ceil(from):Math.floor(from))<0&&(from+=len);for(;from>2];result+=toBase64Table[((3&data[i])<<4)+(data[i+1]>>4)];result+=toBase64Table[((15&data[i+1])<<2)+(data[i+2]>>6)];result+=toBase64Table[63&data[i+2]]}if(2===lengthpad){result+=toBase64Table[data[j=length-lengthpad]>>2];result+=toBase64Table[((3&data[j])<<4)+(data[j+1]>>4)];result+=toBase64Table[(15&data[j+1])<<2];result+=toBase64Table[64]}else if(1===lengthpad){result+=toBase64Table[data[j=length-lengthpad]>>2];result+=toBase64Table[(3&data[j])<<4];result+=toBase64Table[64];result+=toBase64Table[64]}return result},toBinaryTable:[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1],decode:function(data,offset){offset=void 0!==offset?offset:0;var result,result_length,idx,i,c,padding,toBinaryTable=Base64.toBinaryTable,base64Pad=Base64.base64Pad,leftbits=0,leftdata=0,data_length=data.indexOf("=")-offset;data_length<0&&(data_length=data.length-offset);result_length=3*(data_length>>2)+Math.floor(data_length%4/1.5);result=new Array(result_length);for(idx=0,i=offset;i=8){leftbits-=8;padding||(result[idx++]=leftdata>>leftbits&255);leftdata&=(1<, 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 . 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<>>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": height, "data": data}'],["true_color","rw","bool",!0,"Use true-color pixel data"],["colourMap","rw","arr",[],"Colour map array (when not true-color)"],["scale","rw","float",1,"Display area scale factor 0.0 - 1.0"],["viewport","rw","bool",!1,"Use a viewport set with viewportChange()"],["width","rw","int",null,"Display area width"],["height","rw","int",null,"Display area height"],["render_mode","ro","str","","Canvas rendering mode (read-only)"],["prefer_js","rw","str",null,"Prefer Javascript over canvas methods"],["cursor_uri","rw","raw",null,"Can we render cursor using data URI"]]);that.get_context=function(){return c_ctx};that.set_scale=function(scale){rescale(scale)};that.set_width=function(val){that.resize(val,fb_height)};that.get_width=function(){return fb_width};that.set_height=function(val){that.resize(fb_width,val)};that.get_height=function(){return fb_height};rescale=function(factor){var c,tp,x,y,properties=["transform","WebkitTransform","MozTransform",null];c=conf.target;tp=properties.shift();for(;tp&&void 0===c.style[tp];)tp=properties.shift();if(null!==tp){void 0===factor?factor=conf.scale:factor>1?factor=1:factor<.1&&(factor=.1);if(conf.scale!==factor){conf.scale=factor;x=c.width-c.width*factor;y=c.height-c.height*factor;c.style[tp]="scale("+conf.scale+") translate(-"+x+"px, -"+y+"px)"}}};setFillColor=function(color){var bgr,newStyle;if((newStyle="rgb("+(bgr=conf.true_color?color:conf.colourMap[color[0]])[2]+","+bgr[1]+","+bgr[0]+")")!==c_prevStyle){c_ctx.fillStyle=newStyle;c_prevStyle=newStyle}};that.viewportChange=function(deltaX,deltaY,width,height){var saveStyle,x1,y1,vx2,vy2,w,h,c=conf.target,v=viewport,cr=cleanRect,saveImg=null;if(!conf.viewport){deltaX=-v.w;deltaY=-v.h;width=fb_width;height=fb_height}void 0===deltaX&&(deltaX=0);void 0===deltaY&&(deltaY=0);void 0===width&&(width=v.w);void 0===height&&(height=v.h);width>fb_width&&(width=fb_width);height>fb_height&&(height=fb_height);if(v.w!==width||v.h!==height){widthv.x+width-1&&(cr.x2=v.x+width-1);v.w=width;heightv.y+height-1&&(cr.y2=v.y+height-1);v.h=height;v.w>0&&v.h>0&&c.width>0&&c.height>0&&(saveImg=c_ctx.getImageData(0,0,c.width=fb_width&&(deltaX-=vx2+deltaX-fb_width+1);v.y+deltaY<0&&(deltaY=-v.y);vy2+deltaY>=fb_height&&(deltaY-=vy2+deltaY-fb_height+1);if(0!==deltaX||0!==deltaY){v.x+=deltaX;vx2+=deltaX;v.y+=deltaY;vy2+=deltaY;v.x>cr.x1&&(cr.x1=v.x);vx2cr.y1&&(cr.y1=v.y);vy2=c.x2||c.y1>=c.y2)dirtyBoxes.push({x:v.x,y:v.y,w:v.w,h:v.h});else{v.xc.x2&&dirtyBoxes.push({x:c.x2+1,y:v.y,w:vx2-c.x2,h:v.h});v.yc.y2&&dirtyBoxes.push({x:c.x1,y:c.y2+1,w:c.x2-c.x1+1,h:vy2-c.y2})}cleanRect={x1:v.x,y1:v.y,x2:v.x+v.w-1,y2:v.y+v.h-1};return{cleanBox:cleanBox,dirtyBoxes:dirtyBoxes}};that.absX=function(x){return x+viewport.x};that.absY=function(y){return y+viewport.y};that.resize=function(width,height){c_prevStyle="";fb_width=width;fb_height=height;rescale(conf.scale);that.viewportChange()};that.clear=function(){if(conf.logo){that.resize(conf.logo.width,conf.logo.height);that.blitStringImage(conf.logo.data,0,0)}else{that.resize(640,20);c_ctx.clearRect(0,0,viewport.w,viewport.h)}renderQ=[]};that.fillRect=function(x,y,width,height,color){setFillColor(color);c_ctx.fillRect(x-viewport.x,y-viewport.y,width,height)};that.copyImage=function(old_x,old_y,new_x,new_y,w,h){var x1=old_x-viewport.x,y1=old_y-viewport.y,x2=new_x-viewport.x,y2=new_y-viewport.y;c_ctx.drawImage(conf.target,x1,y1,w,h,x2,y2,w,h)};that.startTile=function(x,y,width,height,color){var data,bgr,red,green,blue,i;tile_x=x;tile_y=y;data=(tile=16===width&&16===height?tile16x16:c_ctx.createImageData(width,height)).data;if(conf.prefer_js){red=(bgr=conf.true_color?color:conf.colourMap[color[0]])[2];green=bgr[1];blue=bgr[0];for(i=0;i0;){switch((a=renderQ[0]).type){case"copy":that.copyImage(a.old_x,a.old_y,a.x,a.y,a.width,a.height);break;case"fill":that.fillRect(a.x,a.y,a.width,a.height,a.color);break;case"blit":that.blitImage(a.x,a.y,a.width,a.height,a.data,0);break;case"blitRgb":that.blitRgbImage(a.x,a.y,a.width,a.height,a.data,0);break;case"img":a.img.complete?that.drawImage(a.img,a.x,a.y):ready=!1}ready&&(a=renderQ.shift())}renderQ.length>0&&requestAnimFrame(scan_renderQ)};that.changeCursor=function(pixels,mask,hotx,hoty,w,h){!1!==conf.cursor_uri?conf.true_color?changeCursor(conf.target,pixels,mask,hotx,hoty,w,h):changeCursor(conf.target,pixels,mask,hotx,hoty,w,h,conf.colourMap):Util.Warn("changeCursor called but no cursor data URI support")};that.defaultCursor=function(){conf.target.style.cursor="default"};return function(){var c,i,curDat,curSave;Util.Engine;if(!conf.target)throw"target must be set";if("string"==typeof conf.target)throw"target must be a DOM element";if(!(c=conf.target).getContext)throw"no getContext method";c_ctx||(c_ctx=c.getContext("2d"));that.clear();if(!("createImageData"in c_ctx))throw"Canvas does not support createImageData";conf.render_mode="canvas rendering";if(null===conf.prefer_js){Util.Info("Prefering javascript operations");conf.prefer_js=!0}tile16x16=c_ctx.createImageData(16,16);curDat=[];for(i=0;i<256;i+=1)curDat.push(255);try{curSave=c.style.cursor;changeCursor(conf.target,curDat,curDat,2,2,8,8);if(c.style.cursor){null===conf.cursor_uri&&(conf.cursor_uri=!0);Util.Info("Data URI scheme cursor supported")}else{null===conf.cursor_uri&&(conf.cursor_uri=!1);Util.Warn("Data URI scheme cursor not supported")}c.style.cursor=curSave}catch(exc2){Util.Error("Data URI scheme cursor test exception: "+exc2);conf.cursor_uri=!1}return that}()}function changeCursor(target,pixels,mask,hotx,hoty,w0,h0,cmap){var rgb,RGBsz,ANDsz,XORsz,url,idx,alpha,x,y,cur=[],w=w0,h=h0;h>8&255)};cur.push32le=function(num){this.push(255&num,num>>8&255,num>>16&255,num>>24&255)};RGBsz=w*h*4;XORsz=Math.ceil(w*h/8);ANDsz=Math.ceil(w*h/8);cur.push16le(0);cur.push16le(2);cur.push16le(1);cur.push(w);cur.push(h);cur.push(0);cur.push(0);cur.push16le(hotx);cur.push16le(hoty);cur.push32le(40+RGBsz+XORsz+ANDsz);cur.push32le(22);cur.push32le(40);cur.push32le(w);cur.push32le(2*h);cur.push16le(1);cur.push16le(32);cur.push32le(0);cur.push32le(XORsz+ANDsz);cur.push32le(0);cur.push32le(0);cur.push32le(0);cur.push32le(0);for(y=h-1;y>=0;y-=1)for(x=0;x=w0||y>=h0){cur.push(0);cur.push(0);cur.push(0);cur.push(0)}else{alpha=mask[idx=y*Math.ceil(w0/8)+Math.floor(x/8)]<0?8:16;if(conf.onMouseButton){conf.onMouseButton(pos.x,pos.y,1,bmask);conf.onMouseButton(pos.x,pos.y,0,bmask)}Util.stopEvent(e);return!1}function onMouseMove(e){var pos;if(!conf.focused)return!0;conf.notify&&conf.notify(e);e||window.event;pos=Util.getEventPosition(e,conf.target,conf.scale);conf.onMouseMove&&conf.onMouseMove(pos.x,pos.y);Util.stopEvent(e);return!1}function onMouseDisable(e){var pos;if(!conf.focused)return!0;e||window.event;if((pos=Util.getEventPosition(e,conf.target,conf.scale)).realx>=0&&pos.realy>=0&&pos.realx>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;i20)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>=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++])<>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++])<>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;i7){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)return{status:this.DATA_ERROR}}while(!bfinal&&d.sourceIndexcharModifier.length:sum>0}function hasCharModifier(charModifier,currentModifiers){if(0===charModifier.length)return!1;for(var i=0;i=48&&keycode<=57)return keycode;if(keycode>=65&&keycode<=90)return shiftPressed?keycode:keycode+32;if(keycode>=96&&keycode<=105)return keycode-96+65456;switch(keycode){case 32:return 32;case 106:return 65450;case 107:return 65451;case 108:return 65452;case 109:return 65453;case 110:return 65454;case 111:return 65455;case 187:return 43;case 188:return 44;case 189:return 45;case 190:return 46}return nonCharacterKey({keyCode:keycode})}function nonCharacterKey(evt){if(!evt.keyCode)return null;var keycode=evt.keyCode;if(keycode>=112&&keycode<=135)return 65470+keycode-112;switch(keycode){case 8:return 65288;case 13:return 65293;case 9:return 65289;case 27:return 65307;case 46:return 65535;case 36:return 65360;case 35:return 65367;case 33:return 65365;case 34:return 65366;case 45:return 65379;case 37:return 65361;case 38:return 65362;case 39:return 65363;case 40:return 65364;case 16:return 65505;case 17:return 65507;case 18:return 65513;case 224:return 65031;case 225:return 65027;case 91:return 65516;case 92:return 65517;case 93:return 65383;default:return null}}return{hasShortcutModifier:hasShortcutModifier,hasCharModifier:hasCharModifier,ModifierSync:function(charModifier){var alt=65513;charModifier||(charModifier=navigator&&/mac/i.exec(navigator.platform)?[alt]:navigator&&/win/i.exec(navigator.platform)?[alt,65507]:navigator&&/linux/i.exec(navigator.platform)?[65027]:[]);var state={65507:!1,65513:!1,65027:!1,65505:!1,65511:!1};function sync(evt,keysym){var result=[];function syncKey(keysym){return{keysym:keysyms.lookup(keysym),type:state[keysym]?"keydown":"keyup"}}if(void 0!==evt.ctrlKey&&evt.ctrlKey!==state[65507]&&65507!==keysym){state[65507]=evt.ctrlKey;result.push(syncKey(65507))}if(void 0!==evt.altKey&&evt.altKey!==state[alt]&&keysym!==alt){state[alt]=evt.altKey;result.push(syncKey(alt))}if(void 0!==evt.altGraphKey&&evt.altGraphKey!==state[65027]&&65027!==keysym){state[65027]=evt.altGraphKey;result.push(syncKey(65027))}if(void 0!==evt.shiftKey&&evt.shiftKey!==state[65505]&&65505!==keysym){state[65505]=evt.shiftKey;result.push(syncKey(65505))}if(void 0!==evt.metaKey&&evt.metaKey!==state[65511]&&65511!==keysym){state[65511]=evt.metaKey;result.push(syncKey(65511))}return result}function syncKeyEvent(evt,down){var obj=getKeysym(evt),keysym=obj?obj.keysym:null;null!==keysym&&void 0!==state[keysym]&&(state[keysym]=down);return sync(evt,keysym)}return{keydown:function(evt){return syncKeyEvent(evt,!0)},keyup:function(evt){return syncKeyEvent(evt,!1)},syncAny:function(evt){return sync(evt)},hasShortcutModifier:function(){return hasShortcutModifier(charModifier,state)},activeCharModifier:function(){return hasCharModifier(charModifier,state)?charModifier:null}}},getKey:function(evt){return"keyCode"in evt&&"key"in evt?evt.key+":"+evt.keyCode:"keyCode"in evt?evt.keyCode:evt.key},getKeysym:getKeysym,keysymFromKeyCode:keysymFromKeyCode,nonCharacterKey:nonCharacterKey,substituteCodepoint:substituteCodepoint}}();function KeyEventDecoder(modifierState,next){function sendAll(evts){for(var i=0;iiterations)finish();else{frame_idx=0;istart_time=(new Date).getTime();rfb.connect("test",0,"bogus");queue_next_packet()}};queue_next_packet=function(){var frame,delay;if("running"===test_state){frame=VNC_frame_data[frame_idx];for(;frame_idx=frame_length)next_iteration();else if("realtime"===mode){(delay=frame.slice(1,frame.indexOf("{",1))-((new Date).getTime()-istart_time))<1&&(delay=1);setTimeout(do_packet,delay)}else setTimeout(do_packet,1);else next_iteration()}};var bytes_processed=0;do_packet=function(){var frame=VNC_frame_data[frame_idx],start=frame.indexOf("{",1)+1;bytes_processed+=frame.length-start;if("binary"===VNC_frame_encoding){for(var u8=new Uint8Array(frame.length-start),i=0;i0&&Util.Info(" "+encodings[i][0]+": "+s[0]+" rects");Util.Info("Encoding stats since page load:");for(i=0;i0&&Util.Info(" "+encodings[i][0]+": "+s[1]+" rects")};updateState=function(state,statusMsg){var oldstate=rfb_state;if(state!==oldstate){if(state in{disconnected:1,loaded:1,connect:1,disconnect:1,failed:1,fatal:1}){if(sendTimer){clearInterval(sendTimer);sendTimer=null}if(msgTimer){clearTimeout(msgTimer);msgTimer=null}if(display&&display.get_context()){keyboard.ungrab();mouse.ungrab();display.defaultCursor();"debug"===Util.get_logging()&&"loaded"!==state||display.clear()}ws.close()}"fatal"===oldstate&&Util.Error("Fatal error, cannot continue");("failed"===state||"fatal"===state?Util.Error:Util.Warn)("New state '"+state+"', was '"+oldstate+"'."+(void 0!==statusMsg?" Msg: "+statusMsg:""));rfb_state="failed"===oldstate&&"disconnected"===state?"failed":state;if(disconnTimer&&"disconnect"!==rfb_state){clearTimeout(disconnTimer);disconnTimer=null}switch(state){case"normal":"disconnected"!==oldstate&&"failed"!==oldstate||Util.Error("Invalid transition from 'disconnected' or 'failed' to 'normal'");break;case"connect":init_vars();(function(){var uri;uri="undefined"!=typeof UsingSocketIO?"http":conf.encrypt?"wss":"ws";uri+="://"+rfb_host+":"+rfb_port+"/"+rfb_path;Util.Info("connecting to "+uri);ws.open(uri,conf.wsProtocols)})();break;case"disconnect":test_mode||(disconnTimer=setTimeout((function(){fail("Disconnect timeout")}),1e3*conf.disconnectTimeout));print_stats();break;case"failed":"disconnected"===oldstate&&Util.Error("Invalid transition from 'disconnected' to 'failed'");"normal"===oldstate&&Util.Error("Error while connected.");"init"===oldstate&&Util.Error("Error while initializing.");setTimeout((function(){updateState("disconnected")}),50)}if("failed"===oldstate&&"disconnected"===state){conf.updateState(that,state,oldstate);conf.onUpdateState(that,state,oldstate)}else{conf.updateState(that,state,oldstate,statusMsg);conf.onUpdateState(that,state,oldstate,statusMsg)}}};fail=function(msg){updateState("failed",msg);return!1};handle_message=function(){if(0!==ws.rQlen())switch(rfb_state){case"disconnected":case"failed":Util.Error("Got data while disconnected");break;case"normal":normal_msg()&&ws.rQlen()>0&&null===msgTimer&&(msgTimer=setTimeout((function(){msgTimer=null;handle_message()}),10));break;default:init_msg()}else Util.Warn("handle_message called on empty receive queue")};checkEvents=function(){if("normal"===rfb_state&&!viewportDragging&&mouse_arr.length>0){ws.send(mouse_arr);mouse_arr=[]}};keyPress=function(keysym,down){conf.view_only||ws.send(keyEvent(keysym,down))};mouseButton=function(x,y,down,bmask){down?mouse_buttonMask|=bmask:mouse_buttonMask^=bmask;if(conf.viewportDrag){if(down&&!viewportDragging){viewportDragging=!0;viewportDragPos={x:x,y:y};return}viewportDragging=!1}if(!conf.view_only){mouse_arr=mouse_arr.concat(pointerEvent(display.absX(x),display.absY(y)));ws.send(mouse_arr);mouse_arr=[]}};mouseMove=function(x,y){var deltaX,deltaY;if(viewportDragging){deltaX=viewportDragPos.x-x;deltaY=viewportDragPos.y-y;viewportDragPos={x:x,y:y};display.viewportChange(deltaX,deltaY)}else if(!conf.view_only){mouse_arr=mouse_arr.concat(pointerEvent(display.absX(x),display.absY(y)));checkEvents()}};init_msg=function(){var strlen,reason,length,sversion,cversion,repeaterID,types,num_types,challenge,response,bpp,depth,big_endian,red_max,green_max,blue_max,red_shift,green_shift,blue_shift,true_color,name_length,is_repeater,xvp_sep,xvp_auth,xvp_auth_str;switch(rfb_state){case"ProtocolVersion":if(ws.rQlen()<12)return fail("Incomplete protocol version");sversion=ws.rQshiftStr(12).substr(4,7);Util.Info("Server ProtocolVersion: "+sversion);is_repeater=0;switch(sversion){case"000.000":is_repeater=1;break;case"003.003":case"003.006":case"003.889":rfb_version=3.3;break;case"003.007":rfb_version=3.7;break;case"003.008":case"004.000":case"004.001":rfb_version=3.8;break;default:return fail("Invalid server version "+sversion)}if(is_repeater){repeaterID=conf.repeaterID;for(;repeaterID.length<250;)repeaterID+="\0";ws.send_string(repeaterID);break}rfb_version>3.8&&(rfb_version=3.8);test_mode||(sendTimer=setInterval((function(){ws.flush()}),50));cversion="00"+parseInt(rfb_version,10)+".00"+10*rfb_version%10;ws.send_string("RFB "+cversion+"\n");updateState("Security","Sent ProtocolVersion: "+cversion);break;case"Security":if(rfb_version>=3.7){num_types=ws.rQshift8();if(ws.rQwait("security type",num_types,1))return!1;if(0===num_types){strlen=ws.rQshift32();reason=ws.rQshiftStr(strlen);return fail("Security failure: "+reason)}rfb_auth_scheme=0;types=ws.rQshiftBytes(num_types);for(i=0;irfb_auth_scheme&&(types[i]<=16||22==types[i])&&(rfb_auth_scheme=types[i]);if(0===rfb_auth_scheme)return fail("Unsupported security types: "+types);ws.send([rfb_auth_scheme])}else{if(ws.rQwait("security scheme",4))return!1;rfb_auth_scheme=ws.rQshift32()}updateState("Authentication","Authenticating using scheme: "+rfb_auth_scheme);init_msg();break;case"Authentication":switch(rfb_auth_scheme){case 0:if(ws.rQwait("auth reason",4))return!1;strlen=ws.rQshift32();reason=ws.rQshiftStr(strlen);return fail("Auth failure: "+reason);case 1:if(rfb_version>=3.8){updateState("SecurityResult");return}break;case 22:xvp_sep=conf.xvp_password_sep;if((xvp_auth=rfb_password.split(xvp_sep)).length<3){updateState("password","XVP credentials required (user"+xvp_sep+"target"+xvp_sep+"password) -- got only "+rfb_password);conf.onPasswordRequired(that);return}xvp_auth_str=String.fromCharCode(xvp_auth[0].length)+String.fromCharCode(xvp_auth[1].length)+xvp_auth[0]+xvp_auth[1];ws.send_string(xvp_auth_str);rfb_password=xvp_auth.slice(2).join(xvp_sep);rfb_auth_scheme=2;case 2:if(0===rfb_password.length){updateState("password","Password Required");conf.onPasswordRequired(that);return}if(ws.rQwait("auth challenge",16))return!1;challenge=ws.rQshiftBytes(16);response=function(password,challenge){var i,passwd=[];for(i=0;i=3.8){length=ws.rQshift32();if(ws.rQwait("SecurityResult reason",length,8))return!1;reason=ws.rQshiftStr(length);fail(reason)}else fail("Authentication failed");return;case 2:return fail("Too many auth attempts")}updateState("ClientInitialisation","Authentication OK");init_msg();break;case"ClientInitialisation":ws.send([conf.shared?1:0]);updateState("ServerInitialisation","Authentication OK");break;case"ServerInitialisation":if(ws.rQwait("server initialization",24))return!1;fb_width=ws.rQshift16();fb_height=ws.rQshift16();bpp=ws.rQshift8();depth=ws.rQshift8();big_endian=ws.rQshift8();true_color=ws.rQshift8();red_max=ws.rQshift16();green_max=ws.rQshift16();blue_max=ws.rQshift16();red_shift=ws.rQshift8();green_shift=ws.rQshift8();blue_shift=ws.rQshift8();ws.rQshiftStr(3);Util.Info("Screen: "+fb_width+"x"+fb_height+", bpp: "+bpp+", depth: "+depth+", big_endian: "+big_endian+", true_color: "+true_color+", red_max: "+red_max+", green_max: "+green_max+", blue_max: "+blue_max+", red_shift: "+red_shift+", green_shift: "+green_shift+", blue_shift: "+blue_shift);0!==big_endian&&Util.Warn("Server native endian is not little endian");16!==red_shift&&Util.Warn("Server native red-shift is not 16");0!==blue_shift&&Util.Warn("Server native blue-shift is not 0");name_length=ws.rQshift32();fb_name=Util.decodeUTF8(ws.rQshiftStr(name_length));conf.onDesktopName(that,fb_name);if(conf.true_color&&"Intel(r) AMT KVM"===fb_name){Util.Warn("Intel AMT KVM only support 8/16 bit depths. Disabling true color");conf.true_color=!1}if(rfb_tightvnc){var numServerMessages=ws.rQshift16(),numClientMessages=ws.rQshift16(),numEncodings=ws.rQshift16();ws.rQshift16();for(i=0;i0?0:ws.rQshift8()){case 0:(ret=framebufferUpdate())&&ws.send(fbUpdateRequests());break;case 1:ws.rQshift8();first_colour=ws.rQshift16();num_colours=ws.rQshift16();if(ws.rQwait("SetColourMapEntries",6*num_colours,6))return!1;for(c=0;c0){now=(new Date).getTime();Util.Info("First FBU latency: "+(now-timing.fbu_rt_start))}}for(;FBU.rects>0;){if("normal"!==rfb_state)return!1;if(ws.rQwait("FBU",FBU.bytes))return!1;if(0===FBU.bytes){if(ws.rQwait("rect header",12))return!1;hdr=ws.rQshiftBytes(12);FBU.x=(hdr[0]<<8)+hdr[1];FBU.y=(hdr[2]<<8)+hdr[3];FBU.width=(hdr[4]<<8)+hdr[5];FBU.height=(hdr[6]<<8)+hdr[7];FBU.encoding=parseInt((hdr[8]<<24)+(hdr[9]<<16)+(hdr[10]<<8)+hdr[11],10);conf.onFBUReceive(that,{x:FBU.x,y:FBU.y,width:FBU.width,height:FBU.height,encoding:FBU.encoding,encodingName:encNames[FBU.encoding]});if(!encNames[FBU.encoding]){fail("Disconnected: unsupported encoding "+FBU.encoding);return!1}}timing.last_fbu=(new Date).getTime();ret=encHandlers[FBU.encoding]();now=(new Date).getTime();timing.cur_fbu+=now-timing.last_fbu;if(ret){encStats[FBU.encoding][0]+=1;encStats[FBU.encoding][1]+=1;timing.pixels+=FBU.width*FBU.height}if(timing.pixels>=fb_width*fb_height){if(FBU.width===fb_width&&FBU.height===fb_height||timing.fbu_rt_start>0){timing.full_fbu_total+=timing.cur_fbu;timing.full_fbu_cnt+=1;Util.Info("Timing of full FBU, cur: "+timing.cur_fbu+", total: "+timing.full_fbu_total+", cnt: "+timing.full_fbu_cnt+", avg: "+timing.full_fbu_total/timing.full_fbu_cnt)}if(timing.fbu_rt_start>0){fbu_rt_diff=now-timing.fbu_rt_start;timing.fbu_rt_total+=fbu_rt_diff;timing.fbu_rt_cnt+=1;Util.Info("full FBU round-trip, cur: "+fbu_rt_diff+", total: "+timing.fbu_rt_total+", cnt: "+timing.fbu_rt_cnt+", avg: "+timing.fbu_rt_total/timing.fbu_rt_cnt);timing.fbu_rt_start=0}}if(!ret)return ret}conf.onFBUComplete(that,{x:FBU.x,y:FBU.y,width:FBU.width,height:FBU.height,encoding:FBU.encoding,encodingName:encNames[FBU.encoding]});return!0};encHandlers.RAW=function(){var cur_y,cur_height;0===FBU.lines&&(FBU.lines=FBU.height);FBU.bytes=FBU.width*fb_Bpp;if(ws.rQwait("RAW",FBU.bytes))return!1;cur_y=FBU.y+(FBU.height-FBU.lines);cur_height=Math.min(FBU.lines,Math.floor(ws.rQlen()/(FBU.width*fb_Bpp)));display.blitImage(FBU.x,cur_y,FBU.width,cur_height,ws.get_rQ(),ws.get_rQi());ws.rQshiftBytes(FBU.width*cur_height*fb_Bpp);FBU.lines-=cur_height;if(FBU.lines>0)FBU.bytes=FBU.width*fb_Bpp;else{FBU.rects-=1;FBU.bytes=0}return!0};encHandlers.COPYRECT=function(){FBU.bytes=4;if(ws.rQwait("COPYRECT",4))return!1;display.renderQ_push({type:"copy",old_x:ws.rQshift16(),old_y:ws.rQshift16(),x:FBU.x,y:FBU.y,width:FBU.width,height:FBU.height});FBU.rects-=1;FBU.bytes=0;return!0};encHandlers.RRE=function(){var color,x,y,width,height,chunk;if(0===FBU.subrects){FBU.bytes=4+fb_Bpp;if(ws.rQwait("RRE",4+fb_Bpp))return!1;FBU.subrects=ws.rQshift32();color=ws.rQshiftBytes(fb_Bpp);display.fillRect(FBU.x,FBU.y,FBU.width,FBU.height,color)}for(;FBU.subrects>0&&ws.rQlen()>=fb_Bpp+8;){color=ws.rQshiftBytes(fb_Bpp);x=ws.rQshift16();y=ws.rQshift16();width=ws.rQshift16();height=ws.rQshift16();display.fillRect(FBU.x+x,FBU.y+y,width,height,color);FBU.subrects-=1}if(FBU.subrects>0){chunk=Math.min(100,FBU.subrects);FBU.bytes=(fb_Bpp+8)*chunk}else{FBU.rects-=1;FBU.bytes=0}return!0};encHandlers.HEXTILE=function(){var subencoding,subrects,color,cur_tile,tile_x,x,w,tile_y,y,h,xy,s,sx,sy,wh,sw,sh,rQ=ws.get_rQ(),rQi=ws.get_rQi();if(0===FBU.tiles){FBU.tiles_x=Math.ceil(FBU.width/16);FBU.tiles_y=Math.ceil(FBU.height/16);FBU.total_tiles=FBU.tiles_x*FBU.tiles_y;FBU.tiles=FBU.total_tiles}for(;FBU.tiles>0;){FBU.bytes=1;if(ws.rQwait("HEXTILE subencoding",FBU.bytes))return!1;if((subencoding=rQ[rQi])>30){fail("Disconnected: illegal hextile subencoding "+subencoding);return!1}subrects=0;tile_x=(cur_tile=FBU.total_tiles-FBU.tiles)%FBU.tiles_x;tile_y=Math.floor(cur_tile/FBU.tiles_x);x=FBU.x+16*tile_x;y=FBU.y+16*tile_y;w=Math.min(16,FBU.x+FBU.width-x);h=Math.min(16,FBU.y+FBU.height-y);if(1&subencoding)FBU.bytes+=w*h*fb_Bpp;else{2&subencoding&&(FBU.bytes+=fb_Bpp);4&subencoding&&(FBU.bytes+=fb_Bpp);if(8&subencoding){FBU.bytes+=1;if(ws.rQwait("hextile subrects header",FBU.bytes))return!1;subrects=rQ[rQi+FBU.bytes-1];FBU.bytes+=16&subencoding?subrects*(fb_Bpp+2):2*subrects}}if(ws.rQwait("hextile",FBU.bytes))return!1;FBU.subencoding=rQ[rQi];rQi+=1;if(0===FBU.subencoding)1&FBU.lastsubencoding||display.fillRect(x,y,w,h,FBU.background);else if(1&FBU.subencoding){display.blitImage(x,y,w,h,rQ,rQi);rQi+=FBU.bytes-1}else{if(2&FBU.subencoding){FBU.background=rQ.slice(rQi,rQi+fb_Bpp);rQi+=fb_Bpp}if(4&FBU.subencoding){FBU.foreground=rQ.slice(rQi,rQi+fb_Bpp);rQi+=fb_Bpp}display.startTile(x,y,w,h,FBU.background);if(8&FBU.subencoding){subrects=rQ[rQi];rQi+=1;for(s=0;s>4;sy=15&xy;wh=rQ[rQi+=1];rQi+=1;sw=1+(wh>>4);sh=1+(15&wh);display.subTile(sx,sy,sw,sh,color)}}display.finishTile()}ws.set_rQi(rQi);FBU.lastsubencoding=FBU.subencoding;FBU.bytes=0;FBU.tiles-=1}0===FBU.tiles&&(FBU.rects-=1);return!0};getTightCLength=function(arr){var header=1,data=0;data+=127&arr[0];if(128&arr[0]){header+=1;data+=(127&arr[1])<<7;if(128&arr[1]){header+=1;data+=arr[2]<<14}}return[header,data]};function display_tight(isTightPNG){1===fb_depth&&fail("Tight protocol handler only implements true color mode");var ctl,cmode,clength,color,img,data,filterId=-1,resetStreams=0,streamId=-1,rQ=ws.get_rQ(),rQi=ws.get_rQi();FBU.bytes=1;if(ws.rQwait("TIGHT compression-control",FBU.bytes))return!1;var decompress=function(data){for(var i=0;i<4;i++)if(resetStreams>>i&1){FBU.zlibs[i].reset();Util.Info("Reset zlib stream "+i)}var uncompressed=FBU.zlibs[streamId].uncompress(data,0);0!==uncompressed.status&&Util.Error("Invalid data in zlib stream");return uncompressed.data};ctl=ws.rQpeek8();resetStreams=15&ctl;streamId=3&(ctl>>=4);if(8===ctl)cmode="fill";else if(9===ctl)cmode="jpeg";else if(10===ctl)cmode="png";else if(4&ctl)cmode="filter";else{if(!(ctl<4))return fail("Illegal tight compression received, ctl: "+ctl);cmode="copy"}if(isTightPNG&&("filter"===cmode||"copy"===cmode))return fail("filter/copy received in tightPNG mode");switch(cmode){case"fill":FBU.bytes+=fb_depth;break;case"jpeg":case"png":FBU.bytes+=3;break;case"filter":FBU.bytes+=2}if(ws.rQwait("TIGHT "+cmode,FBU.bytes))return!1;switch(cmode){case"fill":ws.rQshift8();color=ws.rQshiftBytes(fb_depth);display.renderQ_push({type:"fill",x:FBU.x,y:FBU.y,width:FBU.width,height:FBU.height,color:[color[2],color[1],color[0]]});break;case"png":case"jpeg":clength=getTightCLength(ws.rQslice(1,4));FBU.bytes=1+clength[0]+clength[1];if(ws.rQwait("TIGHT "+cmode,FBU.bytes))return!1;ws.rQshiftBytes(1+clength[0]);(img=new Image).src="data:image/"+cmode+extract_data_uri(ws.rQshiftBytes(clength[1]));display.renderQ_push({type:"img",img:img,x:FBU.x,y:FBU.y});img=null;break;case"filter":if(1!==(filterId=rQ[rQi+1]))throw"Unsupported tight subencoding received, filter: "+filterId;if(!function(){var numColors=rQ[rQi+2]+1,paletteSize=numColors*fb_depth;FBU.bytes+=paletteSize;if(ws.rQwait("TIGHT palette "+cmode,FBU.bytes))return!1;var bpp=numColors<=2?1:8,rowSize=Math.floor((FBU.width*bpp+7)/8),raw=!1;if(rowSize*FBU.height<12){raw=!0;clength=[0,rowSize*FBU.height]}else clength=getTightCLength(ws.rQslice(3+paletteSize,3+paletteSize+3));FBU.bytes+=clength[0]+clength[1];if(ws.rQwait("TIGHT "+cmode,FBU.bytes))return!1;ws.rQshiftBytes(3);var palette=ws.rQshiftBytes(paletteSize);ws.rQshiftBytes(clength[0]);var rgb=function(data,numColors,palette,width,height){var x,y,b,w,w1,dp,sp,dest=[];if(2===numColors){w=Math.floor((width+7)/8);w1=Math.floor(width/8);for(y=0;y=0;b--){dp=3*(y*width+8*x+7-b);sp=3*(data[y*w+x]>>b&1);dest[dp]=palette[sp];dest[dp+1]=palette[sp+1];dest[dp+2]=palette[sp+2]}for(b=7;b>=8-width%8;b--){dp=3*(y*width+8*x+7-b);sp=3*(data[y*w+x]>>b&1);dest[dp]=palette[sp];dest[dp+1]=palette[sp+1];dest[dp+2]=palette[sp+2]}}}else for(y=0;y0&&cb.h>0&&(arr=arr.concat(fbUpdateRequest(1,cb.x,cb.y,cb.w,cb.h)));for(i=0;i0){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;i0){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()}; -/*! - * Custom code for y2k.land, licensed under MIT: - * https://github.com/jakejarvis/y2k - */ -(function(){var e=document.getElementById("status"),t=document.getElementById("display"),n=Math.floor(20*Math.random());window.WebSocket?(new RFB({target:t,encrypt:!0}).connect("sandbox.y2k.land",443),document.body.style.backgroundImage="url('tiles/tile_"+n+".png')",e.innerHTML="Spinning up your very own personal computer, please wait!",setTimeout(function(){e.innerHTML='Oh dear, it looks like something went very wrong. :(

Click here to check the server status, or try again in a bit.'},2e4)):e.innerHTML="WebSockets must be enabled to enter Y2K Land!!!

Press the Any key to continue."})(); diff --git a/public/favicon.ico b/public/favicon.ico deleted file mode 100644 index 0ae9b02..0000000 Binary files a/public/favicon.ico and /dev/null differ diff --git a/public/fonts/perfect-dos.woff b/public/fonts/perfect-dos.woff deleted file mode 100644 index 4842ec8..0000000 Binary files a/public/fonts/perfect-dos.woff and /dev/null differ diff --git a/public/fonts/perfect-dos.woff2 b/public/fonts/perfect-dos.woff2 deleted file mode 100644 index 156c98f..0000000 Binary files a/public/fonts/perfect-dos.woff2 and /dev/null differ diff --git a/public/index.html b/public/index.html deleted file mode 100644 index b85e6ec..0000000 --- a/public/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - -Y2K Land — Powered by Windows Me™ 💾 - - - - - - - - - -
-JavaScript is required for this experience, please enable it and refresh the page!

Press the Any key to continue.
-_ -
- - - - - - - diff --git a/public/style.css b/public/style.css deleted file mode 100644 index e8f0b9c..0000000 --- a/public/style.css +++ /dev/null @@ -1,77 +0,0 @@ -@font-face { - font-family: "Perfect DOS VGA 437"; - font-style: normal; - font-weight: normal; - src: url("fonts/perfect-dos.woff2") format("woff2"), - url("fonts/perfect-dos.woff") format("woff"); -} -body { - font-family: "Perfect DOS VGA 437", monospace; - width: 100%; - height: 100%; - margin: 0; - padding: 0; - user-select: none; - - /* specific retro wallpaper tile is set randomly by JS onload */ - background-color: #000; - background-repeat: repeat; - background-attachment: fixed; - background-position: center; -} -a { - color: inherit; - text-decoration: underline; -} -canvas, div#cmd { - display: block; - margin: auto; - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; -} -div#cmd { - width: 600px; - height: 300px; - padding: 12px; - background-color: #000; - color: #ccc; - z-index: -100; -} -canvas { - z-index: 100; - - /* 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; - image-rendering: pixelated; - -ms-interpolation-mode: nearest-neighbor; -} -span.blink { - animation: blink 1s step-end infinite; -} -@keyframes blink { - 50% { - opacity: 0; - } -} -/* http://tholman.com/github-corners/ */ -.github-corner:hover .octo-arm { - animation: octocat-wave 560ms ease-in-out; -} -@keyframes octocat-wave { - 0%, 100% { - transform: rotate(0); - } - 20%, 60% { - transform: rotate(-25deg); - } - 40%, 80% { - transform: rotate(10deg); - } -} diff --git a/public/tiles/tile_0.png b/public/tiles/tile_0.png deleted file mode 100644 index e3de59f..0000000 Binary files a/public/tiles/tile_0.png and /dev/null differ diff --git a/public/tiles/tile_1.png b/public/tiles/tile_1.png deleted file mode 100644 index 1c17039..0000000 Binary files a/public/tiles/tile_1.png and /dev/null differ diff --git a/public/tiles/tile_10.png b/public/tiles/tile_10.png deleted file mode 100644 index 5004578..0000000 Binary files a/public/tiles/tile_10.png and /dev/null differ diff --git a/public/tiles/tile_11.png b/public/tiles/tile_11.png deleted file mode 100644 index 6a1f8d9..0000000 Binary files a/public/tiles/tile_11.png and /dev/null differ diff --git a/public/tiles/tile_12.png b/public/tiles/tile_12.png deleted file mode 100644 index 8fc1849..0000000 Binary files a/public/tiles/tile_12.png and /dev/null differ diff --git a/public/tiles/tile_13.png b/public/tiles/tile_13.png deleted file mode 100644 index 34d8f4c..0000000 Binary files a/public/tiles/tile_13.png and /dev/null differ diff --git a/public/tiles/tile_14.png b/public/tiles/tile_14.png deleted file mode 100644 index 50f9635..0000000 Binary files a/public/tiles/tile_14.png and /dev/null differ diff --git a/public/tiles/tile_15.png b/public/tiles/tile_15.png deleted file mode 100644 index 9891c48..0000000 Binary files a/public/tiles/tile_15.png and /dev/null differ diff --git a/public/tiles/tile_16.png b/public/tiles/tile_16.png deleted file mode 100644 index 3912c2f..0000000 Binary files a/public/tiles/tile_16.png and /dev/null differ diff --git a/public/tiles/tile_17.png b/public/tiles/tile_17.png deleted file mode 100644 index 46f0f2c..0000000 Binary files a/public/tiles/tile_17.png and /dev/null differ diff --git a/public/tiles/tile_18.png b/public/tiles/tile_18.png deleted file mode 100644 index cb74d78..0000000 Binary files a/public/tiles/tile_18.png and /dev/null differ diff --git a/public/tiles/tile_19.png b/public/tiles/tile_19.png deleted file mode 100644 index a75e2b1..0000000 Binary files a/public/tiles/tile_19.png and /dev/null differ diff --git a/public/tiles/tile_2.png b/public/tiles/tile_2.png deleted file mode 100644 index 9ccc395..0000000 Binary files a/public/tiles/tile_2.png and /dev/null differ diff --git a/public/tiles/tile_3.png b/public/tiles/tile_3.png deleted file mode 100644 index 17deff4..0000000 Binary files a/public/tiles/tile_3.png and /dev/null differ diff --git a/public/tiles/tile_4.png b/public/tiles/tile_4.png deleted file mode 100644 index d90feb5..0000000 Binary files a/public/tiles/tile_4.png and /dev/null differ diff --git a/public/tiles/tile_5.png b/public/tiles/tile_5.png deleted file mode 100644 index f76d6fd..0000000 Binary files a/public/tiles/tile_5.png and /dev/null differ diff --git a/public/tiles/tile_6.png b/public/tiles/tile_6.png deleted file mode 100644 index 4b3ce66..0000000 Binary files a/public/tiles/tile_6.png and /dev/null differ diff --git a/public/tiles/tile_7.png b/public/tiles/tile_7.png deleted file mode 100644 index e95fb17..0000000 Binary files a/public/tiles/tile_7.png and /dev/null differ diff --git a/public/tiles/tile_8.png b/public/tiles/tile_8.png deleted file mode 100644 index f4e5f9e..0000000 Binary files a/public/tiles/tile_8.png and /dev/null differ diff --git a/public/tiles/tile_9.png b/public/tiles/tile_9.png deleted file mode 100644 index 26e72c8..0000000 Binary files a/public/tiles/tile_9.png and /dev/null differ diff --git a/backend/server/example.service b/server/example.service similarity index 80% rename from backend/server/example.service rename to server/example.service index 05c0816..abff515 100644 --- a/backend/server/example.service +++ b/server/example.service @@ -8,7 +8,7 @@ Type=simple Restart=always RestartSec=1 User=root -ExecStart=/root/y2k/backend/server/socket.sh +ExecStart=/root/y2k/server/socket.sh [Install] WantedBy=multi-user.target diff --git a/backend/server/install.sh b/server/install.sh similarity index 97% rename from backend/server/install.sh rename to server/install.sh index cdca4fe..908c3a0 100755 --- a/backend/server/install.sh +++ b/server/install.sh @@ -76,7 +76,7 @@ docker pull gcr.io/jakejarvis/y2k:latest git clone https://github.com/jakejarvis/y2k.git /root/y2k #### enable & start service #### -cp /root/y2k/backend/server/example.service /lib/systemd/system/y2k.service +cp /root/y2k/server/example.service /lib/systemd/system/y2k.service systemctl daemon-reload systemctl enable y2k systemctl start y2k diff --git a/backend/server/socket.sh b/server/socket.sh similarity index 72% rename from backend/server/socket.sh rename to server/socket.sh index bbc626c..9bc8fdc 100755 --- a/backend/server/socket.sh +++ b/server/socket.sh @@ -4,7 +4,7 @@ --port=80 \ --binary \ --header-ws="Sec-WebSocket-Protocol: binary" \ - --origin=y2k.land,www.y2k.land,y2k.jakejarvis.workers.dev \ + --origin=y2k.jarv.is,y2k.jakejarvis.workers.dev \ -- \ docker run \ --cpus 1 \ @@ -16,4 +16,4 @@ # to spawn QEMU processes natively on the host machine instead of via # individual Docker containers: -# /root/y2k/backend/bin/boot.rb /root/y2k/backend/hdd /usr/bin/qemu-system-i386 +# /root/y2k/container/bin/boot.rb /root/y2k/container/hdd /usr/bin/qemu-system-i386 diff --git a/workers-site/.cargo-ok b/workers-site/.cargo-ok deleted file mode 100644 index e69de29..0000000 diff --git a/workers-site/.gitignore b/workers-site/.gitignore deleted file mode 100644 index 75c573a..0000000 --- a/workers-site/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -worker diff --git a/workers-site/.npmrc b/workers-site/.npmrc deleted file mode 100644 index 43c97e7..0000000 --- a/workers-site/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/workers-site/index.js b/workers-site/index.js deleted file mode 100644 index 419949d..0000000 --- a/workers-site/index.js +++ /dev/null @@ -1,55 +0,0 @@ -import { getAssetFromKV } 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) { - let options = { - cacheControl: { - browserTTL: 3600, - edgeTTL: 604800, - } - } - - try { - // make debugging easier (see top of this file) - if (DEBUG) options.cacheControl.bypassCache = true - - // asset was found - return await getAssetFromKV(event, options) - } catch (e) { - // if a 404 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 }) - } -} diff --git a/workers-site/package.json b/workers-site/package.json deleted file mode 100644 index 8664f25..0000000 --- a/workers-site/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "private": true, - "name": "y2k-static", - "version": "1.0.0", - "homepage": "https://y2k.land/", - "author": "Jake Jarvis ", - "license": "MIT", - "main": "index.js", - "dependencies": { - "@cloudflare/kv-asset-handler": "*" - } -} diff --git a/wrangler.toml b/wrangler.toml deleted file mode 100644 index 16f82e7..0000000 --- a/wrangler.toml +++ /dev/null @@ -1,9 +0,0 @@ -name = "y2k" -type = "webpack" -account_id = "bd1a636a30a817137ce1e91c9e407373" -zone_id = "8a79e5c61c0a7033d7b0eca176665cd1" -route = "y2k.land/*" - -[site] -bucket = "public" -entry-point = "workers-site"