mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2024-12-23 03:59:25 +00:00
Make nettype and protocol query more strict
It will return error if nettype and protocol query string value is wrong
This commit is contained in:
parent
ec11fa0126
commit
efca11e51c
1 changed files with 7 additions and 0 deletions
|
@ -108,10 +108,17 @@ func (repo *MoneroRepo) Nodes(q MoneroQueryParams) (MoneroNodes, error) {
|
||||||
queryParams = append(queryParams, "%"+q.Host+"%")
|
queryParams = append(queryParams, "%"+q.Host+"%")
|
||||||
}
|
}
|
||||||
if q.NetType != "any" {
|
if q.NetType != "any" {
|
||||||
|
if q.NetType != "mainnet" && q.NetType != "stagenet" && q.NetType != "testnet" {
|
||||||
|
return MoneroNodes{}, errors.New("Invalid nettype, must be one of 'mainnet', 'stagenet', 'testnet' or 'any'")
|
||||||
|
}
|
||||||
whereQueries = append(whereQueries, "nettype = ?")
|
whereQueries = append(whereQueries, "nettype = ?")
|
||||||
queryParams = append(queryParams, q.NetType)
|
queryParams = append(queryParams, q.NetType)
|
||||||
}
|
}
|
||||||
if q.Protocol != "any" {
|
if q.Protocol != "any" {
|
||||||
|
allowedProtocols := []string{"tor", "http", "https"}
|
||||||
|
if !slices.Contains(allowedProtocols, q.Protocol) {
|
||||||
|
return MoneroNodes{}, errors.New("Invalid protocol, must be one of '" + strings.Join(allowedProtocols, "', '") + "' or 'any'")
|
||||||
|
}
|
||||||
if q.Protocol == "tor" {
|
if q.Protocol == "tor" {
|
||||||
whereQueries = append(whereQueries, "is_tor = ?")
|
whereQueries = append(whereQueries, "is_tor = ?")
|
||||||
queryParams = append(queryParams, 1)
|
queryParams = append(queryParams, 1)
|
||||||
|
|
Loading…
Reference in a new issue