crypto

package
v0.0.0-...-c8d95c1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package crypto implements BitTorrent protocol encryption.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientHandshake

func ClientHandshake(c net.Conn, skey []byte, ia []byte, options *Options) (conn net.Conn, buf []byte, err error)

ClientHandshake performs the client side of the BitTorrent protocol encryption handshake. It returns an encrypted connection and any cleartext that was received together with the handshake.

func ServerHandshake

func ServerHandshake(c net.Conn, head []byte, skeys [][]byte, options *Options) (conn net.Conn, skey []byte, ia []byte, err error)

ServerHandshake performs the server side of the BitTorrent protocol encryption handshake. It returns an encrypted connection, the skey that was agreed upon (a torrent hash), and any cleartext that was included within the handshake.

Types

type Conn

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

Conn is an encrypted connexion. It implements the net.Conn interface.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) LocalAddr

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

func (*Conn) Read

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

func (*Conn) RemoteAddr

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

func (*Conn) SetDeadline

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

func (*Conn) SetReadDeadline

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

func (*Conn) SetWriteDeadline

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

func (*Conn) Write

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

type Options

type Options struct {
	AllowCryptoHandshake  bool
	PreferCryptoHandshake bool
	ForceCryptoHandshake  bool
	AllowEncryption       bool
	PreferEncryption      bool
	ForceEncryption       bool
}

Type Options defines a policy for encrypting torrents

func DefaultOptions

func DefaultOptions(prefer, force bool) *Options

DefaultOptions returns a policy for encrypting torrents.

Jump to

Keyboard shortcuts

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