net

module
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: BSD-3-Clause

README

sardanioss/net

A fork of golang.org/x/net with HTTP/2 fingerprinting support for evading bot detection systems.

Why This Fork?

Modern anti-bot systems (Akamai, Cloudflare, PerimeterX) fingerprint HTTP/2 connections by analyzing:

  • SETTINGS frame order and values
  • WINDOW_UPDATE (connection flow) value
  • Pseudo-header order (:method, :authority, :scheme, :path)
  • Header priority in HEADERS frame
  • PRIORITY frames
  • HPACK dynamic table indexing behavior

The standard golang.org/x/net/http2 package doesn't allow customizing these values, making Go HTTP clients easily detectable. This fork adds full control over all HTTP/2 fingerprint vectors.

Installation

go get github.com/sardanioss/net

Features

HTTP/2 Transport Configuration
import "github.com/sardanioss/net/http2"

transport := &http2.Transport{
    // Custom SETTINGS frame (order matters!)
    Settings: map[http2.SettingID]uint32{
        http2.SettingHeaderTableSize:   65536,
        http2.SettingEnablePush:        0,
        http2.SettingInitialWindowSize: 6291456,
        http2.SettingMaxHeaderListSize: 262144,
    },
    SettingsOrder: []http2.SettingID{
        http2.SettingHeaderTableSize,
        http2.SettingEnablePush,
        http2.SettingInitialWindowSize,
        http2.SettingMaxHeaderListSize,
    },

    // Custom WINDOW_UPDATE value (Chrome uses 15663105)
    ConnectionFlow: 15663105,

    // Pseudo-header order (Chrome: m,a,s,p)
    PseudoHeaderOrder: []string{":method", ":authority", ":scheme", ":path"},

    // Header priority in HEADERS frame
    HeaderPriority: &http2.PriorityParam{
        Weight:    255,  // 256 in Chrome (0-indexed)
        Exclusive: true,
        StreamDep: 0,
    },

    // Stream priority mode
    StreamPriorityMode: http2.StreamPriorityChrome,

    // Custom User-Agent
    UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
}
HPACK Indexing Control
import "github.com/sardanioss/net/http2/hpack"

// Configure via Transport
transport := &http2.Transport{
    HPACKIndexingPolicy: hpack.IndexingChrome,
    HPACKNeverIndex:     []string{"x-request-id"},
    HPACKAlwaysIndex:    []string{"accept"},
}

Available indexing policies:

  • IndexingDefault - Standard Go behavior
  • IndexingChrome - Emulates Chrome's indexing decisions
  • IndexingNever - Never index any headers
  • IndexingAlways - Always index headers (if they fit)
Per-Request Header Ordering

Use magic keys to override header order per-request:

req.Header[http2.HeaderOrderKey] = []string{"accept", "user-agent", "accept-language"}
req.Header[http2.PHeaderOrderKey] = []string{":method", ":authority", ":scheme", ":path"}
PRIORITY Frames

Send PRIORITY frames after connection preface:

transport := &http2.Transport{
    Priorities: []http2.Priority{
        {StreamID: 3, PriorityParam: http2.PriorityParam{Weight: 200, StreamDep: 0}},
        {StreamID: 5, PriorityParam: http2.PriorityParam{Weight: 100, StreamDep: 3}},
    },
}

Chrome 133 Fingerprint

To match Chrome 133's HTTP/2 fingerprint:

transport := &http2.Transport{
    Settings: map[http2.SettingID]uint32{
        http2.SettingHeaderTableSize:   65536,
        http2.SettingEnablePush:        0,
        http2.SettingInitialWindowSize: 6291456,
        http2.SettingMaxHeaderListSize: 262144,
    },
    SettingsOrder: []http2.SettingID{
        http2.SettingHeaderTableSize,
        http2.SettingEnablePush,
        http2.SettingInitialWindowSize,
        http2.SettingMaxHeaderListSize,
    },
    ConnectionFlow:     15663105,
    PseudoHeaderOrder:  []string{":method", ":authority", ":scheme", ":path"},
    HeaderPriority:     &http2.PriorityParam{Weight: 255, Exclusive: true, StreamDep: 0},
    StreamPriorityMode: http2.StreamPriorityChrome,
    HPACKIndexingPolicy: hpack.IndexingChrome,
}

