alama / PSO2Proxy

A protocol proxy for PSO2
GNU Affero General Public License v3.0
2 stars 2 forks source link

make sure chat packet be sent at "the right time" #16

Closed frkami123 closed 7 years ago

frkami123 commented 7 years ago

as far as i know that if proxy send chat packet (system) before damage packet (and few other types) it will make client disconnect from proxy. i haven't seen this issue on cyberkitsune proxy (but can reproduce with plugin) but i still wondering if it exists and randomly disconnect clients with gchat enabled since send_crypto_packet direct call transport without any concern. https://github.com/alama/PSO2Proxy/blob/public/proxy/ShipProxy.py#L58-L63

pseudo plugin code to reproduce the issue

@plugins.raw_packet_hook
def on_packet_received(context, packet, packet_type, packet_subtype):
     if packet_type == 0x04 and packet_subtype == 0x52:
          context.send_crypto_packet(packetFactory.SystemMessagePacket("danger", 0x3).build())) # client disconnect from proxy after receive this packet
alama commented 7 years ago

The game do not send encrypted packets until the RC4 handshake is done , so MOST call send_crypto_packet, only the shiplist send/reply are unencrypted

it is on the transport, so the packet data is a on a WAITING list to send out back once the server program go back to the reactor loop

frkami123 commented 7 years ago

I don't think the issue relate to encrypting or packet's synchronization but more likely about packet order. For example, client will disconnect itself from proxy if it receive a chat packet (0x19, 0x01) when it expect damage packet (0x04, 0x52) to come next (like i have pointed out in last comment).

I mean proxy shouldn't insert its customized packet between packets sequence that client is expecting. I tried to send chat packet every 100ms to global chat in my proxy implementation (C++, phantasy proxy) and this issue occur.

That's my conclusion, not 100% sure but i think it exists. I will investigate to find more evidences.

frkami123 commented 7 years ago

this is embarrass, i try again and everything seem normal, maybe because something was wrong with my encoding. i guess we can just insert chat packet whenever we want. sorry :D