-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
peer blacklist #251
peer blacklist #251
Conversation
Ah... |
as I understand correctly from discussion in #190 , whitelist caused some mess. sorry... now users who want just to block something also have such option, not only "drop everything except allowed". in any case, I think whitelist is useful in cases described by me in PR, but maybe it is for advanced users... if you download/seed torrents from the same source(s), peers base is pretty consistent, and it is very easy to collect statistics who and what connects to you. even observation in a week is enough to get approximate picture. and it is much easy to create whitelist based on such statistics rather than blacklist. P.S> now I'm plan to refactor these black/white lists implementation. I think log messages about missing filters file per torrent are very annoying, and also some static variables used in code are ugly (they are just a trick). I found more elegant way to do the same, but some time is required for testing and polishing. Nothing will be changed from end user point of view (exception only one log message will be produced only once on startup, instead of message per torrent). |
Peers who are always choking should be dropped, and make peers' priority down in case very big DL/UL ratio when torrent is not seeding. |
@Kolcha I'm also thinking about doing a blacklist function, but "eh", why I'm figuring my own life and stuffs so slowly and lazily... A traffic based blocking / UL speed restricting plugin is a lot more complex to implement. Like, you do want to seed an old torrent to some client requesting it if you believe (s)he will continue to seed, even if this could only happen in a week later or so. A reasonable way to do this is to build a credit system, but I don't think we are trying to implement a better "FileCoin" here, or are we? Would you like to share your initial thought about the algorithm you might implement first? |
@escape0707 first try to implement "smart" plugin was just to track reported progress and drop peers which don't update it for some time (calculated based on uploaded data). this implementation was targeted only to drop "downloaders" (because I saw a lot of such peers connected to my server). but I see that is not enough... and right now I know too little about torrent internals, I have to read some theory. so, right now I have no any ideas or plans regarding algorithm... |
Oh, I see. So you suggest to first create a plugin to impose a stricter banning rules to avoid "liars" and "malfunctioning clients". That's fair. |
I'm not sure why
|
it is printed on each added torrent due to implementation... with new implementation I'm working on this will not happen (more correctly will happen only once at startup) |
Thank you~ |
Today I tried your patch and:
I found "blacklist ban by just peer client name" won't work. For example:
in the Then I glanced at the code, and think it's because you've adopted the code from the peer_whitelist logic, and it only looks at peer_id to determine whether to block or not at handshake time. This works fine for whitelisting but not blacklisting. Because in whitelisting, Would you like to try reproducing this issue? 😉 |
yes, blacklist was implemented based on whitelist logic. and this is not surprising that there are may be some errors... |
@escape0707 |
Does this means at that case, whitelist will be completely ignored? I want to whitelist Transmission but not Transmission/2.94 because Motrix is using it. But it seems that if blacklist exist, whitelist is completely not functioning. I was thinking that these two filters act like "only let peers allowed by both rules (intersection) to connect". Plus, is it possible and better to disable the whitelist and blacklist plugin for private torrents? |
no, whitelist rules are still applied, right after blacklist ones, see
it should be so. but due to very unstable nature of client name reporting some errors may occur. real client name (reported by client itself) became known only after few bittorrent messages (after "bitfield" message in most cases), but until this happen client name has string guessed by libtorrent, and it may affect filters if it is not replaced in appropriate time. for my personal case (I have slightly different filter built just for my server) I patched libtorrent to disable this guessing and track just empty name (it is empty until client reports something). please note that there are clients which don't report client name at all through whole communication session! but fortunately, usually such clients have suspicious peer IDs or just something I would like to block.
this requires some code changes and recompilation, required check to ignore private torrents must be added here
required check looks like
sorry for delayed answer |
Then I think there might be a bug, I have:
and:
And I'm still getting a lot of peers. I think we have to look closer into this.
Maybe I could give a try on it, thanks for the points you've given! |
slightly strange, will look into it in few days |
@Kolcha I'm still looking at it, a first guess is that |
@Kolcha Oh my god, only a fool like me will spend so much time looking at the older version of this code. And thinking about a pointed outer world storage's state, and then realize that I should look for the source of the bug in the latest version of the code...... I'm completely out of speech at the moment...... Any way, the reason is very straight forward: qBittorrent-Enhanced-Edition/src/base/bittorrent/peer_filter_session_plugin.hpp Lines 61 to 77 in fd04741
If blacklist rule file exist, this method will always return prematurely at L68. The whitelist match code block will never be reached. I think I can file a PR to fix this and also add the logic to bypass PT torrents. What's your thought? |
ugh... when I looked into it to answer your question I even didn't notice this
feel free to do this. moreover, original "blacklist" filters are enabled only for public torrents |
added custom peer blacklist support as counterpart of previously added in #238 peer whitelist.
closes #190 , closes #223 , closes #226 , closes #248 , closes #51 ,
very likely few more issues can be listed here, but it is pretty hard to me to find them...
blacklist rules are placed in external file 'peer_blacklist.txt', located in qBittorrent data directory ($HOME/.local/share/qBittorrent in case of Linux). if there is NO such file plugin is not activated. it is completely safe to keep empty file - this just means "nothing blacklisted". the same rules syntax and logic are used as for whitelist, but just for blacklisting.
for example, to blacklist client mentioned in #190 , next line can be added to blacklist:
in this case
.*
means "any client name", i.e. "ban peer by id". of course, client name matching pattern (or exact name can be added). to ban peer by client name regardless its id, just place.*
instead of peer id matching pattern. beware,.*
in both fields means "blacklist everything"!info about banned peers is saved in the same table in peers.db SQLite database, but only with tag "blacklist".
blacklist can co-exists with whitelists, but this is meaningless. in any case, blacklist rules take precedence. as whitelist, blacklist is applied for all torrents, not only public.