1
1
/***************************************************************************
2
* Copyright (C) 2005-2013 by the Quassel Project *
2
* Copyright (C) 2005-2014 by the Quassel Project *
3
3
* devel@quassel-irc.org *
5
5
* This program is free software; you can redistribute it and/or modify *
1020
// http://www.irchelp.org/irchelp/rfc/ctcpspec.html
1021
// http://en.wikipedia.org/wiki/Direct_Client-to-Client
1022
void CoreSessionEventProcessor::handleCtcpDcc(CtcpEvent *e)
1024
// DCC support is unfinished, experimental and potentially dangerous, so make it opt-in
1025
if (!Quassel::isOptionSet("enable-experimental-dcc")) {
1026
quInfo() << "DCC disabled, start core with --enable-experimental-dcc if you really want to try it out";
1030
// normal: SEND <filename> <ip> <port> [<filesize>]
1031
// reverse: SEND <filename> <ip> 0 <filesize> <token>
1032
QStringList params = e->param().split(' ');
1033
if (params.count()) {
1034
QString cmd = params[0].toUpper();
1035
if (cmd == "SEND") {
1036
if (params.count() < 4) {
1037
qWarning() << "Invalid DCC SEND request:" << e; // TODO emit proper error to client
1040
QString filename = params[1];
1041
QHostAddress address;
1042
quint16 port = params[3].toUShort();
1044
QString numIp = params[2]; // this is either IPv4 as a 32 bit value, or IPv6 (which always contains a colon)
1045
if (numIp.contains(':')) { // IPv6
1046
if (!address.setAddress(numIp)) {
1047
qWarning() << "Invalid IPv6:" << numIp;
1052
address.setAddress(numIp.toUInt());
1055
if (port == 0) { // Reverse DCC is indicated by a 0 port
1056
emit newEvent(new MessageEvent(Message::Error, e->network(), tr("Reverse DCC SEND not supported"), e->prefix(), e->target(), Message::None, e->timestamp()));
1060
qWarning() << "Privileged port requested:" << port; // FIXME ask user if this is ok
1064
if (params.count() > 4) { // filesize is optional
1065
size = params[4].toULong();
1068
// TODO: check if target is the right thing to use for the partner
1069
CoreTransfer *transfer = new CoreTransfer(Transfer::Receive, e->target(), filename, address, port, size, this);
1070
coreSession()->signalProxy()->synchronize(transfer);
1071
coreSession()->transferManager()->addTransfer(transfer);
1074
emit newEvent(new MessageEvent(Message::Error, e->network(), tr("DCC %1 not supported").arg(cmd), e->prefix(), e->target(), Message::None, e->timestamp()));
1017
1081
void CoreSessionEventProcessor::handleCtcpPing(CtcpEvent *e)
1019
1083
e->setReply(e->param().isNull() ? "" : e->param());