This commit is contained in:
henrygd
2026-04-29 17:59:30 -04:00
parent d2eb3b259a
commit 099935e78e
6 changed files with 130 additions and 112 deletions

View File

@@ -221,6 +221,5 @@ func (h *SyncNetworkProbesHandler) Handle(hctx *HandlerContext) error {
if err != nil { if err != nil {
return err return err
} }
slog.Info("network probes synced", "action", req.Action)
return hctx.SendResponse(resp, hctx.RequestID) return hctx.SendResponse(resp, hctx.RequestID)
} }

View File

@@ -333,7 +333,8 @@ func (pm *ProbeManager) runProbe(task *probeTask, runNow bool) {
} }
stagger := getStagger(interval.Milliseconds()) stagger := getStagger(interval.Milliseconds())
slog.Info("starting probe task", "id", task.config.ID, "initial_delay", stagger.String(), "interval", interval.String())
slog.Debug("starting probe task", "target", task.config.Target, "delay", stagger.String(), "interval", interval.String())
if runNow { if runNow {
pm.executeProbe(task) pm.executeProbe(task)
@@ -341,10 +342,9 @@ func (pm *ProbeManager) runProbe(task *probeTask, runNow bool) {
select { select {
case <-task.cancel: case <-task.cancel:
slog.Info("removed probe", "id", task.config.ID) // slog.Info("removed probe", "target", task.config.Target)
return return
case <-time.After(stagger): case <-time.After(stagger):
slog.Info("initial probe execution", "id", task.config.ID)
pm.executeProbe(task) pm.executeProbe(task)
} }
@@ -353,16 +353,15 @@ func (pm *ProbeManager) runProbe(task *probeTask, runNow bool) {
for { for {
select { select {
case <-task.cancel: case <-task.cancel:
slog.Info("removed probe", "id", task.config.ID) // slog.Info("removed probe", "target", task.config.Target)
return return
case <-ticker: case <-ticker:
slog.Info("running probe in main loop", "id", task.config.ID, "interval", interval.String())
pm.executeProbe(task) pm.executeProbe(task)
} }
} }
} }
// getStagger returns a random duration between intervalSeconds/2 and intervalSeconds to stagger probe executions // getStagger returns a random duration between intervalSeconds/2 and intervalSeconds to stagger initial probe executions
func getStagger(intervalMilli int64) time.Duration { func getStagger(intervalMilli int64) time.Duration {
intervalMilliInt := int(intervalMilli) intervalMilliInt := int(intervalMilli)
randomDelayInt := rand.Intn(intervalMilliInt) randomDelayInt := rand.Intn(intervalMilliInt)
@@ -472,20 +471,26 @@ func (task *probeTask) addSampleLocked(sample probeSample) {
// executeProbe runs the configured probe and records the sample. // executeProbe runs the configured probe and records the sample.
func (pm *ProbeManager) executeProbe(task *probeTask) { func (pm *ProbeManager) executeProbe(task *probeTask) {
// slog.Info("running probe", "id", task.config.ID, "interval", task.config.Interval)
var responseUs int64 var responseUs int64
var err error
switch task.config.Protocol { switch task.config.Protocol {
case "icmp": case "icmp":
responseUs = probeICMP(task.config.Target) responseUs, err = probeICMP(task.config.Target)
case "tcp": case "tcp":
responseUs = probeTCP(task.config.Target, task.config.Port) responseUs, err = probeTCP(task.config.Target, task.config.Port)
case "http": case "http":
responseUs = probeHTTP(pm.httpClient, task.config.Target) responseUs, err = probeHTTP(pm.httpClient, task.config.Target)
default: default:
slog.Warn("unknown probe protocol", "protocol", task.config.Protocol) slog.Warn("unknown probe protocol", "protocol", task.config.Protocol)
return return
} }
if err != nil {
slog.Warn("probe failed", "err", err, "target", task.config.Target, "protocol", task.config.Protocol)
}
sample := probeSample{ sample := probeSample{
responseUs: responseUs, responseUs: responseUs,
timestamp: time.Now(), timestamp: time.Now(),
@@ -497,12 +502,12 @@ func (pm *ProbeManager) executeProbe(task *probeTask) {
} }
// probeTCP measures pure TCP handshake response (excluding DNS resolution). // probeTCP measures pure TCP handshake response (excluding DNS resolution).
// Returns -1 on failure. // Returns -1 and an error on failure.
func probeTCP(target string, port uint16) int64 { func probeTCP(target string, port uint16) (int64, error) {
// Resolve DNS first, outside the timing window // Resolve DNS first, outside the timing window
ips, err := net.LookupHost(target) ips, err := net.LookupHost(target)
if err != nil || len(ips) == 0 { if err != nil || len(ips) == 0 {
return -1 return -1, err
} }
addr := net.JoinHostPort(ips[0], fmt.Sprintf("%d", port)) addr := net.JoinHostPort(ips[0], fmt.Sprintf("%d", port))
@@ -510,25 +515,25 @@ func probeTCP(target string, port uint16) int64 {
start := time.Now() start := time.Now()
conn, err := net.DialTimeout("tcp", addr, 3*time.Second) conn, err := net.DialTimeout("tcp", addr, 3*time.Second)
if err != nil { if err != nil {
return -1 return -1, err
} }
conn.Close() conn.Close()
return time.Since(start).Microseconds() return time.Since(start).Microseconds(), nil
} }
// probeHTTP measures HTTP GET request response in microseconds. Returns -1 on failure. // probeHTTP measures HTTP GET request response in microseconds. Returns -1 and an error on failure.
func probeHTTP(client *http.Client, url string) int64 { func probeHTTP(client *http.Client, url string) (int64, error) {
if client == nil { if client == nil {
client = http.DefaultClient client = http.DefaultClient
} }
start := time.Now() start := time.Now()
resp, err := client.Get(url) resp, err := client.Get(url)
if err != nil { if err != nil {
return -1 return -1, err
} }
resp.Body.Close() resp.Body.Close()
if resp.StatusCode >= 400 { if resp.StatusCode >= 400 {
return -1 return -1, fmt.Errorf("HTTP error: %s", resp.Status)
} }
return time.Since(start).Microseconds() return time.Since(start).Microseconds(), nil
} }

View File

@@ -1,6 +1,7 @@
package agent package agent
import ( import (
"errors"
"math" "math"
"net" "net"
"os" "os"
@@ -27,7 +28,7 @@ type icmpPacketConn interface {
// icmpMethod tracks which ICMP approach to use. Once a method succeeds or // icmpMethod tracks which ICMP approach to use. Once a method succeeds or
// all native methods fail, the choice is cached so subsequent probes skip // all native methods fail, the choice is cached so subsequent probes skip
// the trial-and-error overhead. // the trial-and-error overhead.
type icmpMethod int type icmpMethod uint8
const ( const (
icmpUntried icmpMethod = iota // haven't tried yet icmpUntried icmpMethod = iota // haven't tried yet
@@ -76,11 +77,11 @@ var (
// Supports both IPv4 and IPv6 targets. The ICMP method (raw socket, // Supports both IPv4 and IPv6 targets. The ICMP method (raw socket,
// unprivileged datagram, or exec fallback) is detected once per address // unprivileged datagram, or exec fallback) is detected once per address
// family and cached for subsequent probes. // family and cached for subsequent probes.
// Returns response in microseconds, or -1 on failure. // Returns response in microseconds, or -1 and an error on failure.
func probeICMP(target string) int64 { func probeICMP(target string) (int64, error) {
family, ip := resolveICMPTarget(target) family, ip, err := resolveICMPTarget(target)
if family == nil { if err != nil {
return -1 return -1, err
} }
icmpModeMu.Lock() icmpModeMu.Lock()
@@ -98,30 +99,30 @@ func probeICMP(target string) int64 {
case icmpExecFallback: case icmpExecFallback:
return probeICMPExec(target, family.isIPv6) return probeICMPExec(target, family.isIPv6)
default: default:
return -1 return -1, errors.New("unsupported ICMP mode")
} }
} }
// resolveICMPTarget resolves a target hostname or IP to determine the address // resolveICMPTarget resolves a target hostname or IP to determine the address
// family and concrete IP address. Prefers IPv4 for dual-stack hostnames. // family and concrete IP address. Prefers IPv4 for dual-stack hostnames.
func resolveICMPTarget(target string) (*icmpFamily, net.IP) { func resolveICMPTarget(target string) (*icmpFamily, net.IP, error) {
if ip := net.ParseIP(target); ip != nil { if ip := net.ParseIP(target); ip != nil {
if ip.To4() != nil { if ip.To4() != nil {
return &icmpV4, ip.To4() return &icmpV4, ip.To4(), nil
} }
return &icmpV6, ip return &icmpV6, ip, nil
} }
ips, err := net.LookupIP(target) ips, err := net.LookupIP(target)
if err != nil || len(ips) == 0 { if err != nil || len(ips) == 0 {
return nil, nil return nil, nil, err
} }
for _, ip := range ips { for _, ip := range ips {
if v4 := ip.To4(); v4 != nil { if v4 := ip.To4(); v4 != nil {
return &icmpV4, v4 return &icmpV4, v4, nil
} }
} }
return &icmpV6, ips[0] return &icmpV6, ips[0], nil
} }
func detectICMPMode(family *icmpFamily, listen func(network, listenAddr string) (icmpPacketConn, error)) icmpMethod { func detectICMPMode(family *icmpFamily, listen func(network, listenAddr string) (icmpPacketConn, error)) icmpMethod {
@@ -130,31 +131,28 @@ func detectICMPMode(family *icmpFamily, listen func(network, listenAddr string)
label = "IPv6" label = "IPv6"
} }
if conn, err := listen(family.rawNetwork, family.listenAddr); err == nil { conn, err := listen(family.rawNetwork, family.listenAddr)
slog.Debug("ICMP raw socket test", "family", label, "err", err)
if err == nil {
conn.Close() conn.Close()
slog.Info("ICMP probe using raw socket", "family", label)
return icmpRaw return icmpRaw
} else {
slog.Debug("ICMP raw socket unavailable", "family", label, "err", err)
} }
if conn, err := listen(family.dgramNetwork, family.listenAddr); err == nil { conn, err = listen(family.dgramNetwork, family.listenAddr)
slog.Debug("ICMP datagram socket test", "family", label, "err", err)
if err == nil {
conn.Close() conn.Close()
slog.Info("ICMP probe using unprivileged datagram socket", "family", label)
return icmpDatagram return icmpDatagram
} else {
slog.Debug("ICMP datagram socket unavailable", "family", label, "err", err)
} }
slog.Info("ICMP probe falling back to system ping command", "family", label)
return icmpExecFallback return icmpExecFallback
} }
// probeICMPNative sends an ICMP echo request using Go's x/net/icmp package. // probeICMPNative sends an ICMP echo request using Go's x/net/icmp package.
func probeICMPNative(network string, family *icmpFamily, dst net.Addr) int64 { func probeICMPNative(network string, family *icmpFamily, dst net.Addr) (int64, error) {
conn, err := icmp.ListenPacket(network, family.listenAddr) conn, err := icmp.ListenPacket(network, family.listenAddr)
if err != nil { if err != nil {
return -1 return -1, err
} }
defer conn.Close() defer conn.Close()
@@ -170,7 +168,7 @@ func probeICMPNative(network string, family *icmpFamily, dst net.Addr) int64 {
} }
msgBytes, err := msg.Marshal(nil) msgBytes, err := msg.Marshal(nil)
if err != nil { if err != nil {
return -1 return -1, err
} }
// Set deadline before sending // Set deadline before sending
@@ -178,7 +176,7 @@ func probeICMPNative(network string, family *icmpFamily, dst net.Addr) int64 {
start := time.Now() start := time.Now()
if _, err := conn.WriteTo(msgBytes, dst); err != nil { if _, err := conn.WriteTo(msgBytes, dst); err != nil {
return -1 return -1, err
} }
// Read reply // Read reply
@@ -186,23 +184,23 @@ func probeICMPNative(network string, family *icmpFamily, dst net.Addr) int64 {
for { for {
n, _, err := conn.ReadFrom(buf) n, _, err := conn.ReadFrom(buf)
if err != nil { if err != nil {
return -1 return -1, err
} }
reply, err := icmp.ParseMessage(family.proto, buf[:n]) reply, err := icmp.ParseMessage(family.proto, buf[:n])
if err != nil { if err != nil {
return -1 return -1, err
} }
if reply.Type == family.replyType { if reply.Type == family.replyType {
return time.Since(start).Microseconds() return time.Since(start).Microseconds(), nil
} }
// Ignore non-echo-reply messages (e.g. destination unreachable) and keep reading // Ignore non-echo-reply messages (e.g. destination unreachable) and keep reading
} }
} }
// probeICMPExec falls back to the system ping command. Returns -1 on failure. // probeICMPExec falls back to the system ping command. Returns -1 and an error on failure.
func probeICMPExec(target string, isIPv6 bool) int64 { func probeICMPExec(target string, isIPv6 bool) (int64, error) {
var cmd *exec.Cmd var cmd *exec.Cmd
switch runtime.GOOS { switch runtime.GOOS {
case "windows": case "windows":
@@ -211,7 +209,7 @@ func probeICMPExec(target string, isIPv6 bool) int64 {
} else { } else {
cmd = exec.Command("ping", "-n", "1", "-w", "3000", target) cmd = exec.Command("ping", "-n", "1", "-w", "3000", target)
} }
default: // linux, darwin, freebsd default:
if isIPv6 { if isIPv6 {
cmd = exec.Command("ping", "-6", "-c", "1", "-W", "3", target) cmd = exec.Command("ping", "-6", "-c", "1", "-W", "3", target)
} else { } else {
@@ -224,20 +222,20 @@ func probeICMPExec(target string, isIPv6 bool) int64 {
if err != nil { if err != nil {
// If ping fails but we got output, still try to parse // If ping fails but we got output, still try to parse
if len(output) == 0 { if len(output) == 0 {
return -1 return -1, err
} }
} }
matches := pingTimeRegex.FindSubmatch(output) matches := pingTimeRegex.FindSubmatch(output)
if len(matches) >= 2 { if len(matches) >= 2 {
if ms, err := strconv.ParseFloat(string(matches[1]), 64); err == nil { if ms, err := strconv.ParseFloat(string(matches[1]), 64); err == nil {
return int64(math.Round(ms * 1000)) return int64(math.Round(ms * 1000)), nil
} }
} }
// Fallback: use wall clock time if ping succeeded but parsing failed // Fallback: use wall clock time if ping succeeded but parsing failed
if err == nil { if err == nil {
return time.Since(start).Microseconds() return time.Since(start).Microseconds(), nil
} }
return -1 return -1, err
} }

View File

@@ -303,7 +303,8 @@ func TestProbeHTTP(t *testing.T) {
})) }))
defer server.Close() defer server.Close()
responseUs := probeHTTP(server.Client(), server.URL) responseUs, err := probeHTTP(server.Client(), server.URL)
require.NoError(t, err)
assert.GreaterOrEqual(t, responseUs, int64(0)) assert.GreaterOrEqual(t, responseUs, int64(0))
}) })
@@ -313,7 +314,9 @@ func TestProbeHTTP(t *testing.T) {
})) }))
defer server.Close() defer server.Close()
assert.Equal(t, int64(-1), probeHTTP(server.Client(), server.URL)) responseUs, err := probeHTTP(server.Client(), server.URL)
assert.Equal(t, int64(-1), responseUs)
require.Error(t, err)
}) })
} }
@@ -333,7 +336,8 @@ func TestProbeTCP(t *testing.T) {
}() }()
port := uint16(listener.Addr().(*net.TCPAddr).Port) port := uint16(listener.Addr().(*net.TCPAddr).Port)
responseUs := probeTCP("127.0.0.1", port) responseUs, err := probeTCP("127.0.0.1", port)
require.NoError(t, err)
assert.GreaterOrEqual(t, responseUs, int64(0)) assert.GreaterOrEqual(t, responseUs, int64(0))
<-accepted <-accepted
}) })
@@ -345,6 +349,8 @@ func TestProbeTCP(t *testing.T) {
port := uint16(listener.Addr().(*net.TCPAddr).Port) port := uint16(listener.Addr().(*net.TCPAddr).Port)
require.NoError(t, listener.Close()) require.NoError(t, listener.Close())
assert.Equal(t, int64(-1), probeTCP("127.0.0.1", port)) responseUs, err := probeTCP("127.0.0.1", port)
assert.Equal(t, int64(-1), responseUs)
require.Error(t, err)
}) })
} }

