~blu/dip

989fa4da98d1c28a812a04d8a1f04c27258fb0b7 — Bryant Conquest 1 year, 10 months ago 68aa9ef
return provider in data
1 files changed, 3 insertions(+), 1 deletions(-)

M search/search.go
M search/search.go => search/search.go +3 -1
@@ 20,7 20,7 @@ func CheckInRange(Ip net.IP, ipRange string) (bool, error) {
}

func Search(ctx context.Context, sdb *pgxpool.Pool, IP string) (bool, map[string]any, error) {
	rows, err := sdb.Query(ctx, "SELECT range, data FROM \"providers\" WHERE $1<<providers.range;", IP)
	rows, err := sdb.Query(ctx, "SELECT range, data, provider FROM \"providers\" WHERE $1<<providers.range;", IP)
	if err != nil {
		log.Println(err)
		return false, map[string]any{}, err


@@ 28,6 28,7 @@ func Search(ctx context.Context, sdb *pgxpool.Pool, IP string) (bool, map[string
	defer rows.Close()
	for rows.Next() {
		var r net.IPNet
		var p string
		var d map[string]any

		err := rows.Scan(&r, &d)


@@ 35,6 36,7 @@ func Search(ctx context.Context, sdb *pgxpool.Pool, IP string) (bool, map[string
			log.Println("error parsing row: ", err)
			continue
		} else {
			d["provider"] = p
			return true, d, nil
		}
	}