Skip to content

Commit

Permalink
fix vmess link
Browse files Browse the repository at this point in the history
  • Loading branch information
amiremohamadi committed Jun 11, 2024
1 parent b4aa455 commit 702a55f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 54 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ crate-type = ["cdylib"]
[dependencies]
tokio = { version = "1.28", features = ["io-util", "rt"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
base64 = "0.22"
getrandom = { version = "0.2", features = ["js"] }
worker = "0.0.18"
futures-util = "0.3.28"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ and visit https://{YOUR-WORKERS-SUBDOMAIN}.workers.dev/link to get the config li
$ make deploy
```

4. Modify the [xray config](./config/xray.json) and run:
4. Modify the [xray config](./config/vmess.json) and run:
```sh
$ xray -c ./config/xray.json
```
43 changes: 0 additions & 43 deletions config/vless.json

This file was deleted.

7 changes: 2 additions & 5 deletions config/vmess.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"settings": {
"vnext": [
{
"address": "CLOUDFLARE_CLEAN_IP",
"port": 80,
"address": "localhost",
"port": 8787,
"users": [
{
"id": "0fbf4f81-2598-4b6a-a623-0ead4cb9efa8",
Expand All @@ -32,9 +32,6 @@
"streamSettings": {
"network": "ws",
"wsSettings" : {
"headers": {
"Host": "CF_WORKERS_SUBDOMAIN"
}
}
}
}
Expand Down
30 changes: 25 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ mod proxy;
use crate::config::Config;
use crate::proxy::*;

use base64::{engine::general_purpose::URL_SAFE, Engine as _};
use serde::Serialize;
use serde_json::json;
use uuid::Uuid;
use worker::*;

Expand Down Expand Up @@ -45,13 +47,31 @@ fn link(_: Request, cx: RouteContext<Config>) -> Result<Response> {
link: String,
}

let link = format!(
"vmess://{}@104.24.30.167:80?encryption=zero&type=ws&security=none&host={}#tunl",
cx.data.uuid, cx.data.host
);
let link = {
let host = cx.data.host.to_string();
let uuid = cx.data.uuid.to_string();
let config = json!({
"ps": "tunl",
"v": "2",
"add": "162.159.16.149",
"port": "80",
"id": uuid,
"aid": "0",
"scy": "zero",
"net": "ws",
"type": "none",
"host": host,
"path": "",
"tls": "",
"sni": "",
"alpn": ""}
);
format!("vmess://{}", URL_SAFE.encode(config.to_string()))
};

Response::from_json(&Link {
link,
description: "visit https://scanner.github1.cloud/ and replace the IP address in the configuration with a clean one".to_string()
description:
"visit https://scanner.github1.cloud/ and replace the IP address in the configuration with a clean one".to_string()
})
}

0 comments on commit 702a55f

Please sign in to comment.