From 1b411b1fed4fa33d17739542ce53f2870a161998 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Sun, 16 Jun 2024 10:18:45 +0300 Subject: [PATCH] refactor(streams): optimize label generation with strings.Builder feat(network): add periodic data fetching and network update --- internal/streams/dot.go | 15 ++++---- www/network.html | 83 +++++++++++++++++++++++++++++++---------- 2 files changed, 72 insertions(+), 26 deletions(-) diff --git a/internal/streams/dot.go b/internal/streams/dot.go index aa008c40..9aacccb5 100644 --- a/internal/streams/dot.go +++ b/internal/streams/dot.go @@ -146,19 +146,20 @@ func (c *conn) host() (s string) { return } -func (c *conn) label() (s string) { - s = "format_name=" + c.FormatName +func (c *conn) label() string { + var sb strings.Builder + sb.WriteString("format_name=" + c.FormatName) if c.Protocol != "" { - s += "\nprotocol=" + c.Protocol + sb.WriteString("\nprotocol=" + c.Protocol) } if c.Source != "" { - s += "\nsource=" + c.Source + sb.WriteString("\nsource=" + c.Source) } if c.URL != "" { - s += "\nurl=" + c.URL + sb.WriteString("\nurl=" + c.URL) } if c.UserAgent != "" { - s += "\nuser_agent=" + c.UserAgent + sb.WriteString("\nuser_agent=" + c.UserAgent) } - return + return sb.String() } diff --git a/www/network.html b/www/network.html index 5193b6a9..519e0eba 100644 --- a/www/network.html +++ b/www/network.html @@ -21,24 +21,69 @@ - -
- + +
+ + \ No newline at end of file