Target Akamai hash: 52d84b11737d980aef856699f885ca86

API Reference

Transport Fields
Field Type Description
Settings map[SettingID]uint32 Custom HTTP/2 settings values
SettingsOrder []SettingID Order to send settings in SETTINGS frame
ConnectionFlow uint32 WINDOW_UPDATE value (default: 15663105)
PseudoHeaderOrder []string Order of pseudo-headers
HeaderOrder []string Order of regular headers
HeaderPriority *PriorityParam Priority data for HEADERS frame
Priorities []Priority PRIORITY frames to send
UserAgent string Default User-Agent header
StreamPriorityMode StreamPriorityMode Stream priority calculation mode
HPACKIndexingPolicy hpack.IndexingPolicy HPACK dynamic table indexing
HPACKNeverIndex []string Headers to never index
HPACKAlwaysIndex []string Headers to always index
Stream Priority Modes
Mode Description
StreamPriorityDefault Standard Go behavior
StreamPriorityChrome Chrome's priority tree (exclusive on stream 0, weight 256)
StreamPriorityFirefox Firefox's priority tree
StreamPriorityCustom Use custom StreamPriorityFunc
HPACK Indexing Policies
Policy Description
IndexingDefault Standard Go behavior (index if fits)
IndexingChrome Emulates Chrome's indexing decisions
IndexingNever Never index any headers
IndexingAlways Always index headers

License

BSD 3-Clause License (same as golang.org/x/net)

Directories

