Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoryammilwalrus committed Dec 10, 2022
1 parent 73ccc43 commit 316ce33
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,33 @@ console.log(`
// The following message MAY NOT be removed
console.log("Incognito-Lite\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it\nunder the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <https://www.gnu.org/licenses/>.\n");

const bare = createServer('/bare/');
const server = http.createServer()
const bare = createServer("/bare/");
const server = http.createServer();

server.on('request', async (req, res) => {
if(bare.shouldRoute(req)) bare.routeRequest(req, res); else {
const asset = await fetch("https://amethystnetwork-dev.github.io/Incognito/static" + req.url);
const body = new Buffer.from(await asset.arrayBuffer());
res.writeHead(asset.status, { "Content-Type": asset.headers.get("content-type").split(";")[0] });
res.end(body);
}
if(bare.shouldRoute(req)) return bare.routeRequest(req, res);
if(req.url.startsWith("/service/")) return res.end('OK');

const asset = await fetch("https://amethystnetwork-dev.github.io/Incognito/static" + req.url);
const body = new Buffer.from(await asset.arrayBuffer());
res.writeHead(asset.status, { "Content-Type": asset.headers.get("content-type").split(";")[0] });
res.end(body);
});

server.on('upgrade', (req, socket, head) => {
server.on("upgrade", (req, socket, head) => {
if(bare.shouldRoute(req, socket, head)) bare.routeUpgrade(req, socket, head); else socket.end();
});

server.on('listening', () => {
server.on("listening", () => {
const addr = server.address();

console.log(`Server running on port ${addr.port}`)
console.log('');
console.log('You can now view it in your browser.')
console.log(`Server running on port ${addr.port}`);
console.log("");
console.log("You can now view it in your browser.");
/* Code for listing IPS from website-aio */
console.log(`Local: http://${addr.family === 'IPv6' ? `[${addr.address}]` : addr.address}:${addr.port}`);
try { console.log(`On Your Network: http://${address.ip()}:${addr.port}`); } catch (err) {/* Can't find LAN interface */};
if(process.env.REPL_SLUG && process.env.REPL_OWNER) console.log(`Replit: https://${process.env.REPL_SLUG}.${process.env.REPL_OWNER}.repl.co`);
console.log(`Local: http://${addr.family === 'IPv6' ? `[${addr.address}]` : addr.address}:${addr.port}`);
try { console.log(`On Your Network: http://${address.ip()}:${addr.port}`); } catch (err) {/* Can't find LAN interface */};
if(process.env.REPL_SLUG && process.env.REPL_OWNER) console.log(`Replit: https://${process.env.REPL_SLUG}.${process.env.REPL_OWNER}.repl.co`);
});

server.listen({ port: (process.env.PORT || 8080) })

0 comments on commit 316ce33

Please sign in to comment.