diff --git a/docs/vlc-sender.md b/docs/vlc-sender.md index 2b92401..1719cda 100644 --- a/docs/vlc-sender.md +++ b/docs/vlc-sender.md @@ -17,13 +17,13 @@ ### POST /api/send ```json -{ "ip": "243", "files": ["Torrents/movie.mkv"] } +{ "ip": "192.168.50.206", "port": 80, "files": ["Torrents/movie.mkv"] } ``` -Путь файла: `{volume_label}/{subpath}`. Ответ — SSE stream с событиями: `start`, `done`, `error`, `complete`. +Путь файла: `{volume_label}/{subpath}`. `port` опционален (по умолчанию 80). Ответ — SSE stream с событиями: `start`, `done`, `error`, `complete`. ## VLC API -VLC принимает файлы через `POST http://192.168.1.{ip}:8888/upload.json` (multipart/form-data, поле `file`). Порт 8888 — стандартный для VLC iOS WiFi Upload. +VLC принимает файлы через `POST http://{ip}:{port}/upload.json` (multipart/form-data, поле `files[]`). IP и порт вводятся в UI целиком. ## Переменные окружения diff --git a/src/index.ts b/src/index.ts index 9c9937d..85a25a1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,6 @@ import FormData from 'form-data'; const app = express(); const PORT = parseInt(process.env.PORT || '3000', 10); -const SUBNET_PREFIX = '192.168.1.'; // Parse volumes: "label1:/path1,label2:/path2" or just "/path1,/path2" interface Volume { @@ -210,13 +209,12 @@ app.post('/api/send', (req: Request, res: Response): void => { return; } - const ipNum = parseInt(ip, 10); - if (isNaN(ipNum) || ipNum < 1 || ipNum > 254) { - res.status(400).json({ error: 'Invalid IP suffix' }); + if (!/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(ip)) { + res.status(400).json({ error: 'Invalid IP address' }); return; } - const vlcHost = `${SUBNET_PREFIX}${ip}`; + const vlcHost = ip; const vlcPort = port && port > 0 && port <= 65535 ? port : 80; res.writeHead(200, { diff --git a/src/public/index.html b/src/public/index.html index cfd08f2..bb3fa1c 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -166,8 +166,7 @@