Skip to content

Commit

Permalink
Using local webui
Browse files Browse the repository at this point in the history
  • Loading branch information
tindy2013 committed Jun 14, 2021
1 parent 05e7a85 commit 8b24939
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 3 deletions.
16 changes: 16 additions & 0 deletions base/webui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>SSR Speed Web UI</title>
</head>

<body>
<div id="app"></div>
<script type="text/javascript" src="manifest.js"></script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="index.js"></script>
</body>

</html>
26 changes: 26 additions & 0 deletions base/webui/index.js

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions base/webui/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; };
if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } }
{
let window = _____WB$wombat$assign$function_____("window");
let self = _____WB$wombat$assign$function_____("self");
let document = _____WB$wombat$assign$function_____("document");
let location = _____WB$wombat$assign$function_____("location");
let top = _____WB$wombat$assign$function_____("top");
let parent = _____WB$wombat$assign$function_____("parent");
let frames = _____WB$wombat$assign$function_____("frames");
let opener = _____WB$wombat$assign$function_____("opener");

!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var i,a,f,l=0,s=[];l<t.length;l++)a=t[l],o[a]&&s.push(o[a][0]),o[a]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(r&&r(t,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=n(n.s=u[l]);return f};var t={},o={2:0};n.e=function(e){function r(){i.onerror=i.onload=null,clearTimeout(a);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var u=document.getElementsByTagName("head")[0],i=document.createElement("script");i.type="text/javascript",i.charset="utf-8",i.async=!0,i.timeout=12e4,n.nc&&i.setAttribute("nonce",n.nc),i.src=n.p+""+e+".js?"+{0:"f7b23600c63ba2d9b83b",1:"8bb36c1733ec334abc1c"}[e];var a=setTimeout(r,12e4);return i.onerror=i.onload=r,u.appendChild(i),c},n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n.oe=function(e){throw console.error(e),e}}([]);

}
/*
FILE ARCHIVED ON 14:31:52 Aug 30, 2020 AND RETRIEVED FROM THE
INTERNET ARCHIVE ON 05:06:38 Jun 14, 2021.
JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
SECTION 108(a)(3)).
*/
/*
playback timings (ms):
esindex: 0.016
LoadShardBlock: 223.142 (3)
exclusion.robots: 0.244
PetaboxLoader3.datanode: 128.48 (4)
captures_list: 277.94
RedisCDXSource: 29.401
PetaboxLoader3.resolve: 35.602
load_resource: 85.436
exclusion.robots.policy: 0.229
CDXLines.iter: 20.901 (3)
*/
41 changes: 41 additions & 0 deletions base/webui/vendor.js

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions src/webgui_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "printout.h"
#include "renderer.h"
#include "speedtestutil.h"
#include "version.h"

std::atomic<bool> start_flag = false;
std::atomic<time_t> done_time = 0;
Expand Down Expand Up @@ -275,16 +276,20 @@ std::string ssrspeed_generate_color()
void ssrspeed_webserver_routine(const std::string &listen_address, int listen_port)
{
listener_args args = {listen_address, listen_port, 10, 4};
extern bool gServeFile;
extern std::string gServeFileRoot;
gServeFile = true;
gServeFileRoot = "webui/";

append_response("GET", "/status", "text/plain", [](RESPONSE_CALLBACK_ARGS) -> std::string
{
return start_flag ? "running" : "stopped";
});

append_response("GET", "/", "REDIRECT", [](RESPONSE_CALLBACK_ARGS) -> std::string
/*append_response("GET", "/", "REDIRECT", [](RESPONSE_CALLBACK_ARGS) -> std::string
{
return "http://web1.ospf.in/";
});
});*/

append_response("GET", "/favicon.ico", "x-icon", [](RESPONSE_CALLBACK_ARGS) -> std::string
{
Expand All @@ -293,7 +298,7 @@ void ssrspeed_webserver_routine(const std::string &listen_address, int listen_po

append_response("GET", "/getversion", "text/plain", [](RESPONSE_CALLBACK_ARGS) -> std::string
{
return "{\"main\":\"2.7.4\",\"webapi\":\"0.6.1\"}";
return "{\"main\":\"" VERSION "\",\"webapi\":\"0.6.1\"}";
});

append_response("GET", "/getcolors", "text/plain", [](RESPONSE_CALLBACK_ARGS) -> std::string
Expand Down

0 comments on commit 8b24939

Please sign in to comment.