Documentation
¶
Overview ¶
Package tspuprobe finds out whether TCP SYNs to an address die at the national DPI box (the Russian TSPU), seen from the machine it runs on. It is a traceroute with a TTL limit and no privileges: one plain TCP socket per probe, the TTL and IP_RECVERR set, and a router's ICMP Time Exceeded read from the socket while the connection is in SYN_SENT (hop_linux.go).
The method (a re-implementation of the idea described by porutchik/tspu-check and LowderPlay/cheburcheck; no code is shared):
- dpi_hop. SYNs to an address that is certainly blocked in the country go out with TTL 1..max_ttl. The DPI box drops them without an ICMP answer, so the highest TTL a router answered is the hop in front of the box.
- Control. SYNs to a certainly-open address with TTL dpi_hop+1..dpi_hop+hop_limit must not all die, else the method does not apply to this network (ErrControlFailed; that is no verdict about any target).
- Targets, the same way: an established connection or an ICMP answer from behind the box is "open", a RST "refused", silence at every hop "blocked". A blocked answer is checked again, alone and with more patience, because many probes at once trip the ICMP rate limit of routers and look like a blocked address.
Only the addresses of the request are probed. The package is portable; the probe itself is Linux only.
Index ¶
Constants ¶
const ( VerdictBlocked = "blocked" VerdictOpen = "open" VerdictRefused = "refused" // VerdictTimeout: no verdict was reached for that host:port (the deadline ran out, or the name did not resolve). VerdictTimeout = "timeout" // The caps of one run (agent.proto "COUNTRY PROBE"). MaxTargets = 8 MaxPorts = 4 MaxPairs = 16 MaxHopLimit = 8 MaxMaxTTL = 32 DefaultHopLimit = 3 DefaultMaxTTL = 30 TotalDeadline = 120 * time.Second // ControlPort is the port of the control target and of the blocked reference. ControlPort = 443 )
const ( // ReasonRefOpen: the blocked reference answered with a SYN-ACK, so it passes on this path. ReasonRefOpen = "ref_open" // ReasonRefRefused: the reference answered with a RST: something resets it, and this method does not see that filter. ReasonRefRefused = "ref_refused" // ReasonNoHops: no router answered at any TTL, so the route is hidden. ReasonNoHops = "no_hops" // ReasonNoRef: the request had no blocked reference. ReasonNoRef = "no_ref" )
Why the DPI box could not be placed (NoDPIHopError.Reason; the "reason" param of the agent's no_dpi_hop answer).
Variables ¶
var ( ErrBadParams = errors.New("tspuprobe: bad parameters") ErrUnsupportedHost = errors.New("tspuprobe: unsupported destination") // ErrUnsupported: this host cannot run the probe (not Linux, or the socket options are refused). ErrUnsupported = errors.New("tspuprobe: unsupported on this host") // ErrNoDPIHop: the DPI box cannot be placed: no blocked reference, it was silent from the first hop, or it was reachable. // The error a run returns is a *NoDPIHopError that says which (errors.Is matches this value). ErrNoDPIHop = errors.New("tspuprobe: dpi hop not found") // ErrControlFailed: the control target did not get past the DPI box, the method does not apply on this network. ErrControlFailed = errors.New("tspuprobe: control failed") // ErrDeadline: the total deadline ran out before the DPI hop and the control were settled. ErrDeadline = errors.New("tspuprobe: deadline") )
Functions ¶
Types ¶
type NoDPIHopError ¶ added in v0.1.44
type NoDPIHopError struct{ Reason string }
NoDPIHopError is ErrNoDPIHop with the reason the box could not be placed.
func (*NoDPIHopError) Error ¶ added in v0.1.44
func (e *NoDPIHopError) Error() string
func (*NoDPIHopError) Is ¶ added in v0.1.44
func (e *NoDPIHopError) Is(target error) bool
type Request ¶
type Request struct {
Control string // IPv4 literal, port 443
BlockedRef string // IPv4 literal, port 443; "" = ErrNoDPIHop
Targets []Target
HopLimit int
MaxTTL int
}
Request is one run. HopLimit and MaxTTL are 0 for their defaults.