From 35db6597e3b95daf3c625d9c4fa1eb93f5157822 Mon Sep 17 00:00:00 2001 From: enki Date: Wed, 27 Aug 2025 18:08:49 -0700 Subject: [PATCH] Fix DHT bootstrap URL parsing and transcoding completion handler --- internal/dht/bootstrap.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/internal/dht/bootstrap.go b/internal/dht/bootstrap.go index b680f06..0c16795 100644 --- a/internal/dht/bootstrap.go +++ b/internal/dht/bootstrap.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "net" + "net/url" "sync" "time" @@ -518,13 +519,21 @@ func (d *DHTBootstrap) Stop() error { // Helper functions // extractHostname extracts hostname from URL -func extractHostname(url string) string { - // Simple URL parsing - in production use net/url - if host, _, err := net.SplitHostPort(url); err == nil { +func extractHostname(urlStr string) string { + // Parse the URL properly + if u, err := url.Parse(urlStr); err == nil { + // Extract hostname without port + if host, _, err := net.SplitHostPort(u.Host); err == nil { + return host + } + // If no port in URL, return the host directly + return u.Host + } + // Fallback - assume it's already just a hostname + if host, _, err := net.SplitHostPort(urlStr); err == nil { return host } - // Fallback for URLs without port - return url + return urlStr } // isValidNodeID checks if a node ID is valid