v2.0.2+incompatible Latest Latest

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

Go to latest
Published: Mar 5, 2019 License: GPL-3.0 Imports: 17 Imported by: 0



Package quic wraps github.com/lucas-clemente/quic-go with net.Listener and net.Conn types that provide a drop-in replacement for net.TCPConn.

Each QUIC session has exactly one stream, which is the equivilent of a TCP stream.

Conns returned from Accept will have an established QUIC session and are configured to perform a deferred AcceptStream on the first Read or Write.

Conns returned from Dial have an established QUIC session and stream. Dial accepts a Context input which may be used to cancel the dial.

Conns mask or translate qerr.PeerGoingAway to io.EOF as appropriate.

QUIC idle timeouts and keep alives are tuned to mitigate aggressive UDP NAT timeouts on mobile data networks while accounting for the fact that mobile devices in standby/sleep may not be able to initiate the keep alive.



View Source
const (
	MAX_QUIC_IPV4_PACKET_SIZE            = 1252
	MAX_QUIC_IPV6_PACKET_SIZE            = 1232
	MAX_PADDING                          = 64
	NONCE_SIZE                           = 12
	RANDOM_STREAM_LIMIT                  = 1<<38 - 64
View Source
const (
	SERVER_IDLE_TIMEOUT      = 5 * time.Minute
	CLIENT_IDLE_TIMEOUT      = 30 * time.Second


This section is empty.


func Dial

func Dial(
	ctx context.Context,
	packetConn net.PacketConn,
	remoteAddr *net.UDPAddr,
	quicSNIAddress string,
	negotiateQUICVersion string,
	obfuscationKey string,
	obfuscationPaddingSeed *prng.Seed) (net.Conn, error)

Dial establishes a new QUIC session and stream to the server specified by address.

packetConn is used as the underlying packet connection for QUIC. The dial may be cancelled by ctx; packetConn will be closed if the dial is cancelled or fails.

Keep alive and idle timeout functionality in QUIC is disabled as these aspects are expected to be handled at a higher level.


type Conn

type Conn struct {
	// contains filtered or unexported fields

Conn is a net.Conn and psiphon/common.Closer.

func (*Conn) Close

func (conn *Conn) Close() error

func (*Conn) IsClosed

func (conn *Conn) IsClosed() bool

func (*Conn) LocalAddr

func (conn *Conn) LocalAddr() net.Addr

func (*Conn) Read

func (conn *Conn) Read(b []byte) (int, error)

func (*Conn) RemoteAddr

func (conn *Conn) RemoteAddr() net.Addr

func (*Conn) SetDeadline

func (conn *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (conn *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (conn *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) Write

func (conn *Conn) Write(b []byte) (int, error)

type Listener

type Listener struct {
	// contains filtered or unexported fields

Listener is a net.Listener.

func Listen

func Listen(
	logger common.Logger,
	address string,
	obfuscationKey string) (*Listener, error)

Listen creates a new Listener.

func (*Listener) Accept

func (listener *Listener) Accept() (net.Conn, error)

Accept returns a net.Conn that wraps a single QUIC session and stream. The stream establishment is deferred until the first Read or Write, allowing Accept to be called in a fast loop while goroutines spawned to handle each net.Conn will perform the blocking AcceptStream.

type ObfuscatedPacketConn added in v1.0.9

type ObfuscatedPacketConn struct {
	// contains filtered or unexported fields

ObfuscatedPacketConn wraps a QUIC net.PacketConn with an obfuscation layer that obscures QUIC packets, adding random padding and producing uniformly random payload.

The crypto performed by ObfuscatedPacketConn is purely for obfuscation to frusctrate wire-speed DPI and does not add privacy/security. The small nonce space and single key per server is not cryptographically secure.

A server-side ObfuscatedPacketConn performs simple QUIC DPI to distinguish between obfuscated and non-obfsucated peer flows and responds accordingly.

The header and padding added by ObfuscatedPacketConn on top of the QUIC payload will increase UDP packets beyond the QUIC max of 1280 bytes, introducing some risk of fragmentation and/or dropped packets.

func NewObfuscatedPacketConn added in v1.0.9

func NewObfuscatedPacketConn(
	conn net.PacketConn,
	isServer bool,
	obfuscationKey string,
	paddingSeed *prng.Seed) (*ObfuscatedPacketConn, error)

NewObfuscatedPacketConn creates a new ObfuscatedPacketConn.

func (*ObfuscatedPacketConn) Close added in v1.0.9

func (conn *ObfuscatedPacketConn) Close() error

func (*ObfuscatedPacketConn) ReadFrom added in v1.0.9

func (conn *ObfuscatedPacketConn) ReadFrom(p []byte) (int, net.Addr, error)

func (*ObfuscatedPacketConn) WriteTo added in v1.0.9

func (conn *ObfuscatedPacketConn) WriteTo(p []byte, addr net.Addr) (int, error)

Jump to

Keyboard shortcuts

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