Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #109

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
<p align="center"><img src="https://raw.githubusercontent.com/titaniumnetwork-dev/Ultraviolet-Static/main/public/uv.png" height="200"></p>
# BBS-Proxy
日本向けに軽量化して作ったWEBProxyです。
## ~ 導入方法&起動方法 ~

<h1 align="center">Ultraviolet-App</h1>
```sudo curl -Ls https://raw.githubusercontent.com/hirotomoki12345/BBS-Proxy/main/set_pm2.sh -o set.sh```
```bash ./set.sh```

The deployable all-in-one bundle for [Ultraviolet](https://github.com/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 and more!
logの様子を見るには

## Deployment
```pm2 logs bbs-proxy```

[![Run on Replit](https://binbashbanana.github.io/deploy-buttons/buttons/remade/replit.svg)](https://github.com/titaniumnetwork-dev/Ultraviolet-App/wiki/Run-on-Replit)
[![Deploy on Railway](https://binbashbanana.github.io/deploy-buttons/buttons/remade/railway.svg)](https://github.com/titaniumnetwork-dev/Ultraviolet-App/wiki/Deploy-on-Railway)
[![Remix on Glitch](https://binbashbanana.github.io/deploy-buttons/buttons/remade/glitch.svg)](https://github.com/titaniumnetwork-dev/Ultraviolet-App/wiki/Remix-on-Glitch)
[![Deploy to Koyeb](https://binbashbanana.github.io/deploy-buttons/buttons/remade/koyeb.svg)](https://github.com/titaniumnetwork-dev/Ultraviolet-App/wiki/Deploy-to-Koyeb)
で見れます
### 終
## 止めるには
```pm2 stop bbs-proxy```
## 削除するには
```sudo curl -Ls https://raw.githubusercontent.com/hirotomoki12345/BBS-Proxy/main/delete.sh | sudo bash```
## 注意
~~debian linuxじゃないとできないです。(apt入れたらできるかも(試していません))~~

If you are deploying to an alternative service or to a server, refer to [Deploy via terminal](https://github.com/titaniumnetwork-dev/Ultraviolet-App/wiki/Deploy-via-terminal).
他のディストリビューションにも対応させました。

Additional information such as [customizing your frontend](https://github.com/titaniumnetwork-dev/Ultraviolet-App/wiki/Customizing-your-frontend) can be found on the [wiki](https://github.com/titaniumnetwork-dev/Ultraviolet-App/wiki).
localhost以外はHTTPSじゃないと使えません。
## 使わせてもらったもの
Ultraviolet:https://github.com/titaniumnetwork-dev/Ultraviolet

Support and updates can be found in our [Discord Server](discord.gg/unblock).

> [!IMPORTANT]
> Until deployed on a domain with a valid SSL certificate, Firefox will not be able to load the site. Use chromium for testing on localhost

### HTTP Transport
The example uses [EpoxyTransport](https://github.com/MercuryWorkshop/EpoxyTransport) to fetch proxied data encrypted.

You may also want to use [CurlTransport](https://github.com/MercuryWorkshop/CurlTransport), a different way of fetching encrypted data, or [Bare-Client](https://github.com/MercuryWorkshop/Bare-as-module3), the legacy (unencrypted!) transport.

See the [bare-mux](https://github.com/MercuryWorkshop/bare-mux) documentation for more information.
© BlogBooks Community
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
],
"author": "",
"license": "GPL-3.0-or-later",
"dependencies": {
"@mercuryworkshop/bare-mux": "^2.0.4",
"@mercuryworkshop/epoxy-transport": "^2.1.8",
"@titaniumnetwork-dev/ultraviolet": "^3.2.7",
"express": "^4.18.2",
"ultraviolet-static": "github:titaniumnetwork-dev/Ultraviolet-Static",
"wisp-server-node": "^1.1.3",
"ws": "^8.17.1"
},
"dependencies": {
"@mercuryworkshop/bare-mux": "^2.0.4",
"@mercuryworkshop/epoxy-transport": "^2.1.8",
"@titaniumnetwork-dev/ultraviolet": "^3.2.7",
"express": "^4.18.2",
"ultraviolet-static": "github:hirotomoki12345/Ultraviolet-psannetwork",
"wisp-server-node": "^1.1.3",
"ws": "^8.17.1"
},
"devDependencies": {
"eslint": "^8.36.0",
"prettier": "^2.8.4"
Expand Down
193 changes: 193 additions & 0 deletions set_pm2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@

#!/bin/bash

if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root"
exit 1
fi

install_debian() {
if ! dpkg -s "$1" &> /dev/null; then
if ! apt install -y "$1"; then
echo "Failed to install $1 on Debian-based system"
exit 1
fi
fi
}

install_arch() {
if ! pacman -Qi "$1" &> /dev/null; then
if ! pacman -S --noconfirm "$1"; then
echo "Failed to install $1 on Arch-based system"
exit 1
fi
fi
}

install_redhat() {
if ! rpm -q "$1" &> /dev/null; then
if ! yum install -y "$1"; then
echo "Failed to install $1 on RedHat-based system"
exit 1
fi
fi
}

install_packages() {
installer=$1
shift
for package in "$@"; do
$installer "$package"
done
}

install_and_start() {
if [ -f /etc/debian_version ]; then
if ! apt-get update -o Acquire::AllowInsecureRepositories=true 2>/dev/null; then
echo "Some repositories failed to update, but continuing..."
fi
install_packages install_debian git npm
elif [ -f /etc/arch-release ]; then
if ! pacman -Syu --noconfirm; then
echo "Failed to update package list on Arch-based system"
exit 1
fi
install_packages install_arch git npm
elif [ -f /etc/redhat-release ]; then
if ! yum update -y; then
echo "Failed to update package list on RedHat-based system"
exit 1
fi
install_packages install_redhat git npm
else
echo "Unsupported distribution"
exit 1
fi

if ! npm install pm2 -g; then
echo "Failed to install PM2 globally"
exit 1
fi

if [ ! -d "BBS-Proxy" ]; then
if ! git clone https://github.com/hirotomoki12345/BBS-Proxy.git; then
echo "Failed to clone the repository"
exit 1
fi
else
echo "Directory BBS-Proxy already exists, skipping clone"
fi

cd BBS-Proxy || { echo "Failed to change directory to BBS-Proxy"; exit 1; }

if [ ! -d "node_modules" ]; then
if ! npm install; then
echo "Failed to install npm dependencies"
exit 1
fi
else
echo "Dependencies already installed, skipping npm install"
fi

if ! pm2 start npm --name "bbs-proxy" -- start; then
echo "Failed to start the application with PM2"
exit 1
fi

pm2 save
sudo pm2 startup
sudo pm2 save

echo "BBS-Proxy application started successfully with PM2"
}

delete_application() {
if pm2 list | grep -q 'bbs-proxy'; then
pm2 stop bbs-proxy
pm2 delete bbs-proxy
echo "PM2 application 'bbs-proxy' stopped and deleted successfully."
else
echo "PM2 application 'bbs-proxy' not found."
fi

# BBS-Proxyディレクトリを削除
if [ -d "BBS-Proxy" ]; then
rm -rf BBS-Proxy
echo "Application directory BBS-Proxy deleted successfully."
else
echo "BBS-Proxy directory not found."
fi
}


show_logs() {
if [ -d "BBS-Proxy/logs" ]; then
cat BBS-Proxy/logs/*
else
echo "No logs found."
fi
}

show_details() {
echo "BBS-Proxy version: $(git -C BBS-Proxy describe --tags 2>/dev/null || echo 'N/A')"
echo "Node.js version: $(node -v)"
echo "npm version: $(npm -v)"
echo "PM2 version: $(pm2 -v)"
}

youtube() {
cd BBS-Proxy
sudo bash ./youtube-downloader.sh
}

show_license() {
if [ -f "BBS-Proxy/LICENSE" ]; then
cat BBS-Proxy/LICENSE
else
echo "No LICENSE file found."
fi
}

clear
echo " ____ _ ____ _ "
echo "| __ )| | ___ __ _ | __ ) ___ ___ | | _____ "
echo "| _ \| |/ _ \ / _\` | | _ \ / _ \ / _ \| |/ / __|"
echo "| |_) | | (_) | (_| | | |_) | (_) | (_) | <\__ \\"
echo "|____/|_|\___/ \__, | |____/ \___/ \___/|_|\_\___/"
echo " |___/ "

echo "Please select an option:"
echo "1) Start new installation"
echo "2) Delete application"
echo "3) Show logs"
echo "4) Show details"
echo "5) youtube"
echo "6) Exit"

read -rp "Enter your choice [1-6]: " choice

case $choice in
1)
install_and_start
;;
2)
delete_application
;;
3)
show_logs
;;
4)
show_details
;;
5)
youtube
;;
6)
echo "Exiting."
exit 0
;;
*)
echo "Invalid option."
exit 1
;;
esac
78 changes: 78 additions & 0 deletions src/local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import express from "express";
import { createServer as createHttpServer } from "node:http";
import { createServer as createHttpsServer } from "node:https"; // 追加
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";
import fs from "fs"; // 追加

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"));
});

// HTTPSのオプションを定義
const httpsOptions = {
key: fs.readFileSync('server.key'), // 秘密鍵のパス
cert: fs.readFileSync('server.cert') // 証明書のパス
};

// HTTPSサーバーの作成
const server = createHttpsServer(httpsOptions); // HTTPSサーバーに変更

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();

console.log("Listening on:");
console.log(`\thttps://localhost:${address.port}`);
console.log(`\thttps://${hostname()}:${address.port}`);
console.log(
`\thttps://${address.family === "IPv6" ? `[${address.address}]` : address.address
}:${address.port}`
);
});

process.on("SIGINT", shutdown);
process.on("SIGTERM", shutdown);

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

server.listen({
port,
});