Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show any multiple connections from the same IP in peer list #11918

Merged
merged 1 commit into from
Jan 30, 2020

Conversation

thalieht
Copy link
Contributor

The uniqueness of peers is now determined by their IP and port
instead of just their IP.

closes #11845

src/gui/properties/peerlistwidget.cpp Outdated Show resolved Hide resolved
src/gui/properties/peerlistwidget.cpp Outdated Show resolved Hide resolved
@Chocobo1
Copy link
Member

I haven't finished the review yet (you can still push commits) and I recall I looked into this issue myself too. The reason why there were no results from me is that I consider there is more to this issue and is non-trivial (at least for me at that time).
Let's start with this question: how should a connection considered to be unique? I would say it is determined by the tuple: (our IP, our port, peer IP, peer port, protocol).

  • our IP: seems we don't really care in our case/PR here.
  • our port: seems we don't really care in our case/PR here.
  • peer IP: we already have it participate in determining connection uniqueness.
  • peer port: participating in determining connection uniqueness seems to be handled by this PR.
  • protocol: TCP or uTP/UDP. This field is displayed in GUI but doesn't participate in determining connection uniqueness. It is entirely possible that 2 different clients uses the same IP/port pair yet one uses only TCP and another uses only uTP.

So in short, we need to handle (peer IP, peer port, protocol) properly in order to correctly list all on-going connection.

@thalieht
Copy link
Contributor Author

So in short, we need to handle (peer IP, peer port, protocol)

Once again i opened a can of worms... aanyway so far i've been thinking about adding another value (connection) to m_peerItems and compare it to peer.connectionType(). I don't know how yet but if you can think of another way i'm all ears.

@zero77
Copy link

zero77 commented Jan 25, 2020

@thalieht
Will this also be in the webui.

@thalieht
Copy link
Contributor Author

@zero77 yes... inadvertently :)

@Chocobo1
Copy link
Member

Chocobo1 commented Jan 26, 2020

aanyway so far i've been thinking about adding another value (connection) to m_peerItems and compare it to peer.connectionType().

A possible way is to create another struct and use it only in peerlistwidget.cpp, for example:

struct PeerEndpoint
{
    BitTorrent::PeerAddress address;
    QString connectionType; // matches return type of `PeerInfo::connectionType()`

    /* Off topic discussion
    // I think `QString` as the return type of `PeerInfo::connectionType()` might 
    // be not a good choice. IMO qbt code base should have our own `enum class PeerConnectionType` defined 
    // and the values could be:
    enum class PeerConnectionType
    {
        // https://www.libtorrent.org/reference-Core.html#peer_info
        BT_TCP,
        BT_UTP,
        WebSeeds,  // either `connection_type_t::web_seed` or `connection_type_t::http_seed` in libtorrent
    };
    */
};
// add definitions of `operator==(PeerEndpoint, ...)` and `qHash(PeerEndpoint, ...)`

// Then in peerlistwidget.h
QHash<BitTorrent::PeerEndpoint, QStandardItem *> m_peerItems;

That is my basic idea, maybe @glassez could provide some suggestion too.

@thalieht
Copy link
Contributor Author

Thanks! That's a much better idea. I'll wait for @glassez input though in case he objects.

@glassez
Copy link
Member

glassez commented Jan 26, 2020

IIRC, currently we show incorrect peer list since there can be multiple peers from the same IP and we show only one of them, isn't it?

That is my basic idea, maybe @glassez could provide some suggestion too.

Let's try to implement it.

@thalieht
Copy link
Contributor Author

I didn't do the connection type enum thing because libtorrent types were mentioned which i'm not familiar with.

@@ -42,4 +42,15 @@ namespace BitTorrent
static PeerAddress parse(const QString &address);
QString toString() const;
};

struct PeerEndpoint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thalieht

A possible way is to create another struct and use it only in peerlistwidget.cpp

Here is incorrect place. Seems it should be private for PeerListWidget.

src/base/bittorrent/peeraddress.cpp Outdated Show resolved Hide resolved
src/base/bittorrent/peeraddress.cpp Outdated Show resolved Hide resolved
src/base/bittorrent/peeraddress.cpp Outdated Show resolved Hide resolved
src/gui/properties/peerlistwidget.cpp Outdated Show resolved Hide resolved
src/gui/properties/peerlistwidget.cpp Show resolved Hide resolved
src/gui/properties/peerlistwidget.cpp Outdated Show resolved Hide resolved
src/gui/properties/peerlistwidget.cpp Outdated Show resolved Hide resolved
src/gui/properties/peerlistwidget.cpp Show resolved Hide resolved
@thalieht thalieht force-pushed the peerssameip branch 2 times, most recently from 4d474c8 to 902068b Compare January 28, 2020 19:33
src/gui/properties/peerlistwidget.h Outdated Show resolved Hide resolved
src/gui/properties/peerlistwidget.h Outdated Show resolved Hide resolved
Chocobo1
Chocobo1 previously approved these changes Jan 29, 2020
Copy link
Member

@glassez glassez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one more question. How do multiple peers from the same address differ in the peer list?

@@ -57,6 +57,25 @@
#include "propertieswidget.h"
#include "uithememanager.h"

namespace BitTorrent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed to declare the following under BitTorrent namespace? One can think that it is provided by qBittorrent base...

Copy link
Contributor Author

@thalieht thalieht Jan 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@thalieht
Copy link
Contributor Author

How do multiple peers from the same address differ in the peer list?

From their port and/or connection type.

The uniqueness of peers is now determined by their
IP, port and connection type (uTP etc.) instead of just their IP
@Chocobo1 Chocobo1 merged commit 11bea8d into qbittorrent:master Jan 30, 2020
@Chocobo1
Copy link
Member

@thalieht
Thank you!

@thalieht thalieht deleted the peerssameip branch January 30, 2020 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong displaying for multiple connections from a same IP (but different ports)
4 participants