PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Request for scripts => Topic started by: Jorgo on 05 August, 2010, 20:24:41

Title: DHT blocker
Post by: Jorgo on 05 August, 2010, 20:24:41
A new version of ApexDC++ just came out which has DHT enabled by default. A user in the private hub I'm in nearly had a heart attack when someone who's not a member started downloading files from him - and our user isn't in any other hubs.

What I'm looking for urgently is a method to detect DHT and block users who have it enabled in their client. I'm not sure if this should be done in ptokax itself or by script - either way it's pretty urgent. There are always users who never react to hub announcements where we would ask everybody to turn it off manually.

Because of the urgency of the matter, I'll also post this in the ptokax feature request section - please forgive double posting.
Title: Re: DHT blocker
Post by: lUk3f1l3w4lK3R on 06 August, 2010, 14:32:57
I tried such a script a while ago but with no success.
A script to disconnect users who have DHT enabled would be nice,
cause it doesnt matter on which kind of hub (NMDC or ADC) you are,
with DHT enabled, users that are not on the same hub can leech from you.
I run also a private hub and would like to see such a script
but i think its not possible due to the fact that a client that have the DHT
feature, only sends the info about this support when connecting to a ADC hub.
Therefore i dont see a way to block these clients with a PtokaX script.
When connecting to a ADC hub then ADDHT0 is send in SU (Support).
When this is not send in SU then DHT is disabled.
This info is not send by the client when you connect to a NMDC hub,
not in MyINFO and not in Support.
Maybe i missed something and somebody can enlighten me
but i think its not possible to write such a script for PtokaX.
Title: Re: DHT blocker
Post by: Naithif on 06 August, 2010, 14:39:42
Quote from: StrongDC++ nmdchub.cpp
StringList feat;
feat.push_back("UserCommand");
feat.push_back("NoGetINFO");
feat.push_back("NoHello");
feat.push_back("UserIP2");
feat.push_back("TTHSearch");
feat.push_back("ZPipe0");

if(CryptoManager::getInstance()->TLSOk() && !getStealth())
feat.push_back("TLS");

if(BOOLSETTING(USE_DHT))
feat.push_back("DHT0");

supports(feat);



Quote from: Test
$Supports UserCommand NoGetINFO NoHello UserIP2 TTHSearch ZPipe0 TLS DHT0


function SupportsArrival(tUser, sData)
if string.find(sData, "DHT0") then
Core.Kick(tUser, "Hub-Security", "Please turn off DHT in Settings/Advanced/Publish shared files on DHT and use it for searching alternate sources")
end
end


Should work... Modify it to your needs...

Possibly sending a message and disconnecting is better because supports arrive first from a client and maybe even before kicked users check.
Title: Re: DHT blocker
Post by: Jorgo on 06 August, 2010, 16:54:17
That works just fine, thanks a lot!
Title: Re: DHT blocker
Post by: pR0Ps on 06 August, 2010, 17:02:11
Just as an FYI to everyone looking for this, this script works for StrongDC++ 2.30+ and it's derivatives (such as ApexDC++ 1.3.5). At the moment these are the only clients that even support DHT, so this script will detect all DHT users, no exceptions (for now). Thanks for the post Naithif.

EDIT: NMDC hubs will receive "DHT0" while ACD hubs will get "ADDHT0".
Title: Re: DHT blocker
Post by: Yahoo on 06 August, 2010, 17:04:57
gr8 work @ Naithif

