feat: use full IP address instead of subnet suffix
This commit is contained in:
@@ -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 целиком.
|
||||
|
||||
## Переменные окружения
|
||||
|
||||
|
||||
@@ -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, {
|
||||
|
||||
@@ -166,8 +166,7 @@
|
||||
|
||||
<div class="toolbar">
|
||||
<div class="ip-group">
|
||||
<span>192.168.1.</span>
|
||||
<input type="text" id="ipInput" placeholder="___" maxlength="3" inputmode="numeric">
|
||||
<input type="text" id="ipInput" placeholder="192.168.50.xxx" style="width:140px">
|
||||
<span>:</span>
|
||||
<input type="text" id="portInput" placeholder="80" maxlength="5" inputmode="numeric" style="width:45px">
|
||||
</div>
|
||||
@@ -233,8 +232,7 @@
|
||||
|
||||
function updateSendBtn() {
|
||||
const ip = ipInput.value.trim();
|
||||
const ipNum = parseInt(ip, 10);
|
||||
const validIp = ip && !isNaN(ipNum) && ipNum >= 1 && ipNum <= 254;
|
||||
const validIp = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(ip);
|
||||
sendBtn.disabled = sending || selectedFiles.size === 0 || !validIp;
|
||||
}
|
||||
|
||||
@@ -387,6 +385,7 @@
|
||||
|
||||
const port = parseInt(portInput.value.trim(), 10) || 80;
|
||||
const body = JSON.stringify({ ip, port, files });
|
||||
console.log('Sending to', ip + ':' + port, files);
|
||||
fetch('/api/send', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
|
||||
Reference in New Issue
Block a user