mse

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mse implements Message Stream Encryption (MSE/PE) as used by BitTorrent clients to obfuscate protocol traffic and avoid ISP throttling.

The protocol uses Diffie-Hellman key exchange with a 768-bit prime, followed by RC4 encryption of the stream. Both "encrypt headers only" (plaintext) and "full stream" (RC4) modes are supported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandshakeOutgoing

func HandshakeOutgoing(conn net.Conn, infoHash [20]byte, preferred CryptoMethod) (*Conn, CryptoMethod, error)

HandshakeOutgoing performs MSE handshake as the initiator (connecting party). infoHash is required to derive encryption keys. Returns an encrypted Conn and the crypto method negotiated.

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn wraps a net.Conn with optional RC4 encryption.

func (*Conn) Read

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

func (*Conn) Write

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

type CryptoMethod

type CryptoMethod uint32

CryptoMethod selects the payload encryption method.

const (
	CryptoPlaintext CryptoMethod = 0x01
	CryptoRC4       CryptoMethod = 0x02
)

Jump to

Keyboard shortcuts

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