seen you are a long time :D
Title: Re: DHT blocker
Post by: PPK on 06 August, 2010, 23:01:38
Quote from: pR0Ps on 06 August, 2010, 17:02:11
At the moment these are the only clients that even support DHT, so this script will detect all DHT users, no exceptions (for now).
Wrong, there are other (and older) clients using Kademlia (http://en.wikipedia.org/wiki/Kademlia) DHT network and they are not detected by this script :P
Title: Re: DHT blocker
Post by: pR0Ps on 07 August, 2010, 05:09:35
Hmmm, didn't know that. Good to know. Probably not that relevant though, those clients have been around for a while and this seems to be a new thing for most hubowners. Is there any way to check for people using DHT on those older clients?
Title: Re: DHT blocker
Post by: Naithif on 07 August, 2010, 13:16:26
Quote from: PPK on 06 August, 2010, 23:01:38
Wrong, there are other (and older) clients using Kademlia (http://en.wikipedia.org/wiki/Kademlia) DHT network and they are not detected by this script :P

That doesn't really count because:

- This feat was requested on other places because Apex 1.3.5 enabled DHT by default. I believe the request here was connected and it is from the hub owner telling why they banned 1.3.5

- Latest kad client is RevConnect that has core 0.674 (other kad clients are even older) which is usually disallowed in private hubs.
Title: Re: DHT blocker
Post by: PPK on 07 August, 2010, 15:19:53
Quote from: Naithif on 07 August, 2010, 13:16:26
- This feat was requested on other places because Apex 1.3.5 enabled DHT by default.
Here it is requested as DHT blocker...
Quote from: Naithif on 07 August, 2010, 13:16:26
- Latest kad client is RevConnect that has core 0.674 (other kad clients are even older) which is usually disallowed in private hubs.
More 0.674 based clients have kademlia. And they all have kademlia from reverse connect (where it is from year 2003)  ::)
Title: Re: DHT blocker
Post by: Jorgo on 07 August, 2010, 18:28:06
Well, I'm no expert in the matter, but I'd like the script to be as complete as possible. The goal is to not permit any public connections on a private hub.
Title: Re: DHT blocker
Post by: Naithif on 09 August, 2010, 00:44:32
Quote from: PPK on 07 August, 2010, 15:19:53
Here it is requested as DHT blocker...

It does just that.
As far as one can do via hub/scripting. More can be done client level, but I doubt anyone will do that.

Besides the request was started as:

Quote from: Jorgo on 05 August, 2010, 20:24:41
A new version of ApexDC++ just came out which has DHT enabled by default.[...]

So... Exactly...



Quote from: PPK on 07 August, 2010, 15:19:53
More 0.674 based clients have kademlia. And they all have kademlia from reverse connect (where it is from year 2003)  ::)

Yes. What I've tried to say is that 99.99% clients that have kad are stuck on (at most) 0.674.

So banning older clients including 0.674 solves the problem.
Private hubs doesn't rely on usercount anyway, so doing that shouldn't be a problem. Some even enforce a particular client...


Title: Re: DHT blocker
Post by: P_pan on 19 August, 2010, 20:07:57
is it possibble to forward a msg to opchat as soon someone is  using this DHT stuff?

like : user:.... has dht enabled etc etc.... ?

thanks for this great script!
Title: Re: DHT blocker
Post by: P_pan on 20 August, 2010, 08:59:37
Thank You Master Mutor!

getting an little error though
DHT_block.lua: 4: unexpected symbol near "="

and scripts does crash
Title: Re: DHT blocker
Post by: lUk3f1l3w4lK3R on 21 August, 2010, 14:10:25
Quote from: P_pan on 20 August, 2010, 08:59:37
Thank You Master Mutor!

getting an little error though
DHT_block.lua: 4: unexpected symbol near "="

and scripts does crash

remove the , at the end of line 2 and the script starts and you dont get the error message


I get this error message when a registered user try to download filelist from another user:
PtokaX\scripts\kickdht.lua:34:attempt to perform arithmetic on field '?'(a nil value)
Title: Re: DHT blocker
Post by: P_pan on 21 August, 2010, 15:11:06
QuoteI get this error message when a registered user try to download filelist from another user:
PtokaX\scripts\kickdht.lua:34:attempt to perform arithmetic on field '?'(a nil value)

This error i don't have at all.....  total no lua error does show...

Ur Trick did solve  my prob...  Thank You lUk3f1l3w4lK3R


Title: Re: DHT blocker
Post by: P_pan on 23 August, 2010, 09:09:59
getting now indeed this error aswell but now on line 39

PtokaX\scripts\kickdht.lua:39:attempt to perform arithmetic on field '?'(a nil value)
Title: Re: DHT blocker
Post by: P_pan on 28 August, 2010, 12:32:22
Thank You....

