It is currently March 28th, 2024, 9:35 pm

VPN Process Detection (NordVPN)

Get help with creating, editing & fixing problems with skins
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

VPN Process Detection (NordVPN)

Post by Mor3bane »

Hello, I have chosen to commit to NordVPN as my goto for IP virtualisation.

I have an IP meter that shows if Nord is running. What I'd like to try and do is have the meter understand if the VPN is connected, not simply running in the background.

Anyone try this and succeed? I'd love to hear recommendations.

My Code:

Code: Select all

[Rainmeter]
Update=90
Group=small

[Metadata]
Author=Morbane

[Variables]
@include=#@#RoundVariables.inc
Color=#GlobalFontColor#
ColorZ=#ColorOffset#
Font=#GlobalFont#

[MeasureWANIP]
Measure=Plugin
Plugin=WebParser.dll
Url=http://checkip.dyndns.org/%22
RegExp="(?siU)<body>(.+)Address: (.+)</body>"
StringIndex=2
OnChangeAction=[!SetOption MeterWANIP FontColor 186,40,40][!UpdateMeasure][!Redraw]
UpdateDivider=5

[ImageNumberCalc]
Measure=Calc
Formula=Counter%10
DynamicVariables=1

[MeterRipples]
Meter=Image
ImageName="#@#Ripple\tmp-[ImageNumberCalc].gif"
ImageTint=#Color#
AntiAlias=1
Y=0
X=0
W=200
H=200
DynamicVariables=1
Hidden=1

[MeterFrame]
Meter=Image
ImageName=#@#Frame.png
X=35
Y=35
MouseOverAction=[!ShowMeter "MeterRipples"][!Redraw]
;[Play #@#waat.wav]
MouseLeaveAction=[!HideMeter "MeterRipples"][!Redraw]

[iptext]
Meter=STRING
X=99
Y=57
FontColor=#Color#
FontSize=17
StringAlign=Center
FontFace=#Font#
AntiAlias=1
Text="IP:"
DynamicVariables=1

[MeterWANIP]
Meter=String
MeasureName=MeasureWANIP
X=99
Y=85
StringAlign=Center
FontColor=#ColorZ#
FontSize=13
FontFace=#Font#
AntiAlias=1
MouseOverAction=[!SetOption MeterWANIP FontColor #ColorZ#][!Redraw]
LeftMouseDownAction=["C:\Program Files (x86)\NordVPN\NordVPN.exe"]
Text=%1
DynamicVariables=1

;CHANGE THE BELOW METER TO IDENTIFY IF YOUR VPN IS ACTIVE -
;COPY/PASTE THE .exe AND TYPE YOUR MESSAGE BELOW ACCORDINGLY.
;E.g. REPLACE THE "NORD VPN" MESSAGE WITH ONE RELEVANT TO YOUR VPN.

[MeasureProcessLow]
Measure=Plugin
Plugin=Process
ProcessName=NordVPN.exe
Substitute="-1":"STANDARD","1":"NORD VPN"

[MeterIfVPN]
Meter=String
MeasureName=MeasureProcessLow
X=99
Y=109
Text=%1
StringAlign=Center
FontColor=#Color#
FontSize=13
FontFace=#Font#
AntiAlias=1
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: VPN Process Detection (NordVPN)

Post by SilverAzide »

Does your VPN software create a virtual network adapter? If so, you could create a measure that looks for your virtual adapter. I do this all the time, but I'm using Juniper's VPN software, so I'm not sure if it applies to NordVPN.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: VPN Process Detection (NordVPN)

Post by jsmorley »

Something like this:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[MeasureAdapter]
Measure=Plugin
Plugin=SysInfo
SysInfoType=ADAPTER_DESCRIPTION
SysInfoData=Best
DynamicVariables=1

[MeterAdapter]
Meter=String
MeasureName=MeasureAdapter
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
While VPN's use different approaches to taking over things, I would think for most, when you are actually "connected" to the VPN, the "Best" adapter, which will indicate the "active" one, will be the name of the virtual adapter the VPN creates.

So as long as you know what that value is for "Best" when the VPN is not connected, and what it is when it is connected, you should be able to detect and act on it.

Remember that SysInfo requires DyanmicVariables=1 on it to detect changes to "Best" in real-time.

Looks to me like NordVPN creates a virtual TAP adapter, just like my IPVanish does...
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: VPN Process Detection (NordVPN)

Post by Mor3bane »

Hello, I am not sure what I am looking for, in terms of what "best" is on my system. I know you cannot tell me specifically, but perhaps some kind of indicator? Should I be looking for a txt file or similar, an xml? There are some .config files but nothing that looks like an adapter name.

EDIT: Never mind - I see now the code you provided will tell me that :lol:

EDIT 2: Got it working! :17good
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
renoir_zebe
Posts: 1
Joined: February 24th, 2023, 11:42 pm

Re: VPN Process Detection (NordVPN)

Post by renoir_zebe »

This is my first post, so be professional.

Code: Select all

;  VARIABLES for Active Adapters
;-------------------------------------
;
Active_VPN_Adapter=NordLynx


;-------------
;Measures
;-------------

[VPN ADAPTER GW Address]
Measure=Plugin
Plugin=SysInfo
SysInfoData=#Active_VPN_Adapter#
SysInfoType=GATEWAY_ADDRESS
IfMatch="0.0.0.0"
IfMatchAction=[!SetOption meter_VPN_Status Text "*** ACTIVE ***"] [!SetOption meter_VPN_Status FontColor 0,255,0,255] [!Redraw]
IfNotMatchAction=[!SetOption meter_VPN_Status Text "*** NOT CONNECTED ***"] [!SetOption meter_VPN_Status FontColor 255,64,0,255] [!Redraw]
UpdateRate=5

;---------------
;Meters

[meter_VPN_StatusLabel]
Meter=String
MeterStyle=styleLeftText
X=20
Y=30r
W=120
H=20
Text=Status

[meter_VPN_Status]
Meter=String
MeterStyle=styleRightText
MeasureName=VPN ADAPTER GW Address
X=245
Y=0r
H=20
Text= %1
DynamicVariables=1
Last edited by Brian on February 25th, 2023, 12:55 am, edited 1 time in total.
Reason: Please use [code] tags. It's the </> button. Thanks.