destblock

package
v0.2.2-dev.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 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.

Documentation

Overview

Package destblock refuses connections by the name of their destination, for the node's shared egress.

A list of domain suffixes decides. A destination given by name is matched directly (List.Match). A destination given by IP address carries its name only in the first bytes the client sends: the SNI of a TLS ClientHello (WrapTCP) or of a QUIC Initial (QUICGuard). Nothing else is looked at: a stream that is not TLS, a hello without a name (ECH) and a stream that does not show its name within maxSniff bytes pass untouched.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapTCP

func WrapTCP(conn net.Conn, list *List, onBlock func()) net.Conn

WrapTCP holds the client's first bytes of a connection to an IP address until the TLS ClientHello is complete. A name in list closes the connection (onBlock is called once) and no held byte reaches the server. Anything else, a stream that does not start with TLS first, is written out as it came, in order, and every later byte goes straight through.

Write has one caller at a time (the copy loop of the protocol, after the sniffer's put-back bytes), as in torrentguard. Close and CloseWrite may come from other goroutines; the lock is never held over a network write.

Types

type List

type List struct {
	// contains filtered or unexported fields
}

List is an immutable set of domain suffixes. A nil or empty list blocks nothing.

func New

func New(suffixes []string) *List

New builds a list from suffixes such as "max.ru" ("*.max.ru" and ".max.ru" mean the same). Case and a trailing dot are ignored.

func (*List) Empty

func (l *List) Empty() bool

Empty reports whether the list blocks nothing.

func (*List) Match

func (l *List) Match(host string) bool

Match reports whether host is one of the suffixes or a subdomain of one: "max.ru" and "api.max.ru" match "max.ru", "3dmax.ru" and "max.ru.example.com" do not. An IP literal never matches.

type QUICGuard

type QUICGuard struct {
	// contains filtered or unexported fields
}

QUICGuard reads the name from the first datagrams a client sends to each IP destination. One guard serves one UDP session (a session may name several destinations). Safe for concurrent use.

func (*QUICGuard) Drop

func (g *QUICGuard) Drop(list *List, host string, port uint16, b []byte) bool

Drop reports whether the datagram b, the next one for host:port, must not be sent: the QUIC Initial in it (with the ones before it) names something in list, or an earlier datagram of the flow did. A flow whose first datagram is not a QUIC Initial is never looked at again. A ClientHello in two datagrams lets the first one out: without the second the server cannot read it.

Directories

Path Synopsis
Package dbtest makes first flights for tests of destblock and its callers: a real TLS ClientHello and the UDP datagrams of a real QUIC client, produced by crypto/tls and quic-go in memory, no network.
Package dbtest makes first flights for tests of destblock and its callers: a real TLS ClientHello and the UDP datagrams of a real QUIC client, produced by crypto/tls and quic-go in memory, no network.

Jump to

Keyboard shortcuts

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