marceldev89 / BattleNET

BattlEye Protocol Library and Client
GNU Lesser General Public License v3.0
76 stars 44 forks source link

Requesting Bans then Players #37

Closed MikeDev96 closed 8 years ago

MikeDev96 commented 9 years ago

Okay so I'm not sure if this is an error on my behalf or a bug within the BattleNET library, but here goes.

If I request bans then request players, sometimes it will return a half completed ban list and then the players all as one message. Sometimes it will just return the player list then spam a load of empty \r\n after it like it's trying to load the ban list. This is very annoying as it causes an error when trying to parse the data.

Atm I'm using a 'hacky' fix which is creating a new BE Client and requesting the bans on that, not proud of it but I'm stuck for options atm... I have also tried checking if the queue is > 0 but that didn't seem to help either.

I hope you still support this project, and if not at least get back to me...

Thanks, Mike.

MikeDev96 commented 9 years ago

It looks like this baring in mind I have 400+ bans on my server:

GUID Bans:
[#] [GUID] [Minutes left] [Reason]
----------------------------------------
0  ac70059a5bb3da673788fc3a9f51ec78 perm Admin Ban
1  7d5da9cee210c428bab96707e961b0a2 perm Admin Ban
2  b5b5086e338b076873e24176eb8825b6 perm Admin Ban
3  0d6ff564461e30a603839c9de7129c87 perm Admin Ban
4  b9c6cb18449d39c79841d0cba8501f4e perm Admin Ban
5  aae70bc4d7f994af20fb974b17df6654 perm Admin Ban
6  5bd77b80398fe0bdb584a954a1fecc39 perm Admin Ban
7  01e7ee150cb4f338472ab990884ed28d perm Admin Ban
8  9570653a76153bca3d0bf6ff9070cc69 perm Admin Ban
9  919f0f1396092faa4d448d33f359d68d perm Admin Ban
10 fdf186a73f660e5ccebe18132c29bea8 perm Admin Ban
11 c509563882c51dadbd96f6d2f3bb4e84 perm Admin Ban
12 a0df66befdce11afeb6ea84d2acedc99 perm Admin Ban
13 23b247dd72211bfe5ef4f47763fff02f perm Admin Ban
14 8647c93a616e73770b4c3613ca5a5023 perm Admin Ban
15 2ed08b959bbe12ffbbfd5cfc7de5f40a perm Admin Ban
16 ac37cdc94c1ddb99b0f52166aa1b3aff perm Admin Ban
17 60c28370d769645e64c4cb0bee9b80b3 perm Admin Ban
18 12b643c4bb1a4f7788250463e79c2313 perm Admin Ban
19 f02909d4f1e3e92f8ecb018917c7f6f2 perm Admin Ban
20 deedbf4235dc678f93f78036916d1a18 perm Admin Ban
21 ffa041b5bb3744d99955f1c5a817c20b perm Admin Ban
22 23c4d57b2d281022db95dd779c314e27 perm Admin Ban
23 38de9a2e947fdea21d52a951420b9e64 perm Admin Ban
24 31170a484709c5f08994fc9f375a7b93 perm Admin Ban
25 fad693bec500dd75da43d218f2a7c679 perm Admin Ban
26 6a3b80744da1a816c7454cebbb41a38e perm Admin Ban
27 bdf2528680afe8c9dadd7bae4db10dea perm Admin Ban
28 5470d8b1c61895dd8906c5178266a33f perm Admin Ban
29 4b32468e1dbb38da5ad5d4f48417e026 perm Admin Ban
30 b511a5c92fa1911bf76316c8ce1f4f81 perm Admin Ban
31 55af6b08e75872a7b058eceeecc7bdc9 perm Admin Ban
32 c16ea2f143d10e08d838213ae02b2c1f perm Admin Ban
33 4a60c2d0e40294a055201ddc85347a4d perm Admin Ban
34 85a2e9b9c039222f7a6ee9ee2ecd8c6b perm Admin Ban
35 c193149cea1e4e261bdd9ad40ba47694 perm Admin Ban
36 0df3fb4f2c62e20f10c8bcb83e59ff56 perm Admin Ban
37 1b3e08425e22b7bf2c0ad0517219fd70 perm Admin Ban
38 deccabc013a463176a223e39e8665670 perm Admin Ban
39 71ba31e079b5b995dcdca64cbf76648c perm Admin Ban
40 19c18772d51c1321b896ed8a1be1b946 perm Admin Ban
41 8d3ec9fe34f1cd1564f479f4c64c8e9d perm Admin Ban
42 fead60c8082e6831763cc23dc136314d perm Admin Ban
43 91e43f9297c6c8050f337694ba7c6356 perm Admin Ban
44 77259fe768ef32de477f628863048010 perm Admin Ban
45 922c49ec6ff27c1814a0f80f7118cc0c perm BEC : GameHack #38
46 65fe522ded007171f72d2f8321bbc140 perm Admin Ban
47 2ab69eb4e57f927065df5059f3540034 perm Admin Ban
48 466fd9664dc918d21a02fa04bc9b001d perm Admin Ban
49 43baea96f747427f0520a818d05fb5f2 perm Admin Ban
50 867810eacb711d24b448b13bf9809087 perm Admin Ban
51 638810ff6b23802bfabd398be7d390ed perm Admin Ban
52 443848864102c73763ef24ad7a79ee40 perm Admin Ban
53 ba42acc918e79a71a1477ea03d0c2a6a perm Admin Ban
54 8ff84835492966611c4273e1bf23d94e perm Admin Ban
55 6518d862a40c758e455735c8814273d7 perm Admin Ban
56 7854ec4dda75b535541e5eac62ac85ff perm Admin Ban
57 c7d1c24bcbcf8125ed915e3e81624b35 perm Admin Ban
58 178118524cf1363ea1b51f2fba46155a perm Admin Ban
59 f572668f5cf87f2bcca3046725ffec10 perm Admin Ban
60 66006b42151fb522cd9088e3cec95512 perm Admin Ban
61 dd08c9581279cbfafceb7c290fb893bd perm Admin Ban
62 0c345bb4ab69446e3952c790eeeb5709 perm Admin Ban
63 8381f4874c89b43d970c9088d84ba6c5 perm Admin Ban
64 69a1ebfa632f3942d291a871d98959f9 perm Admin Ban
65 f19d15d348c6a3a30ff39ead8d7e5b0f perm Admin Ban
66 dc50857339a556dd4033802357e2cb15 perm Admin Ban
67 ab5032206ec890df8b1608103901b51a perm Admin Ban
68 ac4ee8cf1d0b9caeea79290d3fc36af3 perm Admin Ban
69 c8013438d4644929e117feab49e48317 perm Admin Ban
70 f25079b09cb6e616cc8e416a0bd03554 perm Admin Ban
71 691550a9d4000e8dc8d339b9d145a323 perm Admin Ban
72 cfebe1ac3946cc404c1ca9a257a71889 perm Admin Ban
73 2f4199c6372b835a9d56741f1565b957 perm Admin Ban
74 ce7a80665c4e0ba03cf20fcfbfcf7e75 perm Admin Ban
75 fffc84616b3cda6c602ad408820a8b40 perm Admin Ban
76 2337eece3dd1f54f3e89252052e0a710 perm Admin Ban
77 f6c42a3b04bdfdc94b8546f4ffb3e8de perm Admin Ban
78 5c8b96e51f99021f1633629aa910d35f perm Admin Ban
79 44b16554a5ab8d81926bf035020f39ea perm Admin Ban
80 73063f0ebe08b49ea44d58eadd302b5e perm BEC : GameHack #38
81 2cbf250973c6d86d2a685b92ed082518 perm Admin Ban
82 afce6e8c763fdc0c482bb6507d65db07 perm Admin Ban
83 938d926b76418080ec672b9ada2b49c7 perm Admin Ban
84 ff83c76f7546c15c80d58ef118b989f4 perm Admin Ban
85 be4d2cb73d3b09a3c72c748ccfbaee09 perm Admin Ban
86 d16e46b2e1faa7a38c2d848b56e3d6a9 perm Admin Ban
87 49f906967e40a3a25248e5424f5a7c99 perm Admin Ban
88 873c76271be9cd107cb1e97cbce7d81d perm Admin Ban
89 5dc6149c5fb9ab3239ca6a8e3a81a68a perm Reason: Hacker
90 4cc925c0e56c3fedf1241ff1b48f3c35 perm Reason: Trolling
91 755743d6cb66bf3bebe8ff57f32f72cf perm Reason: Trolling
92 ddce32539073eea5a1958c0c572154cc perm Reason: Trolling
93 66c17c6f0624e1c054de7aacaa502307 perm Reason: Trolling
94 763403529000858eb9c6c436061696f2 perm Reason: Hacker
95 63d25cfce2a1037c6981aa0ca59cb2e5 perm Reason: Hacker
96 94091ae87349a56c78a7f1dcf6acdbee perm Reason: Trader City Troll
97 9fd8ac5a2adaec14fee1f48cc98dfe48 perm Reason: Trader City Troll
98 8b070a97741bce3ac7b8d2534fc57744 perm Reason: Trader City Troll
99 6f8205d61047d1d2caa655a7057900f0 perm Reason: Hacker
100 b5ff67c1de35591d903e506a40ea03d6 perm Reason: Hacker
101 7cd9b800f972cbb94db59c42ddd0f107 perm Reason: Hacker
102 5b950f4f09dfde3146f5c92d7a6a2ef2 perm Reason: Hacker
103 a89d258dc2dc69b7a76600da394059c7 perm Reason: Hacker
104 417327841cdbe6f78002b6988dc76577 perm Reason: Hacker
105 4c3b60b3d77ad21c6fcb3f2a7bb13df7 perm Reason: Hacker
106 5c65d07c48c4b5d0241b66790753eb57 perm Reason: Script Kiddie
107 6257c40c9859c002661501922fa8dd79 perm Reason: Trader City Troll
108 ba635c44409277756b9327637fe1bfd0 perm Reason: Hacker
109 e80fb48ee94afe7a441760f802412e4c perm Reason: Trader City Troll
110 87336aecdea15b42f8c12990e2b9c80d perm Reason: Trader City Troll
111 cb7041449771adf82a68792cdc0b8f70 perm Reason: Trader City Troll
112 429684ea3abeea497d931eb837e95527 perm Reason: TrPlayers on server:
[#] [IP Address]:[Port] [Ping] [GUID] [Name]
--------------------------------------------------
0   x     31   2b9b8192583bdbf028ad6db31fc07ae5(OK) Gemma (Lobby)
1   x      78   a341949171fce884382e7eb53b351aba(OK) Caddy
4   x    47   a727047c92f8ed72f19e2d3af4a02e80(OK) ado
5   x    31   d875b8dc44b50b5132aad6dbfb0e574f(OK) PLeS Vlad
7   x     31   a2c5782f6c8880b8c91de5407a9bdba3(OK) Rober
8   x   31   8c8aa282943b1227d85749ca522eaf03(OK) derGeneral000
9   x    47   efa1a9262fcf60520a07fd11e3c21b8c(OK) LinkSent
10  x    78   faed7a254287417a60e2dde4361257e2(OK) SimonPhoenix (Lobby)
11  x   16   8a914e847ce52b3a85c6f5114e6d30cb(OK) Andreas
12  x    16   2cb824a72ca280d899f231fb5ac9a00b(OK) Shadow
13  x   16   04cd40db77b2720cdc6c8924593cb485(OK) Janne
15  x     31   5ee0766764dac83bab1eebae8bc9a3bd(OK) Sapphire
16  x   47   951e2e9223631d92afe09c7c3a5e33b8(OK) Dylan
(13 players in total)
marceldev89 commented 9 years ago

Are you using the last available code? I had a few issues with ban lists in the (like 2 or 3 years ago) but I'm pretty sure that I fixed those issues back then. Check https://github.com/mvries/BattleNET/issues/1 for reference.

Checking the queue should work fine though, I've been using it in my RCon test client (check https://github.com/mvries/BattleNET/blob/78048821de79d3b2ba4298a95e1b918e844a3d34/BattleNET%20client/Program.cs#L75).

I'm unsure how much this library is still used in the community but this issue hasn't been reported between august 2012 until now so I'm going to guess it's on your end somewhere.

Other than that, last time I did some real work on this library was like 2 years ago so it's not really supported anymore. Unfortunately I lost interest in hosting servers so I pretty much stopped working on this. But as far as I know it'll work fine until BattlEye changes their protocol.

MikeDev96 commented 9 years ago

Well first of all thanks for getting back to me. Yes I am using the latest code, to be extra sure I just compiled the source again and tried it again but still... no luck. Please could you take a look at this: http://puu.sh/is2LJ/ae2f786641.mp4

This is the bug in action, atm I can't get you a video of it cutting the bans half way, that only seems to happen when the server is under load. In the video you will see I click bans then players, the amount of blank lines you get back seems to depend on the duration between the click of bans then players. If you click bans then players quickly, you get more lines, click them slowly you get less lines etc... Seems to me like the ban request is being written over by the player request, not cancelling it but idk... Would love to be able to resolve this atm, bit of a road block for me atm.

Btw, I am correct in thinking the files on Github are the latest files right? So I just download it as a zip then compile myself?

marceldev89 commented 9 years ago

Yeah github files are latest.

The problem I'm seeing is that you're not waiting for the other command to finish. This is sort of how BattlEye / UDP works. Not much we can do about it other than waiting for the command to finish. The queue should help you here but if it's not working make sure that the log parameter is true when you so your command calls. So basically block input until queue is empty.

MikeDev96 commented 9 years ago

Alright, so I made a whole new project to eliminate any potential screw ups on my behalf. I have collected some data:

Video: http://puu.sh/isEJO/13f7de2795.MP4 Sample Project: http://puu.sh/isEQj/58c697e618.ZIP

So, in short this is what I did:

Thread t = new Thread(new ThreadStart((MethodInvoker)delegate {
    Console.WriteLine(c.CommandQueue);
    c.SendCommand("bans");
    Console.WriteLine(c.CommandQueue);
    while (c.CommandQueue > 0) { }
    Console.WriteLine(c.CommandQueue);
    c.SendCommand("players");
    Console.WriteLine(c.CommandQueue);
}));
t.IsBackground = true;
t.Start();

The console gave me this:

0
1
0
1

And the messages received are showed in the video above.

I was looking at the BE RCon protocol and had an idea, I haven't looked thoughourly into the code but is it possible that the queue is being cleared of the ban request once the first packet has been received? To my knowledge, some messages come back in multiple packets aka. fragments. Is it possible that the first fragment is being received and the queue is being cleared before the rest of the fragments have arrived? Just a thought, I don't know too much about how this all works, I would just really love to get a solution to this.

Cheers for taking your time to help me bud, I appreciate it.

MikeDev96 commented 9 years ago

Quick little update, I just tried it again, server has been up for half an hour and now it's doing the thing where it cuts half way through the ban list. Seems to do this when the server is under some kind of load. http://puu.sh/isGjf/5956371bcc.png Everytime I press the button it cuts through at the exact same spot everytime.

marceldev89 commented 9 years ago

Seems to me that the server is dropping packets. I'd imagine that RCON stuff is fairly low priority network wise (if such a thing even exists :smile:). Anyway, as far as I know it's not something that I can do anything about. Ban lists have always been a little bit problematic in the past but I'm not sure if it's because of me or the BattlEye stuff.

Maybe try to contact the dude that made the EPM RCon client, if I remember correctly his team was doing some improvements on the library a while ago. So they might have fixed this. BUT they may also have dropped this library for something of their own.

MikeDev96 commented 9 years ago

There must be something funky going on in your library, I tried requesting both at the same time on BERCon and it worked fine, I'm pretty sure your queuing system isn't working correctly :/ Thanks for your time though bud, I'll just stick with making a whole new client and requesting the bans that way.

marceldev89 commented 9 years ago

Hmm, well I took a really quick look at the queuing system and I might have spotted the issue with it. Try wrapping this in an if that checks if state.PacketsTodo is bigger than zero.

DomiStyle commented 9 years ago

It has been a while since I took a look at DaRT but I just saw those comments on my Github main page.

I had this change implemented in DaRT for a very long time, I apologize for not commiting it. @Mikeeeyy Take a look at this and see if it fixes this problem for you: https://github.com/DomiStyle/BattleNET/commit/50f4b1e1ee5ab2f55744139789c91a1f606b06a5

The issue pretty much just was that BattleNET was assigning duplicate package ids - resulting in cut-off player/ban lists or DaRT getting stuck (timeout). While there was a packetID to overcome this problem it was simply never used (maybe forgotten?). To be sure I gave it another spin with both versions of the library. The original one failed while with this fix I could request long ban lists (3000+) without problems.

I really hope I could help you out - sorry again for not commiting this. (feel free to pull it)

marceldev89 commented 9 years ago

Kinda odd thing to forget to use a local variable that I already defined.

@DomiStyle, thank you for commenting and providing a fix after all this time! And don't feel sorry; people forget, life happens, etc. :smile:

marceldev89 commented 9 years ago

Pulled the code https://github.com/mvries/BattleNET/commit/50f4b1e1ee5ab2f55744139789c91a1f606b06a5, thanks again.

MikeDev96 commented 9 years ago

Sorry for the delayed response... as much as it pains me to say... this did not fix it :/

DomiStyle commented 9 years ago

@Mikeeeyy Are example credentials available where this problem occurs?

MikeDev96 commented 9 years ago

@DomiStyle Thanks for the reply but it doesn't matter anymore. I tinkered around with the library a bit and found out that what I said earlier is correct. In a multipart message the queue is cleared when the first part is received. On my server it takes 25 messages to fully fetch the ban list, the queue was being cleared once message 1 was received. All in all I have decided to create my own library as I have learnt quite a lot just by reading the BE RCon Protocol and the BattleNET library.

marceldev89 commented 8 years ago

Alright, I've got a proper fix for the banlist issues and created a temporary branch for it. You can find it here. It needs to be tested for a little while before being merged back into the master branch because it might have some side effects.

Thanks to @EPM-Cortez for bringing this to my attention (again) and pointing me in the right direction. :smile: