@onxdev/silentium 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1122 -0
- package/Cargo.toml +36 -0
- package/LICENSE +21 -0
- package/README.md +54 -2
- package/npm/bin/silentium.js +45 -0
- package/npm/install.js +31 -0
- package/npm/lib.js +220 -0
- package/package.json +44 -4
- package/rust-toolchain.toml +2 -0
- package/src/cli.rs +140 -0
- package/src/detect.rs +248 -0
- package/src/discord.rs +273 -0
- package/src/main.rs +345 -0
- package/src/net.rs +371 -0
- package/src/ui.rs +373 -0
package/Cargo.toml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "silentium"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
rust-version = "1.75"
|
|
6
|
+
description = "Discord voice kill switch: drop/mute/deafen every call participant, plus local voice-traffic shaping"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
authors = ["onx90s"]
|
|
9
|
+
repository = "https://github.com/onx90s/silentium"
|
|
10
|
+
homepage = "https://github.com/onx90s/silentium"
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
keywords = ["discord", "voice", "firewall", "qos", "cli"]
|
|
13
|
+
categories = ["command-line-utilities", "network-programming"]
|
|
14
|
+
|
|
15
|
+
[[bin]]
|
|
16
|
+
name = "silentium"
|
|
17
|
+
path = "src/main.rs"
|
|
18
|
+
|
|
19
|
+
[dependencies]
|
|
20
|
+
anyhow = "1"
|
|
21
|
+
clap = { version = "4", features = ["derive", "env"] }
|
|
22
|
+
ctrlc = "3"
|
|
23
|
+
serde = { version = "1", features = ["derive"] }
|
|
24
|
+
serde_json = "1"
|
|
25
|
+
|
|
26
|
+
[target.'cfg(windows)'.dependencies]
|
|
27
|
+
ureq = { version = "2.12", default-features = false, features = ["json", "native-tls", "gzip"] }
|
|
28
|
+
|
|
29
|
+
[target.'cfg(unix)'.dependencies]
|
|
30
|
+
ureq = { version = "2.12", default-features = false, features = ["json", "tls", "gzip"] }
|
|
31
|
+
|
|
32
|
+
[profile.release]
|
|
33
|
+
lto = "thin"
|
|
34
|
+
codegen-units = 1
|
|
35
|
+
strip = true
|
|
36
|
+
opt-level = 3
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 onx90s
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Silentium
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
```
|
|
4
|
+
██████╗ ██╗ ██╗ ██████╗ ███╗ ██╗ ████████╗ ██╗ ██╗ ██╗ ███╗ ███╗
|
|
5
|
+
██╔═══╝ ██║ ██║ ██╔═══╝ ████╗ ██║ ╚══██╔══╝ ██║ ██║ ██║ ████╗ ████║
|
|
6
|
+
██████╗ ██║ ██║ █████╗ ██╔██╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║
|
|
7
|
+
╚═══██║ ██║ ██║ ██╔══╝ ██║╚██╗██║ ██║ ██║ ██║ ██║ ██║╚██╔╝██║
|
|
8
|
+
██████║ ██║ ██████╗ ██████╗ ██║ ╚████║ ██║ ██║ ╚██████╔╝ ██║ ╚═╝ ██║
|
|
9
|
+
╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
|
|
10
|
+
```ill switch de voz para Discord. Detecta a call pelos sockets locais do cliente e corta, limita, muta ou derruba — sem plugin, sem injeção.
|
|
11
|
+
|
|
12
|
+
[](https://github.com/onx90s/silentium/releases)
|
|
13
|
+
[](https://www.npmjs.com/package/@onxdev/silentium)
|
|
14
|
+
[](https://github.com/onx90s/silentium/actions)
|
|
15
|
+
[](#licença)
|
|
16
|
+
|
|
17
|
+
## Instalar
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g @onxdev/silentium # baixa o binário do release
|
|
21
|
+
cargo install --git https://github.com/onx90s/silentium --locked
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Binário direto: assets `silentium-linux-x64`, `-linux-arm64`, `-darwin-x64`, `-darwin-arm64`, `-windows-x64.zip` em [releases](https://github.com/onx90s/silentium/releases), com `SHASUMS256.txt`.
|
|
25
|
+
|
|
26
|
+
## Usar
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
silentium # tela inicial: diagnóstico + menu
|
|
30
|
+
silentium detect # acha a call ativa, sem token
|
|
31
|
+
silentium voice drop --invite discord.gg/abc123
|
|
32
|
+
silentium net auto --seconds 30 # corta o Discord por 30s
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`net` corta só o processo do Discord — o resto da máquina fica intacto.
|
|
36
|
+
|
|
37
|
+
## Comandos
|
|
38
|
+
|
|
39
|
+
| | |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `detect` | call ativa pelos sockets locais, zero credencial |
|
|
42
|
+
| `net auto` / `block` / `unblock` / `throttle` | corta, limita, restaura o tráfego de voz |
|
|
43
|
+
| `voice list` / `drop` / `mute` / `deafen` / `restore` / `guard` | controle de participantes via REST |
|
|
44
|
+
| `resolve` | convite → guild + canal |
|
|
45
|
+
|
|
46
|
+
Controle de voz exige token com `MOVE_MEMBERS`, `MUTE_MEMBERS` e `DEAFEN_MEMBERS`.
|
|
47
|
+
|
|
48
|
+
## Build
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cargo build --release
|
|
52
|
+
./build.ps1 -Install # Windows: copia para %LOCALAPPDATA%\Silentium e põe no PATH
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
MIT.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// javascript — npm/bin/silentium.js — executa o binário nativo, instalando sob demanda
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { spawn } = require("node:child_process");
|
|
6
|
+
const lib = require("../lib.js");
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
let binary = lib.resolveBinary();
|
|
10
|
+
|
|
11
|
+
if (!binary) {
|
|
12
|
+
console.error("[silentium] primeira execução: preparando o binário…");
|
|
13
|
+
try {
|
|
14
|
+
binary = await lib.ensureBinary();
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.error(`[silentium] não consegui preparar o binário: ${err.message}`);
|
|
17
|
+
console.error(`[silentium] releases: https://github.com/${lib.REPO}/releases`);
|
|
18
|
+
console.error("[silentium] alternative: cargo install --git https://github.com/" + lib.REPO);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const child = spawn(binary, process.argv.slice(2), {
|
|
24
|
+
stdio: "inherit",
|
|
25
|
+
env: process.env,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
child.on("error", (err) => {
|
|
29
|
+
console.error(`[silentium] falha ao executar o binário: ${err.message}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
34
|
+
process.on(signal, () => {
|
|
35
|
+
if (!child.killed) child.kill(signal);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
child.on("exit", (code, signal) => {
|
|
40
|
+
if (signal) process.kill(process.pid, signal);
|
|
41
|
+
process.exit(code === null ? 1 : code);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
main();
|
package/npm/install.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// javascript — npm/install.js — postinstall best-effort: nunca derruba a instalação
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const lib = require("./lib.js");
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
if (process.env.SILENTIUM_SKIP_DOWNLOAD === "1") {
|
|
8
|
+
console.log("[silentium] SILENTIUM_SKIP_DOWNLOAD=1: download pulado");
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const existing = lib.resolveBinary();
|
|
13
|
+
if (existing) {
|
|
14
|
+
console.log(`[silentium] binário presente: ${existing}`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
await lib.ensureBinary();
|
|
20
|
+
} catch (err) {
|
|
21
|
+
// O shim do CLI tenta de novo no primeiro uso: aqui nunca falhamos o install.
|
|
22
|
+
console.warn(`[silentium] aviso: ${err.message}`);
|
|
23
|
+
console.warn("[silentium] o binário será baixado ou compilado no primeiro `silentium`");
|
|
24
|
+
if (process.env.SILENTIUM_STRICT === "1") throw err;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
main().catch((err) => {
|
|
29
|
+
console.warn(`[silentium] aviso: ${err.message}`);
|
|
30
|
+
if (process.env.SILENTIUM_STRICT === "1") process.exit(1);
|
|
31
|
+
});
|
package/npm/lib.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// javascript — npm/lib.js — plataforma, download do release e resolução do binário
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const os = require("node:os");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const crypto = require("node:crypto");
|
|
8
|
+
const https = require("node:https");
|
|
9
|
+
const { execFileSync } = require("node:child_process");
|
|
10
|
+
|
|
11
|
+
const REPO = "onx90s/silentium";
|
|
12
|
+
const PKG_ROOT = path.join(__dirname, "..");
|
|
13
|
+
const VENDOR = path.join(__dirname, "vendor");
|
|
14
|
+
|
|
15
|
+
function packageVersion() {
|
|
16
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(PKG_ROOT, "package.json"), "utf8"));
|
|
17
|
+
return pkg.version;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function platformTag() {
|
|
21
|
+
const platform = process.platform;
|
|
22
|
+
const arch = process.arch;
|
|
23
|
+
if (platform === "linux" && (arch === "x64" || arch === "arm64")) return { platform: "linux", arch };
|
|
24
|
+
if (platform === "darwin" && (arch === "x64" || arch === "arm64")) return { platform: "darwin", arch };
|
|
25
|
+
if (platform === "win32" && arch === "x64") return { platform: "windows", arch };
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function isMusl() {
|
|
30
|
+
if (process.platform !== "linux") return false;
|
|
31
|
+
try {
|
|
32
|
+
const report = process.report && process.report.getReport();
|
|
33
|
+
return Boolean(report) && !report.header.glibcVersionRuntime;
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function binaryName() {
|
|
40
|
+
return process.platform === "win32" ? "silentium.exe" : "silentium";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function assetName(tag) {
|
|
44
|
+
const ext = tag.platform === "windows" ? "zip" : "tar.gz";
|
|
45
|
+
return `silentium-${tag.platform}-${tag.arch}.${ext}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function vendorBinary() {
|
|
49
|
+
return path.join(VENDOR, binaryName());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function localBuildBinary() {
|
|
53
|
+
const name = binaryName();
|
|
54
|
+
const candidates = [
|
|
55
|
+
path.join(PKG_ROOT, "target", "release", name),
|
|
56
|
+
path.join(PKG_ROOT, "..", "target", "release", name),
|
|
57
|
+
];
|
|
58
|
+
return candidates.find((p) => fs.existsSync(p)) || null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Ordem: SILENTIUM_BINARY -> vendor/ -> build local do cargo.
|
|
62
|
+
function resolveBinary() {
|
|
63
|
+
const override = process.env.SILENTIUM_BINARY;
|
|
64
|
+
if (override && fs.existsSync(override)) return override;
|
|
65
|
+
const vendored = vendorBinary();
|
|
66
|
+
if (fs.existsSync(vendored)) return vendored;
|
|
67
|
+
const built = localBuildBinary();
|
|
68
|
+
if (built) return built;
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function download(url, destination, redirects = 0) {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
if (redirects > 5) return reject(new Error("redirects demais"));
|
|
75
|
+
https
|
|
76
|
+
.get(url, { headers: { "user-agent": `silentium-npm/${packageVersion()}` } }, (res) => {
|
|
77
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
78
|
+
res.resume();
|
|
79
|
+
return resolve(download(res.headers.location, destination, redirects + 1));
|
|
80
|
+
}
|
|
81
|
+
if (res.statusCode !== 200) {
|
|
82
|
+
res.resume();
|
|
83
|
+
return reject(new Error(`HTTP ${res.statusCode} em ${url}`));
|
|
84
|
+
}
|
|
85
|
+
const file = fs.createWriteStream(destination);
|
|
86
|
+
res.pipe(file);
|
|
87
|
+
file.on("finish", () => file.close(() => resolve(destination)));
|
|
88
|
+
file.on("error", reject);
|
|
89
|
+
})
|
|
90
|
+
.on("error", reject);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function fetchText(url) {
|
|
95
|
+
const tmp = path.join(os.tmpdir(), `silentium-${process.pid}-${Date.now()}.txt`);
|
|
96
|
+
await download(url, tmp);
|
|
97
|
+
const text = fs.readFileSync(tmp, "utf8");
|
|
98
|
+
fs.rmSync(tmp, { force: true });
|
|
99
|
+
return text;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function sha256(file) {
|
|
103
|
+
return crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function extract(archive, tag, into) {
|
|
107
|
+
if (tag.platform === "windows") {
|
|
108
|
+
execFileSync(
|
|
109
|
+
"powershell",
|
|
110
|
+
["-NoProfile", "-NonInteractive", "-Command", `Expand-Archive -Path '${archive}' -DestinationPath '${into}' -Force`],
|
|
111
|
+
{ stdio: "inherit" }
|
|
112
|
+
);
|
|
113
|
+
} else {
|
|
114
|
+
execFileSync("tar", ["-xzf", archive, "-C", into], { stdio: "inherit" });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function downloadRelease(tag) {
|
|
119
|
+
const version = packageVersion();
|
|
120
|
+
const base = `https://github.com/${REPO}/releases/download/v${version}`;
|
|
121
|
+
const asset = assetName(tag);
|
|
122
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "silentium-"));
|
|
123
|
+
const archive = path.join(tmpDir, asset);
|
|
124
|
+
|
|
125
|
+
await download(`${base}/${asset}`, archive);
|
|
126
|
+
|
|
127
|
+
let expected = null;
|
|
128
|
+
try {
|
|
129
|
+
const sums = await fetchText(`${base}/SHASUMS256.txt`);
|
|
130
|
+
const line = sums.split("\n").find((l) => l.trim().endsWith(asset));
|
|
131
|
+
if (line) expected = line.trim().split(/\s+/)[0];
|
|
132
|
+
} catch {
|
|
133
|
+
// release sem checksums: segue, mas avisa
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (expected) {
|
|
137
|
+
const actual = sha256(archive);
|
|
138
|
+
if (actual !== expected) {
|
|
139
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
140
|
+
throw new Error(`checksum não bate: esperado ${expected}, obtido ${actual}`);
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
console.warn("[silentium] aviso: SHASUMS256.txt ausente no release, pulando verificação");
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
extract(archive, tag, tmpDir);
|
|
147
|
+
const candidates = [
|
|
148
|
+
path.join(tmpDir, binaryName()),
|
|
149
|
+
path.join(tmpDir, "silentium", binaryName()),
|
|
150
|
+
];
|
|
151
|
+
const found = candidates.find((p) => fs.existsSync(p));
|
|
152
|
+
if (!found) {
|
|
153
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
154
|
+
throw new Error("binário não encontrado dentro do arquivo baixado");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
fs.mkdirSync(VENDOR, { recursive: true });
|
|
158
|
+
const target = vendorBinary();
|
|
159
|
+
fs.copyFileSync(found, target);
|
|
160
|
+
if (process.platform !== "win32") fs.chmodSync(target, 0o755);
|
|
161
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
162
|
+
return target;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function buildFromSource() {
|
|
166
|
+
const cargoToml = path.join(PKG_ROOT, "Cargo.toml");
|
|
167
|
+
if (!fs.existsSync(cargoToml)) {
|
|
168
|
+
throw new Error("sem Cargo.toml: este pacote não traz código-fonte para compilar");
|
|
169
|
+
}
|
|
170
|
+
execFileSync("cargo", ["build", "--release", "--locked"], {
|
|
171
|
+
cwd: PKG_ROOT,
|
|
172
|
+
stdio: "inherit",
|
|
173
|
+
});
|
|
174
|
+
const built = localBuildBinary();
|
|
175
|
+
if (!built) throw new Error("cargo terminou sem produzir o binário");
|
|
176
|
+
fs.mkdirSync(VENDOR, { recursive: true });
|
|
177
|
+
const target = vendorBinary();
|
|
178
|
+
fs.copyFileSync(built, target);
|
|
179
|
+
if (process.platform !== "win32") fs.chmodSync(target, 0o755);
|
|
180
|
+
return target;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Instala o binário se ainda não estiver presente: release -> cargo.
|
|
184
|
+
async function ensureBinary({ quiet = false } = {}) {
|
|
185
|
+
const existing = resolveBinary();
|
|
186
|
+
if (existing) return existing;
|
|
187
|
+
|
|
188
|
+
const tag = platformTag();
|
|
189
|
+
if (tag && !isMusl()) {
|
|
190
|
+
try {
|
|
191
|
+
const target = await downloadRelease(tag);
|
|
192
|
+
if (!quiet) console.log(`[silentium] binário instalado: ${target}`);
|
|
193
|
+
return target;
|
|
194
|
+
} catch (err) {
|
|
195
|
+
if (!quiet) console.warn(`[silentium] download falhou (${err.message}); tentando compilar`);
|
|
196
|
+
}
|
|
197
|
+
} else if (!quiet) {
|
|
198
|
+
console.warn(`[silentium] sem binário pronto para ${process.platform}/${process.arch}; compilando`);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const target = buildFromSource();
|
|
202
|
+
if (!quiet) console.log(`[silentium] binário compilado: ${target}`);
|
|
203
|
+
return target;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
module.exports = {
|
|
207
|
+
ensureBinary,
|
|
208
|
+
REPO,
|
|
209
|
+
PKG_ROOT,
|
|
210
|
+
VENDOR,
|
|
211
|
+
packageVersion,
|
|
212
|
+
platformTag,
|
|
213
|
+
assetName,
|
|
214
|
+
binaryName,
|
|
215
|
+
vendorBinary,
|
|
216
|
+
resolveBinary,
|
|
217
|
+
downloadRelease,
|
|
218
|
+
buildFromSource,
|
|
219
|
+
isMusl,
|
|
220
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onxdev/silentium",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Kill switch de voz para Discord: detecta a call pelos sockets locais e corta, limita, muta ou derruba participantes",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"discord",
|
|
7
|
+
"voice",
|
|
8
|
+
"kill-switch",
|
|
9
|
+
"firewall",
|
|
10
|
+
"qos",
|
|
11
|
+
"audio",
|
|
12
|
+
"cli",
|
|
13
|
+
"rust"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "onx90s",
|
|
17
|
+
"homepage": "https://github.com/onx90s/silentium#readme",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/onx90s/silentium.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/onx90s/silentium/issues"
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"silentium": "npm/bin/silentium.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"npm/",
|
|
30
|
+
"src/",
|
|
31
|
+
"Cargo.toml",
|
|
32
|
+
"Cargo.lock",
|
|
33
|
+
"rust-toolchain.toml",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"setup": "node npm/install.js"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/cli.rs
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// rust — src/cli.rs — superfície de argumentos
|
|
2
|
+
use clap::{Args, Parser, Subcommand};
|
|
3
|
+
|
|
4
|
+
#[derive(Parser, Debug)]
|
|
5
|
+
#[command(
|
|
6
|
+
name = "silentium",
|
|
7
|
+
version,
|
|
8
|
+
about = "Kill switch de voz para call do Discord",
|
|
9
|
+
long_about = "Detecta a call ativa pelos sockets locais do Discord e derruba o tráfego\n\
|
|
10
|
+
dele por firewall (só o Discord, resto do PC intacto). Também desc,\n\
|
|
11
|
+
muta e ensurdece participantes via REST quando há token de bot com\n\
|
|
12
|
+
MOVE_MEMBERS / MUTE_MEMBERS / DEAFEN_MEMBERS."
|
|
13
|
+
)]
|
|
14
|
+
pub struct Cli {
|
|
15
|
+
/// Token de bot, ou de usuário com --user-token (sem prefixo "Bot").
|
|
16
|
+
#[arg(long, env = "DISCORD_TOKEN", global = true)]
|
|
17
|
+
pub token: Option<String>,
|
|
18
|
+
|
|
19
|
+
/// Trata o token como token de usuário (sem prefixo "Bot ").
|
|
20
|
+
#[arg(long, global = true)]
|
|
21
|
+
pub user_token: bool,
|
|
22
|
+
|
|
23
|
+
/// ID do servidor. Pode ser omitido quando --invite é usado.
|
|
24
|
+
#[arg(long, env = "GUILD_ID", global = true)]
|
|
25
|
+
pub guild: Option<String>,
|
|
26
|
+
|
|
27
|
+
/// Intervalo entre chamadas REST, em ms.
|
|
28
|
+
#[arg(long, global = true, default_value_t = 150)]
|
|
29
|
+
pub delay_ms: u64,
|
|
30
|
+
|
|
31
|
+
/// Mostra o que faria, sem executar.
|
|
32
|
+
#[arg(long, global = true)]
|
|
33
|
+
pub dry_run: bool,
|
|
34
|
+
|
|
35
|
+
/// Sem subcomando, abre a tela inicial interativa.
|
|
36
|
+
#[command(subcommand)]
|
|
37
|
+
pub cmd: Option<Cmd>,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#[derive(Subcommand, Debug, Clone)]
|
|
41
|
+
pub enum Cmd {
|
|
42
|
+
/// Valida o token e mostra a conta do bot.
|
|
43
|
+
Whoami,
|
|
44
|
+
/// Resolve um convite (discord.gg/xxx) em guild + canal.
|
|
45
|
+
Resolve { invite: String },
|
|
46
|
+
/// Detecta a call ativa olhando os sockets locais do Discord. Não usa API.
|
|
47
|
+
Detect,
|
|
48
|
+
/// Operações na sessão de voz.
|
|
49
|
+
#[command(subcommand)]
|
|
50
|
+
Voice(VoiceCmd),
|
|
51
|
+
/// Shaping de rede no tráfego de voz.
|
|
52
|
+
#[command(subcommand)]
|
|
53
|
+
Net(NetCmd),
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#[derive(Args, Debug, Clone, Default)]
|
|
57
|
+
pub struct TargetArgs {
|
|
58
|
+
/// Restringe a um canal de voz específico.
|
|
59
|
+
#[arg(long)]
|
|
60
|
+
pub channel: Option<String>,
|
|
61
|
+
/// Alvo específico (repetível). Sem isso, todos em voz.
|
|
62
|
+
#[arg(long = "user")]
|
|
63
|
+
pub user: Vec<String>,
|
|
64
|
+
/// Convite da call; extrai guild e canal dele.
|
|
65
|
+
#[arg(long)]
|
|
66
|
+
pub invite: Option<String>,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#[derive(Subcommand, Debug, Clone)]
|
|
70
|
+
pub enum VoiceCmd {
|
|
71
|
+
/// Quem está em voz agora.
|
|
72
|
+
List(TargetArgs),
|
|
73
|
+
/// Desconecta da voz (channel_id: null).
|
|
74
|
+
Drop(TargetArgs),
|
|
75
|
+
/// Muta no servidor.
|
|
76
|
+
Mute(TargetArgs),
|
|
77
|
+
/// Desmuta.
|
|
78
|
+
Unmute(TargetArgs),
|
|
79
|
+
/// Ensurdece no servidor.
|
|
80
|
+
Deafen(TargetArgs),
|
|
81
|
+
/// Remove deafen.
|
|
82
|
+
Undeafen(TargetArgs),
|
|
83
|
+
/// Desfaz mute e deafen de todos.
|
|
84
|
+
Restore(TargetArgs),
|
|
85
|
+
/// Vigia o canal e derruba quem entrar.
|
|
86
|
+
Guard {
|
|
87
|
+
#[command(flatten)]
|
|
88
|
+
target: TargetArgs,
|
|
89
|
+
/// Ação aplicada a quem entrar: drop | mute | deafen.
|
|
90
|
+
#[arg(long, default_value = "drop")]
|
|
91
|
+
action: String,
|
|
92
|
+
/// Intervalo de polling, em segundos.
|
|
93
|
+
#[arg(long, default_value_t = 2)]
|
|
94
|
+
interval: u64,
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#[derive(Subcommand, Debug, Clone)]
|
|
99
|
+
pub enum NetCmd {
|
|
100
|
+
/// Aplica shaping no UDP de voz (50000-65535).
|
|
101
|
+
Throttle {
|
|
102
|
+
/// Banda permitida para o áudio, em kbps. 8 degrada, 2 mata.
|
|
103
|
+
#[arg(long, default_value_t = 8)]
|
|
104
|
+
kbps: u64,
|
|
105
|
+
/// Perda de pacotes, em %. Linux.
|
|
106
|
+
#[arg(long)]
|
|
107
|
+
loss: Option<u8>,
|
|
108
|
+
/// Latência adicional, em ms. Linux.
|
|
109
|
+
#[arg(long = "latency")]
|
|
110
|
+
delay: Option<u32>,
|
|
111
|
+
/// Duração em segundos. Sem isso, permanece até `net clear`.
|
|
112
|
+
#[arg(long)]
|
|
113
|
+
seconds: Option<u64>,
|
|
114
|
+
/// Interface de saída. Autodetectada se omitida.
|
|
115
|
+
#[arg(long)]
|
|
116
|
+
iface: Option<String>,
|
|
117
|
+
},
|
|
118
|
+
/// Remove todo o shaping aplicado.
|
|
119
|
+
Clear {
|
|
120
|
+
#[arg(long)]
|
|
121
|
+
iface: Option<String>,
|
|
122
|
+
},
|
|
123
|
+
/// Corta a internet SÓ do Discord (firewall por processo). Outros apps seguem normais.
|
|
124
|
+
Block {
|
|
125
|
+
/// Duração em segundos. Sem isso, fica até Enter/Ctrl-C.
|
|
126
|
+
#[arg(long)]
|
|
127
|
+
seconds: Option<u64>,
|
|
128
|
+
},
|
|
129
|
+
/// Desfaz o bloqueio.
|
|
130
|
+
Unblock,
|
|
131
|
+
/// Detecta a call ativa e corta o Discord por N segundos.
|
|
132
|
+
Auto {
|
|
133
|
+
/// Duração em segundos. Sem isso, fica até Enter/Ctrl-C.
|
|
134
|
+
#[arg(long)]
|
|
135
|
+
seconds: Option<u64>,
|
|
136
|
+
/// Corta mesmo se nenhuma call for detectada.
|
|
137
|
+
#[arg(long)]
|
|
138
|
+
force: bool,
|
|
139
|
+
},
|
|
140
|
+
}
|