View File

@@ -33,11 +33,12 @@ import { SystemStatus } from "@/lib/enums"
import { Checkbox } from "@/components/ui/checkbox" import { Checkbox } from "@/components/ui/checkbox"
import { useMemo } from "react" import { useMemo } from "react"
import { formatBulkProbeLine } from "@/components/network-probes-table/probe-dialog" import { formatBulkProbeLine } from "@/components/network-probes-table/probe-dialog"
import { Badge } from "../ui/badge"
const protocolColors: Record<string, string> = { const protocolColors: Record<string, string> = {
icmp: "bg-blue-500/15 text-blue-400", icmp: "bg-blue-500/15 text-blue-600 dark:text-blue-400",
tcp: "bg-purple-500/15 text-purple-400", tcp: "bg-purple-500/15 text-purple-600 dark:text-purple-400",
http: "bg-green-500/15 text-green-400", http: "bg-green-500/15 text-green-700 dark:text-green-400",
} }
const SYSTEM_STATUS_COLORS = { const SYSTEM_STATUS_COLORS = {
@@ -97,9 +98,17 @@ export function getProbeColumns(
header: ({ column }) => <HeaderButton column={column} name={t`Name`} Icon={NetworkIcon} />, header: ({ column }) => <HeaderButton column={column} name={t`Name`} Icon={NetworkIcon} />,
cell: ({ row, getValue }) => { cell: ({ row, getValue }) => {
const probe = row.original const probe = row.original
const { status } = useStore($allSystemsById)[probe.system] || {}
let color = "bg-green-500"
if (!probe.enabled || status === SystemStatus.Paused) {
color = "bg-primary/40"
} else if (status === SystemStatus.Down || status === SystemStatus.Pending) {
color = "bg-yellow-500"
}
return ( return (
<div className="ms-1.5 max-w-40 flex gap-2 items-center tabular-nums"> <div className="ms-1.5 max-w-40 flex gap-2 items-center tabular-nums">
<span className={cn("shrink-0 size-2 rounded-full", probe.enabled ? "bg-green-500" : "bg-primary/40")} /> <span className={cn("shrink-0 size-2 rounded-full", color)} />
<div className="relative w-fit min-w-0 max-w-full"> <div className="relative w-fit min-w-0 max-w-full">
<span className="invisible block overflow-hidden whitespace-nowrap" aria-hidden="true"> <span className="invisible block overflow-hidden whitespace-nowrap" aria-hidden="true">
{longestName} {longestName}
@@ -117,7 +126,11 @@ export function getProbeColumns(
const allSystems = $allSystemsById.get() const allSystems = $allSystemsById.get()
const systemNameA = allSystems[a.original.system]?.name ?? "" const systemNameA = allSystems[a.original.system]?.name ?? ""
const systemNameB = allSystems[b.original.system]?.name ?? "" const systemNameB = allSystems[b.original.system]?.name ?? ""
return systemNameA.localeCompare(systemNameB) const primary = systemNameA.localeCompare(systemNameB)
if (primary !== 0) {
return primary
}
return (a.original.name || a.original.target).localeCompare(b.original.name || b.original.target)
}, },
header: ({ column }) => <HeaderButton column={column} name={t`System`} Icon={ServerIcon} />, header: ({ column }) => <HeaderButton column={column} name={t`System`} Icon={ServerIcon} />,
cell: ({ getValue }) => { cell: ({ getValue }) => {
@@ -162,16 +175,13 @@ export function getProbeColumns(
header: ({ column }) => <HeaderButton column={column} name={t`Protocol`} Icon={ArrowLeftRightIcon} />, header: ({ column }) => <HeaderButton column={column} name={t`Protocol`} Icon={ArrowLeftRightIcon} />,
cell: ({ getValue }) => { cell: ({ getValue }) => {
const protocol = getValue() as string const protocol = getValue() as string
return ( return <Badge className={cn("uppercase", protocolColors[protocol])}>{protocol}</Badge>
<span className={cn("ms-1.5 px-2 py-0.5 rounded text-xs font-medium uppercase", protocolColors[protocol])}>
{protocol}
</span>
)
}, },
}, },
{ {
id: "interval", id: "interval",
accessorFn: (record) => record.interval, accessorFn: (record) => record.interval,
invertSorting: true,
header: ({ column }) => <HeaderButton column={column} name={t`Interval`} Icon={RefreshCwIcon} />, header: ({ column }) => <HeaderButton column={column} name={t`Interval`} Icon={RefreshCwIcon} />,
cell: ({ getValue }) => <span className="ms-1.5 tabular-nums">{getValue() as number}s</span>, cell: ({ getValue }) => <span className="ms-1.5 tabular-nums">{getValue() as number}s</span>,
}, },

View File

@@ -443,6 +443,48 @@ export function runOnce<T extends (...args: any[]) => any>(fn: T): T {
}) as T }) as T
} }
const visualWidthCache = new Map<string, number>()
/** Get the visual width of a string, accounting for full-width and narrow punctuation characters.
* Don't use for monospaced fonts, use .length instead
*/
function getVisualStringWidth(str: string): number {
const cached = visualWidthCache.get(str)
if (cached !== undefined) {
return cached
}
let width = 0
for (const char of str) {
if (char === ".") {
width += 0.7
continue
}
const code = char.codePointAt(0) || 0
// Hangul Jamo and Syllables are often slightly thinner than Hanzi/Kanji
if ((code >= 0x1100 && code <= 0x115f) || (code >= 0xac00 && code <= 0xd7af)) {
width += 1.8
continue
}
// Count CJK and other full-width characters as 2 units, others as 1
// Arabic and Cyrillic are counted as 1
const isFullWidth =
(code >= 0x2e80 && code <= 0x9fff) || // CJK Radicals, Symbols, and Ideographs
(code >= 0xf900 && code <= 0xfaff) || // CJK Compatibility Ideographs
(code >= 0xfe30 && code <= 0xfe6f) || // CJK Compatibility Forms
(code >= 0xff00 && code <= 0xff60) || // Fullwidth Forms
(code >= 0xffe0 && code <= 0xffe6) || // Fullwidth Symbols
code > 0xffff // Emojis and other supplementary plane characters
width += isFullWidth ? 2 : 1
}
visualWidthCache.set(str, width)
return width
}
/** Compare the visual width of two strings imprecisely */
export function isVisuallyLonger(str1: string, str2: string): boolean {
return getVisualStringWidth(str1) > getVisualStringWidth(str2)
}
/** Format seconds to hours, minutes, or seconds */ /** Format seconds to hours, minutes, or seconds */
export function secondsToString(seconds: number, unit: "hour" | "minute" | "day"): string { export function secondsToString(seconds: number, unit: "hour" | "minute" | "day"): string {
const count = Math.floor(seconds / (unit === "hour" ? 3600 : unit === "minute" ? 60 : 86400)) const count = Math.floor(seconds / (unit === "hour" ? 3600 : unit === "minute" ? 60 : 86400))
@@ -472,45 +514,3 @@ export function secondsToUptimeString(seconds: number): string {
return secondsToString(seconds, "day") return secondsToString(seconds, "day")
} }
} }
const visualWidthCache = new Map<string, number>()
/** Get the visual width of a string, accounting for full-width and narrow punctuation characters.
* Don't use for monospaced fonts, use .length instead
*/
export function getVisualStringWidth(str: string): number {
const cached = visualWidthCache.get(str)
if (cached !== undefined) {
return cached
}
let width = 0
for (const char of str) {
if (char === ".") {
width += 0.7
continue
}
const code = char.codePointAt(0) || 0
// Hangul Jamo and Syllables are often slightly thinner than Hanzi/Kanji
if ((code >= 0x1100 && code <= 0x115f) || (code >= 0xac00 && code <= 0xd7af)) {
width += 1.8
continue
}
// Count CJK and other full-width characters as 2 units, others as 1
// Arabic and Cyrillic are counted as 1
const isFullWidth =
(code >= 0x2e80 && code <= 0x9fff) || // CJK Radicals, Symbols, and Ideographs
(code >= 0xf900 && code <= 0xfaff) || // CJK Compatibility Ideographs
(code >= 0xfe30 && code <= 0xfe6f) || // CJK Compatibility Forms
(code >= 0xff00 && code <= 0xff60) || // Fullwidth Forms
(code >= 0xffe0 && code <= 0xffe6) || // Fullwidth Symbols
code > 0xffff // Emojis and other supplementary plane characters
width += isFullWidth ? 2 : 1
}
visualWidthCache.set(str, width)
return width
}
export function isVisuallyLonger(str1: string, str2: string): boolean {
return getVisualStringWidth(str1) > getVisualStringWidth(str2)
}