works very fine :)
Title: Re: DHT blocker
Post by: somewherenotthere on 28 August, 2010, 20:57:35
Doesnt seem to be working... no errors, just not doing anything.
Title: Re: DHT blocker
Post by: somewherenotthere on 29 August, 2010, 06:45:03
Yes I do/did.

It is working now thought, weird...

kudos to the creators of this script, really really helpful!
Title: Re: DHT blocker
Post by: merlin_xl54 on 31 August, 2010, 01:19:07
I started using this in our private hub and seem to be getting quite a few notifications. Even from users with the newest DC++ 0.770. We also have some older clients too. Is there a cut off where clients have it on with no options to turn it off. Can it be listed under any other options? We have a lot of clients pre 0.699 etc?

TIA

M
Title: Re: DHT blocker
Post by: P_pan on 31 August, 2010, 21:27:29
it looks like this script is a little mean ghost.... :)

error: scripts\DHT_block.lua:50: attempt to concatenate a nil value

:)  on latest build....
Title: Re: DHT blocker
Post by: For_Ever_MeXxX on 17 September, 2010, 08:30:30
Hello,

how I can remove the Botname from the Report in Operator Chat?

<#Operator> <#Kolloid> The Unregistered User, NICK with IP: **.**.**.** is using DHT.


and if I set only Report it Spams the Operator Chat with the same message 5 times or sometimes more...
Look here...

