From ef953b36fdfdaf62419a36c4e185b13a07d2c6fd Mon Sep 17 00:00:00 2001 From: Christian Ditaputratama Date: Mon, 16 Sep 2024 22:35:14 +0700 Subject: [PATCH] fix: Reject input hostname with protocol This is quick fix. Do not accept submitted tor address with protocol since it won't work. The initial clearnet validation can be done with `net.LookupIP`, but for tor network can't be done with that method. For now, just inform to remove the http:// or https:// part to the submitter. --- internal/monero/monero.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/monero/monero.go b/internal/monero/monero.go index 750265c..595ebac 100644 --- a/internal/monero/monero.go +++ b/internal/monero/monero.go @@ -220,6 +220,10 @@ func (r *moneroRepo) Add(protocol string, hostname string, port uint) error { ipAddr = hostIp.String() ips = ip.SliceToString(hostIps) + } else { + if strings.HasPrefix(hostname, "http://") || strings.HasPrefix(hostname, "https://") { + return errors.New("Don't start hostname with http:// or https://, just put your hostname") + } } row, err := r.db.Query(`