titaniumnetwork-dev / Ultraviolet

A highly sophisticated proxy used for evading internet censorship or accessing websites in a controlled sandbox using the power of service-workers. Works by intercepting HTTP requests with a service worker script that follows the TompHTTP specifications.
https://docs.titaniumnetwork.org/proxies/ultraviolet
GNU Affero General Public License v3.0
565 stars 4.13k forks source link

No Bare Clients Found #125

Closed anshnk closed 7 months ago

anshnk commented 7 months ago

Issue tracker is ONLY used for reporting bugs. New features should be discussed on our Discord server.

No Bare Clients found on UV 3.0.0

Expected Behavior

Site will load

Current Behavior

Site will show the error page and say No Bare Clients Found

Steps to Reproduce

import express from "express";
import { createServer } from "node:http";
import { uvPath } from "@titaniumnetwork-dev/ultraviolet";
import { epoxyPath } from "@mercuryworkshop/epoxy-transport";
import { baremuxPath } from "@mercuryworkshop/bare-mux";
import { join } from "node:path";
import { hostname } from "node:os";
import path from 'path';
import wisp from "wisp-server-node"

const __filename = path.resolve(new URL(import.meta.url).pathname.replace(/^\/([a-z]):\//i, '$1:/'));
const __dirname = path.dirname(__filename);
const publicPath = path.resolve(__dirname, './public');

const app = express();
// Load our publicPath first and prioritize it over UV.
app.use(express.static(publicPath));
// Load vendor files last.
// The vendor's uv.config.js won't conflict with our uv.config.js inside the publicPath directory.
app.use("/uv/", express.static(uvPath));
app.use("/epoxy/", express.static(epoxyPath));
app.use("/baremux/", express.static(baremuxPath));

// Error for everything else
app.use((req, res) => {
  res.status(404);
  res.sendFile(join(publicPath, "404.html"));
});

const server = createServer();

server.on("request", (req, res) => {
  app(req, res);
});
server.on("upgrade", (req, socket, head) => {
  if (req.url.endsWith("/wisp/"))
    wisp.routeRequest(req, socket, head);
  else
    socket.end();
});

let port = parseInt(process.env.PORT || "");

if (isNaN(port)) port = 8080;

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

  // by default we are listening on 0.0.0.0 (every interface)
  // we just need to list a few
  console.log("Listening on:");
  console.log(`\thttp://localhost:${address.port}`);
  console.log(`\thttp://${hostname()}:${address.port}`);
  console.log(
    `\thttp://${address.family === "IPv6" ? `[${address.address}]` : address.address
    }:${address.port}`
  );
});

// https://expressjs.com/en/advanced/healthcheck-graceful-shutdown.html
process.on("SIGINT", shutdown);
process.on("SIGTERM", shutdown);

function shutdown() {
  console.log("SIGTERM signal received: closing HTTP server");
  server.close();
  process.exit(0);
}

server.listen({
  port,
});
  1. Using this code start up a server.
  2. Try to load a page
  3. No Bare Clients Found

Context (Environment)

Trying to load the site in a iFrame

IncognitoTGT commented 7 months ago

Known issue

anshnk commented 7 months ago

Nuh uh!

Percslol commented 7 months ago

@anshnk UV 3.0.0 requires you to set a transport on your frontend using bare-mux, you can find a guide on how to do that here