[12:26:30] <#Operator> <#Kolloid> The Unregistered User, [ ROMANIA-GIRL ] with IP: [ **.**.**.** ] is using DHT.
[12:26:30] <#Operator> <#Kolloid> The Unregistered User, [ [ro][rds]fane ] with IP: [ **.**.**.** ] is using DHT.
[12:26:30] <#Operator> <#Kolloid> The Unregistered User, [ sdhgfnsdfsdxaz ] with IP: [ **.**.**.** ] is using DHT.
[12:26:30] <#Operator> <#Kolloid> The Unregistered User, [ [RO][AG][RDS][George_2010] ] with IP: [ **.**.**.** ] is using DHT.
[12:26:31] <#Operator> <#Kolloid> The Unregistered User, [ ROMANIA-GIRL ] with IP: [ **.**.**.** ] is using DHT.
[12:26:31] <#Operator> <#Kolloid> The Unregistered User, [ [ro][rds]fane ] with IP: [ **.**.**.** ] is using DHT.
[12:26:31] <#Operator> <#Kolloid> The Unregistered User, [ sdhgfnsdfsdxaz ] with IP: [ **.**.**.** ] is using DHT.
[12:26:31] <#Operator> <#Kolloid> The Unregistered User, [ [RO][AG][RDS][George_2010] ] with IP: [ **.**.**.** ] is using DHT.
[12:26:32] <#Operator> <#Kolloid> The Unregistered User, [ ROMANIA-GIRL ] with IP: [ **.**.**.** ] is using DHT.
[12:26:32] <#Operator> <#Kolloid> The Unregistered User, [ [ro][rds]fane ] with IP: [ **.**.**.** ] is using DHT.
[12:26:32] <#Operator> <#Kolloid> The Unregistered User, [ sdhgfnsdfsdxaz ] with IP: [ **.**.**.** ] is using DHT.
[12:26:32] <#Operator> <#Kolloid> The Unregistered User, [ [RO][AG][RDS][George_2010] ] with IP: [ **.**.**.** ] is using DHT.
[12:26:33] <#Operator> <#Kolloid> The Unregistered User, [ ROMANIA-GIRL ] with IP: [ **.**.**.** ] is using DHT.
[12:26:33] <#Operator> <#Kolloid> The Unregistered User, [ [ro][rds]fane ] with IP: [ **.**.**.** ] is using DHT.
[12:26:33] <#Operator> <#Kolloid> The Unregistered User, [ sdhgfnsdfsdxaz ] with IP: [ **.**.**.** ] is using DHT.
[12:26:33] <#Operator> <#Kolloid> The Unregistered User, [ [RO][AG][RDS][George_2010] ] with IP: [ **.**.**.** ] is using DHT.
[12:26:34] <#Operator> <#Kolloid> The Unregistered User, [ ROMANIA-GIRL ] with IP: [ **.**.**.** ] is using DHT.
[12:26:34] <#Operator> <#Kolloid> The Unregistered User, [ [ro][rds]fane ] with IP: [ **.**.**.** ] is using DHT.
[12:26:34] <#Operator> <#Kolloid> The Unregistered User, [ sdhgfnsdfsdxaz ] with IP: [ **.**.**.** ] is using DHT.
[12:26:34] <#Operator> <#Kolloid> The Unregistered User, [ [RO][AG][RDS][George_2010] ] with IP: [ **.**.**.** ] is using DHT.
[12:26:35] <#Operator> <#Kolloid> The Unregistered User, [ ROMANIA-GIRL ] with IP: [ **.**.**.** ] is using DHT.
[12:26:35] <#Operator> <#Kolloid> The Unregistered User, [ [ro][rds]fane ] with IP: [ **.**.**.** ] is using DHT.
[12:26:35] <#Operator> <#Kolloid> The Unregistered User, [ sdhgfnsdfsdxaz ] with IP: [ **.**.**.** ] is using DHT.
[12:26:35] <#Operator> <#Kolloid> The Unregistered User, [ sossana ] with IP: [ **.**.**.** ] is using DHT.
[12:26:35] <#Operator> <#Kolloid> The Unregistered User, [ [RO][AG][RDS][George_2010] ] with IP: [ **.**.**.** ] is using DHT.
[12:27:48] <#Operator> <#Kolloid> The Unregistered User, [ ROMANIA-GIRL ] with IP: [ **.**.**.** ] is using DHT.
[12:27:48] <#Operator> <#Kolloid> The Unregistered User, [ [ro][rds]fane ] with IP: [ **.**.**.** ] is using DHT.
[12:27:48] <#Operator> <#Kolloid> The Unregistered User, [ sossana ] with IP: [ **.**.**.** ] is using DHT.
[12:27:48] <#Operator> <#Kolloid> The Unregistered User, [ sdhgfnsdfsdxaz ] with IP: [ **.**.**.** ] is using DHT.
[12:27:48] <#Operator> <#Kolloid> The Unregistered User, [ [RO]90-CMO ] with IP: [ **.**.**.** ] is using DHT.
[12:27:48] <#Operator> <#Kolloid> The Unregistered User, [ [RO][AG][RDS][George_2010] ] with IP: [ **.**.**.** ] is using DHT.
[12:28:46] <#Operator> <#Kolloid> The Unregistered User, [ ROMANIA-GIRL ] with IP: [ **.**.**.** ] is using DHT.
[12:28:46] <#Operator> <#Kolloid> The Unregistered User, [ [ro][rds]fane ] with IP: [ **.**.**.** ] is using DHT.
[12:28:46] <#Operator> <#Kolloid> The Unregistered User, [ sossana ] with IP: [ **.**.**.** ] is using DHT.
[12:28:46] <#Operator> <#Kolloid> The Unregistered User, [ sdhgfnsdfsdxaz ] with IP: [ **.**.**.** ] is using DHT.
[12:28:46] <#Operator> <#Kolloid> The Unregistered User, [ [RO]90-CMO ] with IP: [ **.**.**.** ] is using DHT.
[12:28:46] <#Operator> <#Kolloid> The Unregistered User, [ [RO][AG][RDS][George_2010] ] with IP: [ **.**.**.** ] is using DHT.
Title: Re: DHT blocker
Post by: somewherenotthere on 19 September, 2010, 21:56:55
hey mutor, this is definitely a helpful script, apex users are now aware of the fact that dht is enabled.

The problem that i am experiencing is that, on user arrival, the opchat gets spammed with msgs of all users using dht and multiples of this:

