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.
This commit is contained in:
Christian Ditaputratama 2024-09-16 22:35:14 +07:00
parent 76a54a0f29
commit ef953b36fd
No known key found for this signature in database
GPG key ID: 31D3D06D77950979

View file

@ -220,6 +220,10 @@ func (r *moneroRepo) Add(protocol string, hostname string, port uint) error {
ipAddr = hostIp.String() ipAddr = hostIp.String()
ips = ip.SliceToString(hostIps) 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(` row, err := r.db.Query(`