jackpoz / BotFarm

Application used to spawn WoW automated players compatible with 3.3.5a version only.
GNU General Public License v2.0
84 stars 68 forks source link

Bot authentication with delay - server with anti-flood rejects connections #35

Closed Magic-WoW closed 8 years ago

Magic-WoW commented 8 years ago

Hi there!

There are some cores like Sunwell Core and Trinity probably too which have anti-flood system when one ip address tries to send multiple logon challenges at the same time. I think that there should be a system which will delay sending packets from each bot by some time. I don't know C# well, tried to sleep the threads, by they're async-tasked somehow and I can't achieve the goal.

As bots are multithreaded, packets are going out at the same time and they arrive nearly at the same time too. If you have any suggestion how to fix that, It would be perfect and useful! :)

jackpoz commented 8 years ago

Bots are started using Parallel.ForEach at https://github.com/jackpoz/BotFarm/blob/master/BotFarm/BotFactory.cs#L187 and at https://github.com/jackpoz/BotFarm/blob/master/BotFarm/BotFactory.cs#L195 , you probably want to change that to a sequential for loop with Thread.Sleep() or waiting for the bot to be connected. Bots will still try to auth all at once if for some reason they get dc'd.

It probably spotted that your anti-flood system is broken when multiple clients share the same ip, say an Internet Point or shared wifi for example.

Magic-WoW commented 8 years ago

As I said, I don't know C#, but this did the work!

foreach (BotInfo info in infos) { Thread.Sleep(2000); var bot = LoadBot(info); lock (bots) bots.Add(bot); Interlocked.Increment(ref createdBots); }

for(int i = 0; i < botCount; i++) { Thread.Sleep(2000); try { var bot = CreateBot(); lock (bots) { bots.Add(bot); if (bots.Count % 100 == 0) SaveBotInfos(); } } catch (Exception ex) { Log("Error creating new bot: " + ex.Message + "\n" + ex.StackTrace, LogLevel.Error); } }

Thank you very much!