Quote[21:39:34] <*> <*> The Reg, *with I.P.: *.*.*.*is using DHT.
[21:39:34] <*> <*> The Owner, *with I.P.: *..*.*is using DHT.
[21:39:34] <*> <*> The Reg, *with I.P.: *.*.*.*is using DHT.
[21:39:34] <*> <*> The Owner, *with I.P.: *.*.*.*is using DHT.
[21:39:34] <*> <*> The Reg, *with I.P.: *.*.*.*is using DHT.
[21:39:34] <*> <*> The Owner, *with I.P.: *.*.*.*is using DHT.
[21:39:36] <*> <*> The Reg, *with I.P.: **.*.*is using DHT.
[21:39:36] <*> <*> The Owner, *with I.P.: *.*.*.*is using DHT.
[21:39:36] <*> <*> The Reg, *with I.P.: *.*.*.*is using DHT.
[21:39:36] <*> <*> The Unregistered User, *with I.P.: *.*.*.*is using DHT.
[21:39:36] <*> <*> The Owner, *with I.P.: ***.*.*is using DHT.

I have report only on fyi. Any help? it seems like such a random thing
Title: Re: DHT blocker
Post by: somewherenotthere on 20 September, 2010, 09:54:48
Hey Mutor, I did read them yes, and i used the latest one. Unless there is something i missed in those 2 posts? Or perhaps you could make it clearer as to what your suggestion is in those posts?
Title: Re: DHT blocker
Post by: For_Ever_MeXxX on 20 September, 2010, 12:58:19
He is right Mutor, my Opchat get spammed again, too...
Title: Re: DHT blocker
Post by: lUk3f1l3w4lK3R on 20 September, 2010, 17:35:30
First version of this script did exactly what the script did, that i tried to make myself: it didnt disconnect users with DHT enabled clients (yes, there where DHT enabled clients).
Now the 2nd version of your script works like it should work.

I dont know what caused the issue with your first version
but thanks for updating your script.

Good work as allways Mutor.

Thx alot.
Title: Re: DHT blocker
Post by: For_Ever_MeXxX on 20 September, 2010, 22:08:43
Yes, it was always the same IP for one User...


I was getting the msg from 3 user with DHT in 4secs 4-5times then it stops and after same mins it was starting again...
Title: Re: DHT blocker
Post by: somewherenotthere on 21 September, 2010, 17:40:20
Quote from: Mutor on 21 September, 2010, 04:57:14
No Sir, I was asking if more than one user on a common IP
Hey Mutor, no problem. The users were completely different, and in fact one user was myself (owner) as I was testing the reporting capability. I have since disabled it and have had the problem again, last part of IP left intact for your consideration:

Quote[15:43:37] <*> <*> The Reg, *with I.P.: *.*.150.180 is using DHT.
[15:43:38] <*> <*> The Reg, *with I.P.: *.*.150.180 is using DHT.
[15:43:39] <*> <*> The Reg, *with I.P.: *.*.150.180 is using DHT.
[15:43:41] <*> <*> The Reg, *with I.P.: *.*.150.180 is using DHT.
[15:43:41] <*> <*> The Reg, *with I.P.: *.*.37.234 is using DHT.

If you note: the first 4 are the same person, the last is a different person. This swaps each time, leading me to believe that it is triggered by it checking one user.

It is not a terrible problem, just slightly annoying in what is really helpful script (many kudos to Mutor and other contributors) as the hub is meant for a certain country only, and the apexdc++ devs for some really silly reason decided that they should ship it with it enabled.

Again, thank you for helping out so much Mutor, you have made running a hub much nicer with the many scripts you have made/helped make.
Title: Re: DHT blocker
Post by: somewherenotthere on 22 September, 2010, 18:33:03
Quote from: Mutor on 22 September, 2010, 00:07:05
Another revision, testers welcome.
Also I removed the original script as
I feel at least some people may have
been using that version unwittingly.

Hey Mutor, seems to be better now... i was using the one with the options listed as "0 ,1 , etc"

Title: Re: DHT blocker
Post by: For_Ever_MeXxX on 22 September, 2010, 20:55:14
Working great now... No problems anymore...

Great work, Mutor.  ;)
Title: Re: DHT blocker
Post by: merlin_xl54 on 24 September, 2010, 03:38:46
Hi Mutor,

Thanks for all your work. I received this in error from the bot. scripts\DHTDetector.lua:27: bad argument #1 to 'insert' (table expected, got number)
Line 27--> table.insert(Tab[user.sIP],1,GetProf(user))

Thanks again,

M