Looking for a better way to track forwards
I have implemented a script that uses a standardized hook (UAPI::Email::add_forwarder) to track certain details relating to the addition of a forwarder to an email account.
This is working fine, but I have come across one limitation - the data passed to my methods by the hook does not include the IP address of the actor who added the forward (I am guessing that the IP is missing because hooks can fire in a context where an IP is not present?).
As I need the IP info, I am forced to scrape the access logs to find matching entries from which I can extract an IP. This solution is less robust than I would like and so I am curious if there is a better way to get the IP address as well as the forward details?
-
Hello @rorymckinley, Thank you for taking the time to provide more information. The Guide to cPanel Variables - Developer Documentation - cPanel Documentation Additionally, the document below offers some information on how to use hook action codes: Guide to Standardized Hooks - The describe() Method - Developer Documentation - cPanel Documentation Let me know if you have any questions. Thank you. 0 -
Hello @rorymckinley, It's not something I've personally tested, but you may want to look into using the $ip variable documented on the link below: my $socketfile = $ENV{'CPANEL_CONNECT_SOCKET'} || $ENV{'CPANEL_PHPCONNECT_SOCKET'};
Side note: The documentation for the variables shows example usage as follows:$cpliveapi->cpanelprint('$appname'});
Is the closing '}' a typo?0 -
Hello @rorymckinley, Upon further review, I don't believe the $ip variable is best suited for your use-case. The LiveAPI System let's you setup custom environments for applications in the cPanel interface. However, in your case, you want to fetch the Webmail user's IP address directly through the hook action code instead of the interface. I recommend opening a feature request for the inclusion of a feature that tracks Webmail user's IP addresses: 0 -
Hi @cPanelMichael - sorry for the long delay in answering this - I ended up down another rabbit hole. Just wanted to say thank you for the response - I will open a feature request. 0
Please sign in to leave a comment.
Comments
6 comments