hacknode

package module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

HackNode Go SDK (github.com/voidxgroup/hacknode-net/sdks/go)

Zero-dependency Go 1.25+ client (net/http), fail-open HTTP risk guard middleware, and HMAC-SHA256 webhook signature verifier for hacknode.net.

Install

go get github.com/voidxgroup/hacknode-net/sdks/go@latest

Quick Start

package main

import (
	"context"
	"fmt"
	"os"

	hacknode "github.com/voidxgroup/hacknode-net/sdks/go"
)

func main() {
	client := hacknode.NewClient(os.Getenv("HACKNODE_API_KEY"))
	res, err := client.Lookup(context.Background(), "20.171.207.12", "GPTBot/1.2")
	if err == nil {
		fmt.Println(res.Risk.Score, res.Risk.Recommendation, res.Flags.IsMobile, res.Flags.IsResidentialProxy)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyWebhookSignature

func VerifyWebhookSignature(rawBody []byte, sigHeader, secret string) bool

Types

type AIBotDetail

type AIBotDetail struct {
	ID               string   `json:"id"`
	Slug             string   `json:"slug"`
	Name             string   `json:"name"`
	Owner            string   `json:"owner"`
	Category         string   `json:"category"`
	RobotsToken      string   `json:"robots_token"`
	VerificationMode string   `json:"verification_mode"`
	IPv4Prefixes     []string `json:"ipv4_prefixes"`
	IPv6Prefixes     []string `json:"ipv6_prefixes"`
	TotalIPv4        uint64   `json:"total_ipv4"`
	DBVersion        string   `json:"db_version"`
}

type Client

type Client struct {
	APIKey     string
	BaseURL    string
	HTTPClient *http.Client
}

func NewClient

func NewClient(apiKey string) *Client

func (*Client) BulkLookup

func (c *Client) BulkLookup(ctx context.Context, ips []string, userAgent string) ([]LookupResult, error)

func (*Client) GuardMiddleware

func (c *Client) GuardMiddleware(minBlockScore int, next http.Handler) http.Handler

GuardMiddleware blocks spoofed AI bots and requests at or above minBlockScore (fail-open on network errors).

func (*Client) Lookup

func (c *Client) Lookup(ctx context.Context, ip, userAgent string) (*LookupResult, error)

func (*Client) LookupAIBot

func (c *Client) LookupAIBot(ctx context.Context, slug string) (*AIBotDetail, error)

func (*Client) LookupCountry

func (c *Client) LookupCountry(ctx context.Context, countryCode string) (*CountrySummary, error)

type CountrySummary

type CountrySummary struct {
	Country           string            `json:"country"`
	TotalASNs         int               `json:"total_asns"`
	TotalIPv4         uint64            `json:"total_ipv4"`
	TotalIPv6Prefixes uint64            `json:"total_ipv6_prefixes"`
	AvgRiskBaseline   int               `json:"avg_risk_baseline"`
	TypeCounts        map[string]int    `json:"type_counts"`
	TypeIPv4          map[string]uint64 `json:"type_ipv4"`
	DBVersion         string            `json:"db_version"`
}

type LookupResult

type LookupResult struct {
	IP       string `json:"ip"`
	Hostname string `json:"hostname,omitempty"`
	Geo      struct {
		Country   string  `json:"country"`
		Region    string  `json:"region"`
		City      string  `json:"city"`
		Postal    string  `json:"postal,omitempty"`
		Latitude  float64 `json:"latitude"`
		Longitude float64 `json:"longitude"`
		Timezone  string  `json:"timezone"`
	} `json:"geo"`
	Network struct {
		ASN      string `json:"asn"`
		ASNNum   uint32 `json:"asn_num"`
		Org      string `json:"org"`
		Domain   string `json:"domain,omitempty"`
		CIDR     string `json:"cidr,omitempty"`
		Type     string `json:"type"`
		Provider string `json:"provider,omitempty"`
	} `json:"network"`
	Flags struct {
		IsDatacenter       bool `json:"is_datacenter"`
		IsMobile           bool `json:"is_mobile"`
		IsProxy            bool `json:"is_proxy"`
		IsVPN              bool `json:"is_vpn"`
		IsTor              bool `json:"is_tor"`
		IsResidentialProxy bool `json:"is_residential_proxy"`
		IsAbuser           bool `json:"is_abuser"`
		IsAIBot            bool `json:"is_ai_bot"`
		IsSpoofedBot       bool `json:"is_spoofed_bot"`
	} `json:"flags"`
	Bot *struct {
		Name        string `json:"name"`
		Owner       string `json:"owner"`
		Category    string `json:"category"`
		Verified    bool   `json:"verified"`
		ClaimedName string `json:"claimed_name,omitempty"`
	} `json:"bot,omitempty"`
	Risk struct {
		Score          int      `json:"score"`
		Level          string   `json:"level"`
		Recommendation string   `json:"recommendation"`
		Reasons        []string `json:"reasons"`
	} `json:"risk"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL