DCC — Interface to DCC file transfers

A module providing a high-level interface for DCC file transfers.

DCC file transfers involve having the sender listen on some tcp port and the receiver connect to the port to initiate the file transfer. The file name and length as well as the tcp port and address are shared via other means.

Config

{
    "port_range": [40690, 40990],
    "public_addr": "127.0.0.1",
    "bind_host": "127.0.0.1"
}
port_range

The range of ports between which arbitrary ports will be used for file transfers

public_addr

When sending files, what address we will advertise as being connectable on

bind_host

What IP address to bind to when creating listener sockets for the file send role.

Class Reference

class pyircbot.modules.DCC.DCC(bot, name)[source]

Bases: pyircbot.modulebase.ModuleBase

offer(file_path, port=None)[source]

Offer a file to another user. - check file size - start listener socket thread on some port - info about the file: tuple of (ip, port, size)

recieve(host, port, length)[source]

Receive a file another user has offered. Returns a generator that yields data chunks.

class pyircbot.modules.DCC.OfferThread(master, path, bind_addr, port, timeout=30)[source]

Bases: threading.Thread

abort()[source]

Expire the offer after a timeout.

run()[source]

Open a server socket that accepts a single connections. When the first client connects, send the contents of the offered file.

send_file(socket)[source]

Send the contents of the offered file to the passed socket :param socket: socket object ready for sending :type socket: socket.socket

stopoffer()[source]

Prematurely shut down & cleanup the offer socket

class pyircbot.modules.DCC.RecieveGenerator(host, port, length)[source]

Bases: object

exception pyircbot.modules.DCC.TransferFailedException[source]

Bases: Exception

pyircbot.modules.DCC.int2ip(num)[source]

Convert an integer to an ip address string

pyircbot.modules.DCC.ip2int(ipstr)[source]

Convert an ip address string to an integer