What's new

Getting VPN connected users from sh script

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Addicted2keyboards

New Around Here
Hi,

My router in an Asus RT-AX88U and is running the latest firmware (386.8_0). I have it sending event notifications by Telegram bots and now I need to send a notification when an authorized user connects to my VPN.

That information is available in the Web UI (VPN > VPN Status or VPN Server):

1661039918165.png


1661039523253.png


I want to obtain the same information for an automated sh script, running from cron, but my trials didn't work. What I tried:
  • with nvram get/dump command: can't find any information regarding VPN connected users.
  • wiht curl: no matter what recipe I use, I can't pass through the login page.
  • even tried with lynx, but also can't pass through the login page.
Inspecting how the Web UI gets that information, the Advanced_VPN_OpenVPN.asp page loads the file ajax_openvpn_client_status.xml which has:
Code:
<?xml version="1.0" ?>
<vpnserver>
<% nvram_dump("openvpn_connected",""); %>
</vpnserver>
I tested inserting ajax_openvpn_client_status.xml in the browser's address bar, just right after the login page, and it gives me the xml with the exact needed information (the function executes and inserts the data between the %).

Looking for nvram_dump() in the git sources it appears to be defined in the httpd server. So it appears to be only possible to call nvram_dump() from an http session.

Am I missing something or does anyone knows how to get the VPN connected users?
 
AFAIK, that information should be directly accessible from the same file that keeps the GUI updated, and which is updated by the OpenVPN server itself.

Code:
cat /tmp/etc/openvpn/server1/status
 
Yes, I had already caught that path in the sources but unfortunately my directory /tmp/etc/openvpn/ is always empty and nothing seems to be written there...
 
Yes, I had already caught that path in the sources but unfortunately my directory /tmp/etc/openvpn/ is always empty and nothing seems to be written there...
Double check the path. The information is definitely written there when a server is running, as well as all the configuration files that are generated when running an instance.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top