It is currently April 25th, 2024, 2:33 am

Private Internet Access (VPN) broke recently

Get help with creating, editing & fixing problems with skins
Darv
Posts: 13
Joined: September 27th, 2015, 1:48 am

Private Internet Access (VPN) broke recently

Post by Darv »

Hoping someone that knows Rainmeter coding can figure this out.

Private Internet Access aka PIA recently released version 1.8 of their VPN. The update broke the Rainmeter skin which I use to make sure my connection is secure. Really missing it. The skin itself seems pretty straight forward but I can't determine what changed in 1.8. Reverting to version 1.7 resolves the issue. The problem is that it doesn't seem to recognize when the VPN is connected. Any help or suggestions would be appreciated but I wouldn't even call myself a novice. Just a rainmeter user with some programming background.

-------------------------------------------------------------------------------------------------------------------------------------

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,0,0,0

[MeasureNetwork]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData=1
RegExpSubstitute=1
Substitute="^(.*)\.(.*)\.(.*)\.(.*)$":"\1"

[OnlineStatus]
Measure=Calc
Formula=[MeasureNetwork]
IfBelowValue = 11
IfBelowAction=[!SetOption MeterNetwork FontColor 0,255,0,200][!SetOption PiaIcon ImageName pia_on.png][!UpdateMeter PiaIcon][!Redraw]
IfAboveValue = 11
IfAboveAction=[!SetOption MeterNetwork FontColor 255,0,0,255][!SetOption PiaIcon ImageName pia_off.png][!UpdateMeter PiaIcon][!Redraw]
DynamicVariables=1

[PiaIcon]
Meter=Image
ImageName=pia_gray.png
W=30
H=30
X=8
Y=7

[MeterNetwork]
Meter=String
MeasureName=OnlineStatus
FontSize=30
FontColor=167,167,167,255
StringStyle=Bold
AntiAlias=1
Text=VPN
X=30
y=0
Last edited by Brian on March 17th, 2020, 6:57 am, edited 1 time in total.
Reason: Please use the code tags. It's the </> button.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Private Internet Access (VPN) broke recently

Post by mak_kawa »

I don't know abput PIA at all, so can't do specific help abput it and the skin. But...how about the value of [MeasureNetwork] *before* the RegExpSubstitution?
User avatar
Yincognito
Rainmeter Sage
Posts: 7157
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Private Internet Access (VPN) broke recently

Post by Yincognito »

Darv wrote: March 17th, 2020, 6:53 am Hoping someone that knows Rainmeter coding can figure this out.

Private Internet Access aka PIA recently released version 1.8 of their VPN. The update broke the Rainmeter skin which I use to make sure my connection is secure. Really missing it. The skin itself seems pretty straight forward but I can't determine what changed in 1.8. Reverting to version 1.7 resolves the issue. The problem is that it doesn't seem to recognize when the VPN is connected. Any help or suggestions would be appreciated but I wouldn't even call myself a novice. Just a rainmeter user with some programming background.
The coding appears to be fine, although I didn't tested it yet - and the fact that it works for previous PIA versions seems to indicate that as well. However, the process is the key here: you basically test to see if the number before the first dot in the address (i.e. its most significant bits) of the IP address of the NIC (aka network interface controller) whose index number is 1 is less or greater than 11. So, one (or more) of the following possibilities might have "broken" this process:

- the NIC whose IP address you want to be tested has a different index in SysInfoData (low probability, but still a possibility)
- the number before the first dot in the address being less or greater than 11 doesn't reflect the security of the connection anymore, in the new PIA version
- the new version uses a different method to secure your connection, a method that doesn't translate in the IP address change you used to test in the previous versions

Now, if this process works for the previous version of PIA in the same test environment, I think one of the latter two possibilities are more likely, so, assuming the skin itself works, that's where I would start my investigation at.

P.S. Personally, I wouldn't count to much on the index of the NIC in SysInfoData. To me, the name of the NIC (or the 'Best' value, if that's the case) seem safer and more credible when approaching this...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Private Internet Access (VPN) broke recently

Post by jsmorley »

I'm sure it varies by VPN, but the way that I test to see if my VPN in providing the connection is like this:

Code: Select all

[MeasureAdapterDesc]
Measure=Plugin
Plugin=SysInfo
SysInfoType=ADAPTER_DESCRIPTION
SysInfoData=Best
UpdateDivider=5
DynamicVariables=1
IfMatch=IPVanish
IfMatchAction=[!SetVariable Interface "[MeasureAdapterDesc]"][!SetOption MeterWANLabel Text "VPN"][!SetOption MeterLANLabel Text "TAP"]
IfNotMatchAction=[!SetVariable Interface "[MeasureAdapterDesc]"][!SetOption MeterWANLabel Text "WAN"][!SetOption MeterLANLabel Text "LAN"]
So I just use an Interface option of "Best", then check the name of the adapter it returns to see if it is my VPN. This will either be the name of my physical NIC, or if the VPN is active, the name of the virtual TUN/TAP adapter the software sets up.

From then on, I just use the name returned in [MeasureAdapterDesc] as the Interface option in all my network measures.

I certainly can't be sure this will work for any and all VPN's out there, although I would think most of them use some sort of TUN/TAP virtual adapter to create a Virtual Private Network.

Note the DynamicVariables=1 on this. SysInfo will not see a real-time change to the information it returns unless the measure is made dynamic.


1.jpg

2.jpg
You do not have the required permissions to view the files attached to this post.
kenbo01
Posts: 3
Joined: July 15th, 2020, 11:33 pm

Re: Private Internet Access (VPN) broke recently

Post by kenbo01 »

