Compare commits

...

2 Commits

Author SHA1 Message Date
Maxi Quoß 69acc57ed2 fix: save failed when creating new device 2025-03-18 01:37:27 +01:00
Maxi Quoß c9bc0c8f38 fix: port check ignore connection refused error 2025-03-18 01:27:02 +01:00
2 changed files with 34 additions and 5 deletions
+4 -2
View File
@@ -77,10 +77,12 @@ func CheckPort(host string, port string) (bool, error) {
timeout := 500 * time.Millisecond
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, port), timeout)
if err != nil {
// treat "host unreachable" and "timeout" as no error
// treat "host unreachable", "connection refused" and "timeout" as no error
var netErr *net.OpError
if errors.As(err, &netErr) {
if errors.Is(netErr.Err, syscall.EHOSTUNREACH) || netErr.Timeout() {
if errors.Is(netErr.Err, syscall.EHOSTUNREACH) ||
errors.Is(netErr.Err, syscall.ECONNREFUSED) ||
netErr.Timeout() {
return false, nil
}
}
+30 -3
View File
@@ -5,16 +5,43 @@
import NetworkScan from '$lib/components/NetworkScan.svelte';
import { m } from '$lib/paraglide/messages';
import { permission, pocketbase } from '$lib/stores/pocketbase';
import type { Device, Port } from '$lib/types/device';
import type { Device, Group, Port } from '$lib/types/device';
import { faBinoculars, faWrench } from '@fortawesome/free-solid-svg-icons';
import Fa from 'svelte-fa';
import toast from 'svelte-french-toast';
let device: Device = {
name: '',
ip: '',
mac: '',
netmask: '',
description: '',
status: '',
ports: [] as string[],
link_open: '',
ping_cmd: '',
wake_cron: '',
wake_cron_enabled: false,
wake_cmd: '',
wake_confirm: false,
wake_timeout: 0,
shutdown_cron: '',
shutdown_cron_enabled: false,
shutdown_cmd: '',
shutdown_confirm: false,
shutdown_timeout: 0,
password: '',
groups: [] as string[],
expand: {
ports: [] as Port[]
ports: [] as Port[],
groups: [] as Group[]
},
groups: [] as string[]
created_by: '',
sol_enabled: false,
sol_auth: false,
sol_user: '',
sol_password: '',
sol_port: 0
} as Device;
$: if (Object.hasOwn($permission, 'create')) {