From 433021e623a84eb8d33ac92c41d4581335f2fa7c Mon Sep 17 00:00:00 2001 From: bethropolis <66518866+bethropolis@users.noreply.github.com> Date: Wed, 24 Jun 2026 02:21:03 +0300 Subject: [PATCH 1/3] fix: remove unused crypto/sha256 import in output.go --- pkg/cli/output.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/cli/output.go b/pkg/cli/output.go index f59d22f..5600e3a 100644 --- a/pkg/cli/output.go +++ b/pkg/cli/output.go @@ -1,7 +1,6 @@ package cli import ( - "crypto/sha256" "encoding/json" "fmt" "os" From 9cb2d4255420667615c237c864892e80579df0a4 Mon Sep 17 00:00:00 2001 From: bethropolis <66518866+bethropolis@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:15:53 +0300 Subject: [PATCH 2/3] fix(send): auto-detect HTTPS protocol in SendToDevice when Protocol is unknown (e.g. send --ip) --- pkg/send/send.go | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/pkg/send/send.go b/pkg/send/send.go index aa22f53..78a5f46 100644 --- a/pkg/send/send.go +++ b/pkg/send/send.go @@ -147,25 +147,38 @@ func SendToDevice(ctx context.Context, cfg *config.Config, device *model.Device, client := &http.Client{} scheme := "http" + if device.Protocol == "" { + addr := net.JoinHostPort(device.IP, strconv.Itoa(device.Port)) + dialer := &net.Dialer{Timeout: 2 * time.Second} + conn, err := tls.DialWithDialer(dialer, "tcp", addr, &tls.Config{InsecureSkipVerify: true}) + if err == nil { + conn.Close() + device.Protocol = model.ProtocolTypeHTTPS + } + } + if device.Protocol == model.ProtocolTypeHTTPS { scheme = "https" - expectedFingerprint := device.Fingerprint + tlsConfig := &tls.Config{ + InsecureSkipVerify: true, + } + if device.Fingerprint != "" { + expectedFingerprint := device.Fingerprint + tlsConfig.VerifyConnection = func(state tls.ConnectionState) error { + if len(state.PeerCertificates) == 0 { + return fmt.Errorf("no peer certificates presented") + } + cert := state.PeerCertificates[0] + hash := sha256.Sum256(cert.Raw) + actual := hex.EncodeToString(hash[:]) + if !strings.EqualFold(actual, expectedFingerprint) { + return fmt.Errorf("TLS certificate fingerprint mismatch: expected %s, got %s", expectedFingerprint, actual) + } + return nil + } + } tr := &http.Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, - VerifyConnection: func(state tls.ConnectionState) error { - if len(state.PeerCertificates) == 0 { - return fmt.Errorf("no peer certificates presented") - } - cert := state.PeerCertificates[0] - hash := sha256.Sum256(cert.Raw) - actual := hex.EncodeToString(hash[:]) - if !strings.EqualFold(actual, expectedFingerprint) { - return fmt.Errorf("TLS certificate fingerprint mismatch: expected %s, got %s", expectedFingerprint, actual) - } - return nil - }, - }, + TLSClientConfig: tlsConfig, } client.Transport = tr defer tr.CloseIdleConnections() From 122d6eee47cebd452887c217a122a4a8875b6a08 Mon Sep 17 00:00:00 2001 From: bethropolis <66518866+bethropolis@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:31:15 +0300 Subject: [PATCH 3/3] fix(test): increase multicast self-ignore startup sleep to reduce CI flakiness --- pkg/discovery/multicast_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/discovery/multicast_test.go b/pkg/discovery/multicast_test.go index 2c8e03c..76e0788 100644 --- a/pkg/discovery/multicast_test.go +++ b/pkg/discovery/multicast_test.go @@ -138,7 +138,7 @@ func TestMulticastDiscovery_IgnoreSelf(t *testing.T) { } defer md.Stop() - time.Sleep(100 * time.Millisecond) + time.Sleep(200 * time.Millisecond) md.SendDiscoveryAnnouncement()