feat: Added remote nodes i2p filter #148

This commit is contained in:
Cristian Ditaputratama 2024-11-07 20:52:38 +07:00
parent e892733a55
commit f339bc9c3c
Signed by: ditatompel
GPG key ID: 31D3D06D77950979
3 changed files with 11 additions and 7 deletions

View file

@ -11,7 +11,7 @@ import (
)
var nettypes = []string{"mainnet", "stagenet", "testnet"}
var protocols = []string{"tor", "http", "https"}
var protocols = []string{"tor", "i2p", "http", "https"}
type nodeStatus struct {
Code int

View file

@ -19,7 +19,7 @@ import (
)
var nettypes = []string{"mainnet", "stagenet", "testnet"}
var protocols = []string{"tor", "http", "https"}
var protocols = []string{"tor", "i2p", "http", "https"}
type nodeStatus struct {
Code int

View file

@ -99,13 +99,17 @@ func (q *QueryNodes) toSQL() (args []interface{}, where string) {
wq = append(wq, "nettype = ?")
args = append(args, q.Nettype)
}
if q.Protocol != "any" && slices.Contains([]string{"tor", "http", "https"}, q.Protocol) {
if q.Protocol == "tor" {
if q.Protocol != "any" && slices.Contains([]string{"tor", "i2p", "http", "https"}, q.Protocol) {
switch q.Protocol {
case "i2p":
wq = append(wq, "is_i2p = ?")
args = append(args, 1)
case "tor":
wq = append(wq, "is_tor = ?")
args = append(args, 1)
} else {
wq = append(wq, "(protocol = ? AND is_tor = ?)")
args = append(args, q.Protocol, 0)
default:
wq = append(wq, "(protocol = ? AND is_tor = ? AND is_i2p = ?)")
args = append(args, q.Protocol, 0, 0)
}
}
if q.CC != "any" {