Package: kopete Version: 4:3.3.2-3 Severity: normal Tags: patch
Hi, Kopete has a problem initiating outgoing MSN transfers (i.e. when it is acting as server) when used behind a firewall that does network address translation (NAT). This happens, because Kopete reports the IP of the local socket to the other peer, rather than the true external IP address. I had created a patch for this problem several months ago, which allows the user to specify an IP address and port number to report to the other client. However, I did not submit the patch to the Kopete maintainers in time for the KDE 3.4 release. Since the next official version of Kopete will use the MSN9 protocol which auto-detects the right IP, this patch became unnecessairy for future versions of Kopete. But Debian is still shipping with the 3.3 (and possibly 3.4) versions of Kopete, I am hoping you can include this patch to make it more useful for those with NATed connections. This patch is very non-intrusive. The largest change is adding a new tab to the MSNEditAccount.ui file. However, I backported the patch to the latest Debian verison of Kopete (from kdenetwork-3.3.2), so it should work fine. Please note that there appear to be at least two different bugs with NAT and MSN transfers in general, so this patch doesn't completely fix MSN transfers. If there are problems with the patch, please e-mail me. The patch is attached: MSN_file_transfers.diff - Anton -- System Information: Debian Release: 3.1 APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.11.6.20050401 Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Versions of packages kopete depends on: ii kdelibs4 4:3.3.2-5 KDE core libraries ii libart-2.0-2 2.3.17-1 Library of functions for 2D graphi ii libc6 2.3.2.ds1-21 GNU C Library: Shared libraries an ii libfam0c102 2.7.0-6 client library to control the FAM ii libgcc1 1:3.4.3-12 GCC support library ii libice6 4.3.0.dfsg.1-10 Inter-Client Exchange library ii libidn11 0.5.13-1.0 GNU libidn library, implementation ii libjpeg62 6b-10 The Independent JPEG Group's JPEG ii libpcre3 5.0-1 Perl 5 Compatible Regular Expressi ii libpng12-0 1.2.8rel-1 PNG library - runtime ii libqt3c102-mt 3:3.3.4-3 Qt GUI Library (Threaded runtime v ii libsm6 4.3.0.dfsg.1-10 X Window System Session Management ii libssl0.9.7 0.9.7e-3 SSL shared libraries ii libstdc++5 1:3.3.5-12 The GNU Standard C++ Library v3 ii libx11-6 4.3.0.dfsg.1-10 X Window System protocol client li ii libxext6 4.3.0.dfsg.1-10 X Window System miscellaneous exte ii libxml2 2.6.16-7 GNOME XML library ii libxrender1 0.8.3-7 X Rendering Extension client libra ii libxslt1.1 1.1.12-8 XSLT processing library - runtime ii xlibs 4.3.0.dfsg.1-12 X Keyboard Extension (XKB) configu ii zlib1g 1:1.2.2-4 compression library - runtime -- no debconf information
diff -U 3 -d -r -N -- kdenetwork-3.3.2.orig/kopete/protocols/msn/msnaccount.cpp kdenetwork-3.3.2/kopete/protocols/msn/msnaccount.cpp --- kdenetwork-3.3.2.orig/kopete/protocols/msn/msnaccount.cpp 2004-08-05 15:26:24.000000000 -0400 +++ kdenetwork-3.3.2/kopete/protocols/msn/msnaccount.cpp 2005-05-01 15:39:55.000000000 -0400 @@ -116,6 +116,24 @@ return 1863; } +QString MSNAccount::externalIP() const +{ + QString externalIP = pluginData( protocol(), QString::fromLatin1( "ExtIPAddress" ) ); + if( !externalIP.isEmpty() ) + return externalIP; + else + return QString::null; +} + +uint MSNAccount::externalPort() const +{ + QString externalPort = pluginData( protocol(), QString::fromLatin1( "ExtPort" ) ); + if( !externalPort.isEmpty() ) + return externalPort.toUInt(); + else + return 6891; +} + void MSNAccount::setAway( bool away, const QString & awayReason ) { m_awayReason = awayReason; diff -U 3 -d -r -N -- kdenetwork-3.3.2.orig/kopete/protocols/msn/msnaccount.h kdenetwork-3.3.2/kopete/protocols/msn/msnaccount.h --- kdenetwork-3.3.2.orig/kopete/protocols/msn/msnaccount.h 2004-08-05 15:26:24.000000000 -0400 +++ kdenetwork-3.3.2/kopete/protocols/msn/msnaccount.h 2005-05-01 14:26:59.000000000 -0400 @@ -64,6 +64,16 @@ * Returns the address of the MSN server port */ uint serverPort(); + + /** + * Returns the external IP address / hostname set by the user + */ + QString externalIP() const; + + /** + * Returns the external port set by the user for direct connections + */ + uint externalPort() const; MSNNotifySocket *notifySocket(); diff -U 3 -d -r -N -- kdenetwork-3.3.2.orig/kopete/protocols/msn/msnfiletransfersocket.cpp kdenetwork-3.3.2/kopete/protocols/msn/msnfiletransfersocket.cpp --- kdenetwork-3.3.2.orig/kopete/protocols/msn/msnfiletransfersocket.cpp 2004-08-05 15:26:24.000000000 -0400 +++ kdenetwork-3.3.2/kopete/protocols/msn/msnfiletransfersocket.cpp 2005-05-01 16:11:16.000000000 -0400 @@ -34,6 +34,7 @@ #include "kopetemetacontact.h" #include "msnmessagemanager.h" #include "msnswitchboardsocket.h" +#include "msnaccount.h" using namespace KNetwork; @@ -58,6 +59,21 @@ kdDebug(14140) << "MSNFileTransferSocket::~MSNFileTransferSocket" <<endl; } +QString MSNFileTransferSocket::getExternalIP() const +{ + MSNAccount* accmsn = static_cast<MSNAccount*> ( m_contact->account() ); + MSNMessageManager* manager=dynamic_cast<MSNMessageManager*>(m_contact->manager()); + if( !accmsn->externalIP().isEmpty() ) + return accmsn->externalIP(); + else + return manager->service()->getLocalIP(); +} + +uint MSNFileTransferSocket::getExternalPort() const +{ + return static_cast<MSNAccount*> ( m_contact->account() )->externalPort(); +} + void MSNFileTransferSocket::parseCommand(const QString & cmd, uint id, const QString & data) { if( cmd == "VER" ) @@ -387,8 +403,8 @@ "\r\n" "Invitation-Command: ACCEPT\r\n" "Invitation-Cookie: " + QString::number(cookie()) + "\r\n" - "IP-Address: " + manager->service()->getLocalIP() + "\r\n" - "Port: 6891\r\n" + "IP-Address: " + getExternalIP() + "\r\n" + "Port: " + QString::number( getExternalPort() ) + "\r\n" "AuthCookie: "+QString::number(auth)+"\r\n" "Launch-Application: FALSE\r\n" "Request-Data: IP-Address:\r\n\r\n").utf8(); @@ -396,7 +412,7 @@ manager->service()->sendCommand( "MSG" , "N", true, message ); } - listen(6891); + listen( getExternalPort() ); } } else //CANCEL diff -U 3 -d -r -N -- kdenetwork-3.3.2.orig/kopete/protocols/msn/msnfiletransfersocket.h kdenetwork-3.3.2/kopete/protocols/msn/msnfiletransfersocket.h --- kdenetwork-3.3.2.orig/kopete/protocols/msn/msnfiletransfersocket.h 2004-07-17 15:10:31.000000000 -0400 +++ kdenetwork-3.3.2/kopete/protocols/msn/msnfiletransfersocket.h 2005-05-01 14:26:59.000000000 -0400 @@ -80,6 +80,18 @@ */ virtual void parseCommand(const QString & cmd, uint id, const QString & data); virtual void bytesReceived(const QByteArray & data); + + /** + * Gets the external IP either from the socket or user's preferences + * @return The IP address for the remote peer to connect to + */ + QString getExternalIP() const; + + /** + * Gets the external port (set by user in preferences) + * @return The port for the remote peer to connect to + */ + uint getExternalPort() const; protected slots: virtual void slotReadyWrite(); diff -U 3 -d -r -N -- kdenetwork-3.3.2.orig/kopete/protocols/msn/ui/msneditaccountui.ui kdenetwork-3.3.2/kopete/protocols/msn/ui/msneditaccountui.ui --- kdenetwork-3.3.2.orig/kopete/protocols/msn/ui/msneditaccountui.ui 2004-08-05 15:26:24.000000000 -0400 +++ kdenetwork-3.3.2/kopete/protocols/msn/ui/msneditaccountui.ui 2005-05-01 14:26:59.000000000 -0400 @@ -227,6 +227,9 @@ <property name="text"> <string>&Override default server information</string> </property> + <property name="accel"> + <string>Alt+O</string> + </property> </widget> <widget class="QLayoutWidget"> <property name="name"> @@ -284,14 +287,6 @@ <property name="enabled"> <bool>false</bool> </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>3</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> <property name="text"> <string>messenger.hotmail.com</string> </property> @@ -362,17 +357,12 @@ <property name="name"> <cstring>NotifyNewChat</cstring> </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> <property name="text"> <string>Au&tomatically open a chat window when someone starts a conversation</string> </property> + <property name="accel"> + <string>Alt+T</string> + </property> </widget> <widget class="QCheckBox"> <property name="name"> @@ -381,6 +371,9 @@ <property name="text"> <string>Automatically &download the display picture if possible</string> </property> + <property name="accel"> + <string>Alt+D</string> + </property> <property name="checked"> <bool>true</bool> </property> @@ -392,22 +385,20 @@ <property name="text"> <string>Download and show c&ustom emoticons</string> </property> + <property name="accel"> + <string>Alt+U</string> + </property> </widget> <widget class="QCheckBox"> <property name="name"> <cstring>SendAwayMessages</cstring> </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> <property name="text"> <string>Send a&way messages</string> </property> + <property name="accel"> + <string>Alt+W</string> + </property> <property name="checked"> <bool>false</bool> </property> @@ -499,7 +490,134 @@ <property name="sizeHint"> <size> <width>21</width> - <height>20</height> + <height>184</height> + </size> + </property> + </spacer> + </vbox> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>&File Transfers</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox4</cstring> + </property> + <property name="title"> + <string>File Transfer Settings</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout20</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2_2</cstring> + </property> + <property name="text"> + <string>Local &IP address:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>m_externalIP</cstring> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>m_externalIP</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>External IP Address</string> + </property> + <property name="whatsThis" stdset="0"> + <string><h1>Specify External IP Address</h1> +<p>Enter your machine's external IP address or hostname here. This is usually the public address of your router/firewall. If you don't have a router/firewall/NAT just leave this blank.</p> +<p>Enter the IP in the form: "000.000.000.000"</p> +<p><font color="#fd0000">Note: This address must be accessible/visible to others on the internet.</font></p></string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel4_2</cstring> + </property> + <property name="text"> + <string>Po&rt:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>m_externalPort</cstring> + </property> + </widget> + <widget class="QSpinBox"> + <property name="name"> + <cstring>m_externalPort</cstring> + </property> + <property name="maxValue"> + <number>65535</number> + </property> + <property name="value"> + <number>6891</number> + </property> + <property name="toolTip" stdset="0"> + <string>External Port</string> + </property> + <property name="whatsThis" stdset="0"> + <string><h1>External Port</h1> +<p>In order to receive incomming connections you will need to forward +one or more ports from your firewall/router to this machine.</p> +<p>Specify the port Kopete should use for incomming connections.</p> +<p>Most people should not change this value.</p></string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel3_2</cstring> + </property> + <property name="text"> + <string><ul> +<li>You can leave the local IP address empty if you do not use NAT.</li> +<li>If you are having trouble receiving files, specify your IP here.</li> +<li>A hostname is also valid.</li> +<li>If you are behind a firewall/router/NAT you will need to forward the port specified above to this machine.</li> +<li>This is a per-account setting.</li> +</ul></string> + </property> + <property name="alignment"> + <set>WordBreak|AlignVCenter</set> + </property> + </widget> + </vbox> + </widget> + <spacer> + <property name="name"> + <cstring>spacer29</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>278</height> </size> </property> </spacer> diff -U 3 -d -r -N -- kdenetwork-3.3.2.orig/kopete/protocols/msn/ui/msneditaccountwidget.cpp kdenetwork-3.3.2/kopete/protocols/msn/ui/msneditaccountwidget.cpp --- kdenetwork-3.3.2.orig/kopete/protocols/msn/ui/msneditaccountwidget.cpp 2004-08-05 15:26:24.000000000 -0400 +++ kdenetwork-3.3.2/kopete/protocols/msn/ui/msneditaccountwidget.cpp 2005-05-01 15:42:40.000000000 -0400 @@ -109,6 +109,9 @@ MSNAccount *m_account = static_cast<MSNAccount*>( account ); d->ui->m_serverName->setText( m_account->serverName() ); d->ui->m_serverPort->setValue( m_account->serverPort() ); + + d->ui->m_externalIP->setText( m_account->externalIP() ); + d->ui->m_externalPort->setValue( m_account->externalPort() ); QStringList blockList = QStringList::split( ',', account->pluginData( d->protocol, QString::fromLatin1( "blockList" ) ) ); QStringList allowList = QStringList::split( ',', account->pluginData( d->protocol, QString::fromLatin1( "allowList" ) ) ); @@ -164,6 +167,9 @@ account()->setPluginData( d->protocol, "serverName", "messenger.hotmail.com" ); account()->setPluginData( d->protocol, "serverPort", "1863" ); } + + account()->setPluginData( d->protocol, "ExtIPAddress", d->ui->m_externalIP->text() ); + account()->setPluginData( d->protocol, "ExtPort", QString::number(d->ui->m_externalPort->value() )); static_cast<MSNAccount *>( account() )->resetPictureObject();