-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0638673
commit a0190ea
Showing
5 changed files
with
2,280 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Titanium Network | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "Ultraviolet App", | ||
"description": "Node.js Ultraviolet instance", | ||
"repository": "https://github.com/titaniumnetwork-dev/Ultraviolet-App", | ||
"logo": "https://raw.githubusercontent.com/titaniumnetwork-dev/Ultraviolet-Static/main/public/uv.png", | ||
"keywords": ["tomp", "ultraviolet"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import express from "express"; | ||
import { createServer } from "node:http"; | ||
import { publicPath } from "ultraviolet-static"; | ||
import { uvPath } from "@titaniumnetwork-dev/ultraviolet"; | ||
import { epoxyPath } from "@mercuryworkshop/epoxy-transport"; | ||
import { baremuxPath } from "@mercuryworkshop/bare-mux/node"; | ||
import { join } from "node:path"; | ||
import { hostname } from "node:os"; | ||
import wisp from "wisp-server-node" | ||
|
||
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) => { | ||
res.setHeader("Cross-Origin-Opener-Policy", "same-origin"); | ||
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp"); | ||
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, | ||
}); |
Oops, something went wrong.
a0190ea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ugfd-proxy – ./
ugfd-proxy-ugfd.vercel.app
ugfd-proxy-offical.vercel.app
ugfd-proxy-git-main-ugfd.vercel.app