Something like this?

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
BackgroundMode=3
SolidColor=0,0,0,90

[Metadata]
; Contains basic information of the skin.
Name=VPN Status

[MeasureNetwork]
Measure=Plugin
Plugin=SysInfo
SysInfoData=Best
SysInfoType=ADAPTER_DESCRIPTION
Substitute="Private Internet Access Network Adapter":"1","WireGuard Tunnel":"1"

[OnlineStatus]
Measure=Calc
Formula=[MeasureNetwork]
IfCondition=OnlineStatus = 1
IfTrueAction=[!SetOption MeterNetwork FontColor 0,255,0,155][!SetOption PiaIcon ImageName pia_on.png][!UpdateMeter PiaIcon][!Redraw]
IfCondition2=OnlineStatus <> 1
IfTrueAction2=[!SetOption MeterNetwork FontColor 255,0,0,255][!SetOption PiaIcon ImageName pia_off.png][!UpdateMeter PiaIcon][!Redraw]
DynamicVariables=1

[PiaIcon]
Meter=Image
ImageName=pia_gray.png
W=30
H=30
X=8
Y=7

[MeterNetwork]
Meter=String
MeasureName=OnlineStatus
FontSize=30
FontColor=167,167,167,255
StringStyle=Bold
AntiAlias=1
Text=VPN
X=30
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Private Internet Access (VPN) broke recently

Post by balala »

kenbo01 wrote: July 15th, 2020, 11:35 pm Something like this?
The code as you've written it, has a small problem: the [MeasureNetwork] measure with the SysInfoType=ADAPTER_DESCRIPTION option, returns a string value (https://docs.rainmeter.net/manual/plugins/sysinfo/#Network), which can't be used onto a Calc measure ([OnlineStatus] with the Formula=[MeasureNetwork] option).
And a comment (this is definitely not a mistake and doesn't even prevents the options to work, but): the IfConditon2 option of the [OnlineStatus] measure is not needed. Instead of using it, recommend to remove it and replace the IfTrueAction2 option with IfFlaseAction. But again: this is just a "design" question, not a functional one.
kenbo01
Posts: 3
Joined: July 15th, 2020, 11:33 pm

Re: Private Internet Access (VPN) broke recently

Post by kenbo01 »

Thanks for the feedback. I only installed Rainmeter today so this is very much my first attempt and I wasn't entirely sure what I was doing.

That being said, I can confirm that the code does actually work and produce the desired outcome on my computer. That is, if I disconnect VPN it changes to red text and icon, and if I reconnect it changes to the green text and icon. So I can only assume that under the hood it can cope with a "1" when expecting a 1.

I'll have a closer look tomorrow and also explore your other feedback.

Thanks again
User avatar
Yincognito
Rainmeter Sage
Posts: 7157
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Private Internet Access (VPN) broke recently

Post by Yincognito »

balala wrote: July 16th, 2020, 7:51 amThe code as you've written it, has a small problem: the [MeasureNetwork] measure with the SysInfoType=ADAPTER_DESCRIPTION option, returns a string value (https://docs.rainmeter.net/manual/plugins/sysinfo/#Network), which can't be used onto a Calc measure ([OnlineStatus] with the Formula=[MeasureNetwork] option).
While this is entirely correct in terms of how Rainmeter code works in general, it doesn't produce adverse effects in this case, since kenbo01's code is replacing the "valid VPN strings" with the numerical value of 1 in the Substitute, and for the other cases, since the string isn't a number, the Calc measure will reduce it to the default 0. In other words, the Calc measure will yield the correct result, mainly because the measure will turn a non-numerical string into a value different than 1 (i.e. the default 0).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Private Internet Access (VPN) broke recently

Post by balala »

Yincognito wrote: July 16th, 2020, 11:54 am While this is entirely correct in terms of how Rainmeter code works in general, it doesn't produce adverse effects in this case, since kenbo01's code is replacing the "valid VPN strings" with the numerical value of 1 in the Substitute, and for the other cases, since the string isn't a number, the Calc measure will reduce it to the default 0. In other words, the Calc measure will yield the correct result, mainly because the measure will turn a non-numerical string into a value different than 1 (i.e. the default 0).
Right, now I see. I just couldn't get it to work this way because for me a completely different string is returned by the [MeasureNetwork] measure, so I get 0 in all circumstances and finally I missed to modify the substitution.
But even so, I think instead of adding a Calc measure, an IfMatch could be used directly on the [MeasureNetwork] measure, which would avoid the need of using the [OnlineStatus] measure. And the less measures, the better...
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Private Internet Access (VPN) broke recently

Post by jsmorley »

Yes, I'm not quite sure why you wouldn't just go with:

Code: Select all

[MeasureNetwork]
Measure=Plugin
Plugin=SysInfo
SysInfoData=Best
SysInfoType=ADAPTER_DESCRIPTION
DynamicVariables=1
IfMatch=Private Internet Access Network Adapter||WireGuard Tunnel
IfMatchAction=[!SetOption MeterNetwork FontColor 0,255,0,155][!SetOption PiaIcon ImageName pia_on.png][!UpdateMeter *][!Redraw]
IfNotMatchAction=[!SetOption MeterNetwork FontColor 255,0,0,255][!SetOption PiaIcon ImageName pia_off.png][!UpdateMeter *][!Redraw]

Note that DynamicVariables=1 is required on a SysInfo measure where you want a dynamic change to the ADAPTER_DESCRIPTION or other "network" values to be recognized. This is peculiar to these values, and was originally designed this way since like many other values you measure with SysInfo, it was not expected that the name of your active network adapter could change while the skin is running. WiFi and VPN and all that has changed this assumption somewhat over the years, but the original behavior remains.