blocking outgoing packets?

Discuss the development of Lua addons for Ashita v3 here.
Locked
beauxq
Posts: 5
Joined: Fri Apr 06, 2018 11:17 am

blocking outgoing packets?

Post by beauxq » Fri Dec 14, 2018 5:31 pm

I can't get packet blocking to work.

I'm using this to test:

Code: Select all

ashita.register_event('outgoing_packet', function(id, size, data, modified, blocked)
    if id == 26 then  -- action
        local action = struct.unpack('B', data, 0x0A + 1);
                
        if action == 3 then  -- cast spell
            print("returning true to block spell");
            return true;
        end
    end

    return false;
end);
I thought this should block all my spell casts, but it doesn't.
I see the "returning true to block spell" in the log, and it casts the spell.
User avatar
atom0s
Site Admin
Posts: 458
Joined: Sat May 14, 2016 5:13 pm

Re: blocking outgoing packets?

Post by atom0s » Sat Dec 15, 2018 9:31 pm

The action part of the packet is 2 bytes (unsigned short). You are only reading it as a single byte. Use 'H' instead of 'B'.

However the code you posted works as is for me. The action type should be fine as a byte but you should read it as its real size.
Either way, are you certain that you loaded the addon/saved it properly?

Are you also sure you are not also using something like AshitaCast? That will alter the actions and reinject them manually which may be your issue.
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
beauxq
Posts: 5
Joined: Fri Apr 06, 2018 11:17 am

Re: blocking outgoing packets?

Post by beauxq » Sun Dec 16, 2018 12:02 pm

Ok, without ashitacast, it works like I expect.

Is there no way for an addon to block these packets with Ashitacast running?
I expected it to be like a pipeline through all the plugins and addons, and it could be blocked or modified or injected at any level.
User avatar
atom0s
Site Admin
Posts: 458
Joined: Sat May 14, 2016 5:13 pm

Re: blocking outgoing packets?

Post by atom0s » Sun Dec 16, 2018 8:13 pm

AshitaCast is designed to load itself before other plugins even if its loaded late. Ashita allows prioritized loading in the plugin interface, which AshitaCast makes use of to ensure it's first to have consistent and proper usage.

Packet injection is done, in v3, immediately and without any re-checks. So for example with AshitaCast, when it blocks and reinjects a packet, you'll never see that injected packet. In v4 that will change and be introduced so that you can see the reinjected packets of other plugins/addons and attempt to block them as needed. I don't plan on pulling this change into v3 though, so most I can say is you'll have to wait for v4 to get that exact functionality.

You can make a plugin that loads before AshitaCast and do what you need though in that.
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
Locked