generated from Dicken/dickendock
round35: Vollstaendiger Portscan (1-65535) pro Geraet als Option, fuer Geraete mit vielen Diensten auf unueblichen Ports
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useMemo, useState, type FormEvent } from "react";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faBan, faCheck, faFloppyDisk, faPen, faTrash, faXmark, faSort, faSortUp, faSortDown } from "@fortawesome/free-solid-svg-icons";
|
||||
import { faBan, faCheck, faFloppyDisk, faPen, faTrash, faXmark, faSort, faSortUp, faSortDown, faMagnifyingGlassPlus } from "@fortawesome/free-solid-svg-icons";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { Button, Favicon } from "@launchpad/ui";
|
||||
import type { Service } from "@launchpad/shared";
|
||||
@@ -79,8 +79,8 @@ interface ScanResult {
|
||||
deviceNameSuggestion: string | null;
|
||||
}
|
||||
|
||||
async function scanDevice(id: string, signal?: AbortSignal): Promise<ScanResult> {
|
||||
const res = await fetch(`/api/scan/devices/${id}`, { method: "POST", signal });
|
||||
async function scanDevice(id: string, signal?: AbortSignal, full = false): Promise<ScanResult> {
|
||||
const res = await fetch(`/api/scan/devices/${id}${full ? "?full=true" : ""}`, { method: "POST", signal });
|
||||
const body = await res.json();
|
||||
if (!res.ok) {
|
||||
throw new Error(body.detail ?? body.error ?? `Scan fehlgeschlagen (HTTP ${res.status})`);
|
||||
@@ -326,10 +326,10 @@ function DeviceRow({ device }: { device: DeviceWithServices }) {
|
||||
const [scanAbort, setScanAbort] = useState<AbortController | null>(null);
|
||||
|
||||
const scanMutation = useMutation({
|
||||
mutationFn: () => {
|
||||
mutationFn: (full: boolean) => {
|
||||
const controller = new AbortController();
|
||||
setScanAbort(controller);
|
||||
return scanDevice(device.id, controller.signal);
|
||||
return scanDevice(device.id, controller.signal, full);
|
||||
},
|
||||
onSuccess: (result) => {
|
||||
const portsText = result.ports.length > 0 ? result.ports.join(", ") : "keine";
|
||||
@@ -414,12 +414,25 @@ function DeviceRow({ device }: { device: DeviceWithServices }) {
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
setScanMessage(null);
|
||||
scanMutation.mutate();
|
||||
scanMutation.mutate(false);
|
||||
}}
|
||||
disabled={scanMutation.isPending}
|
||||
>
|
||||
{scanMutation.isPending ? "Scanne …" : "Jetzt scannen"}
|
||||
</Button>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
setScanMessage("Vollständiger Portscan (1-65535) läuft, kann etwas dauern …");
|
||||
scanMutation.mutate(true);
|
||||
}}
|
||||
disabled={scanMutation.isPending}
|
||||
title="Vollständigen Portscan (alle 65535 Ports statt nur der üblichen) durchführen - für Geräte mit vielen Diensten auf unüblichen Ports"
|
||||
aria-label="Vollständigen Portscan durchführen"
|
||||
>
|
||||
<FontAwesomeIcon icon={faMagnifyingGlassPlus} />
|
||||
</Button>
|
||||
{scanMutation.isPending && scanAbort ? (
|
||||
<Button
|
||||
size="icon"
|
||||
|
||||
Reference in New Issue
Block a user