Path Synopsis
Package bpf implements marshaling and unmarshaling of programs for the Berkeley Packet Filter virtual machine, and provides a Go implementation of the virtual machine.
Package bpf implements marshaling and unmarshaling of programs for the Berkeley Packet Filter virtual machine, and provides a Go implementation of the virtual machine.
Package context has been superseded by the standard library context package.
Package context has been superseded by the standard library context package.
ctxhttp
Package ctxhttp provides helper functions for performing context-aware HTTP requests.
Package ctxhttp provides helper functions for performing context-aware HTTP requests.
Package dict implements the Dictionary Server Protocol as defined in RFC 2229.
Package dict implements the Dictionary Server Protocol as defined in RFC 2229.
dns
dnsmessage
Package dnsmessage provides a mostly RFC 1035 compliant implementation of DNS message packing and unpacking.
Package dnsmessage provides a mostly RFC 1035 compliant implementation of DNS message packing and unpacking.
Package html implements an HTML5-compliant tokenizer and parser.
Package html implements an HTML5-compliant tokenizer and parser.
atom
Package atom provides integer codes (also known as atoms) for a fixed set of frequently occurring HTML strings: tag names and attribute keys such as "p" and "id".
Package atom provides integer codes (also known as atoms) for a fixed set of frequently occurring HTML strings: tag names and attribute keys such as "p" and "id".
charset
Package charset provides common text encodings for HTML documents.
Package charset provides common text encodings for HTML documents.
http
httpguts
Package httpguts provides functions implementing various details of the HTTP specification.
Package httpguts provides functions implementing various details of the HTTP specification.
httpproxy
Package httpproxy provides support for HTTP proxy determination based on environment variables, as provided by net/http's ProxyFromEnvironment function.
Package httpproxy provides support for HTTP proxy determination based on environment variables, as provided by net/http's ProxyFromEnvironment function.
Package http2 implements the HTTP/2 protocol.
Package http2 implements the HTTP/2 protocol.
h2c
Package h2c implements the unencrypted "h2c" form of HTTP/2.
Package h2c implements the unencrypted "h2c" form of HTTP/2.
h2i command
The h2i command is an interactive HTTP/2 console.
The h2i command is an interactive HTTP/2 console.
hpack
Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2.
Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2.
Package icmp provides basic functions for the manipulation of messages used in the Internet Control Message Protocols, ICMPv4 and ICMPv6.
Package icmp provides basic functions for the manipulation of messages used in the Internet Control Message Protocols, ICMPv4 and ICMPv6.
Package idna implements IDNA2008 using the compatibility processing defined by UTS (Unicode Technical Standard) #46, which defines a standard to deal with the transition from IDNA2003.
Package idna implements IDNA2008 using the compatibility processing defined by UTS (Unicode Technical Standard) #46, which defines a standard to deal with the transition from IDNA2003.
internal
gate
Package gate contains an alternative condition variable.
Package gate contains an alternative condition variable.
http3
Package http3 implements the HTTP/3 protocol.
Package http3 implements the HTTP/3 protocol.
httpsfv
Package httpsfv provides functionality for dealing with HTTP Structured Field Values.
Package httpsfv provides functionality for dealing with HTTP Structured Field Values.
iana
Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).
Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).
quic/cmd/interop command
The interop command is the client and server used by QUIC interoperability tests.
The interop command is the client and server used by QUIC interoperability tests.
quic/quicwire
Package quicwire encodes and decode QUIC/HTTP3 wire encoding types, particularly variable-length integers.
Package quicwire encodes and decode QUIC/HTTP3 wire encoding types, particularly variable-length integers.
socket
Package socket provides a portable interface for socket system calls.
Package socket provides a portable interface for socket system calls.
socks
Package socks provides a SOCKS version 5 client implementation.
Package socks provides a SOCKS version 5 client implementation.
sockstest
Package sockstest provides utilities for SOCKS testing.
Package sockstest provides utilities for SOCKS testing.
testcert
Package testcert contains a test-only localhost certificate.
Package testcert contains a test-only localhost certificate.
timeseries
Package timeseries implements a time series structure for stats collection.
Package timeseries implements a time series structure for stats collection.
Package ipv4 implements IP-level socket options for the Internet Protocol version 4.
Package ipv4 implements IP-level socket options for the Internet Protocol version 4.
Package ipv6 implements IP-level socket options for the Internet Protocol version 6.
Package ipv6 implements IP-level socket options for the Internet Protocol version 6.
Package nettest provides utilities for network testing.
Package nettest provides utilities for network testing.
Package netutil provides network utility functions, complementing the more common ones in the net package.
Package netutil provides network utility functions, complementing the more common ones in the net package.
Package proxy provides support for a variety of protocols to proxy network data.
Package proxy provides support for a variety of protocols to proxy network data.
Package publicsuffix provides a public suffix list based on data from https://publicsuffix.org/
Package publicsuffix provides a public suffix list based on data from https://publicsuffix.org/
Package quic implements the QUIC protocol.
Package quic implements the QUIC protocol.
qlog
Package qlog serializes qlog events.
Package qlog serializes qlog events.
Package route provides basic functions for the manipulation of packet routing facilities on BSD variants.
Package route provides basic functions for the manipulation of packet routing facilities on BSD variants.
Package trace implements tracing of requests and long-lived objects.
Package trace implements tracing of requests and long-lived objects.
Package webdav provides a WebDAV server implementation.
Package webdav provides a WebDAV server implementation.
internal/xml
Package xml implements a simple XML 1.0 parser that understands XML name spaces.
Package xml implements a simple XML 1.0 parser that understands XML name spaces.
Package websocket implements a client and server for the WebSocket protocol as specified in RFC 6455.
Package websocket implements a client and server for the WebSocket protocol as specified in RFC 6455.
Package xsrftoken provides methods for generating and validating secure XSRF tokens.
Package xsrftoken provides methods for generating and validating secure XSRF tokens.

Jump to

Keyboard shortcuts

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