Log in

View Full Version : An easy way of switching proxy/VPN settings before connecting to any kind of network


Menneisyys
05-09-2005, 10:18 AM
An easy way of switching proxy/VPN settings before connecting to any kind of network

At http://www.firstloox.org//forums/showthread.php?t=3815 , a question has been asked about an easy way of switching proxy/VPN settings before connecting to a different Wi-Fi network. As this question is very important - you may often want to switch, for example, proxy servers while you're browsing and you don't want to re-enter the entire proxy address each time you do this -, I've decided to spend some time on explaining this and diving into the Registry to find out how it internally stores connectivity-related information.

It's, fortunately, pretty easy to dynamically change the proxy/VPN info before switching networks with the built-in Connection Manager in any Pocket PC PDA from PPC2k2 on. PPC2k2 was revolutionary in that it introduced the 'Work'/'The Internet' distinction and, also, the ability to define more than one so-called 'connection groups', each having separate VPN and proxy server information (which are common to all connections defined in these connection groups). This means that, in Wi-Fi, where you don't need to specify any connection inside connection groups, you can just switch connection groups to make the changes visible. (With modem-based connections like GPRS, on the other hand, you need to re-create each connection in all the connection groups you define. This definitely leads to some additional work and data duplication, but can't be circumvented.)

You only need to create two or more connection groups in Connection Manager with the proxy/VPN data pairs necessary. Then, before connecting to a given Wi-Fi network, just click the Connectivity icon on the taskbar, click the Settings links, click the Advanced tab and the Select Networks button. Then, just choose the connection group in the drop-down list at the bottom (in the Programs that automatically connect to a private network should connect using section) that has the right proxy and VPN info for your particular Wi-Fi connection and connect.

How can you create the right connection group? It's pretty easy. Just click the New... button in the above-mentioned Programs that automatically connect to a private network should connect using section:

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/CreateANewWorkGroup-1.gif

Just enter a new name for this group; say, 'serverConfig1', in the 'Enter a name for these settings:' input field.

Then, if the particular server requires VPN (if it doesn't, ignore this step) click the VPN tab and, there, click New. Fill in the necessary VPN info, by pressing the Next each time between the pages; finally, press Finish.

To set up the proxy server, click the Proxy Settings tab. Check in both checkboxes. If the proxy server is listening at port 80, then, just enter its address in the Proxy server: input field here:

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/BTSettingsProxyAddPort80.gif

Otherwise (the proxy server is listening on some other port), press Advanced and fill in the HTTP Server and Port addresses:

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/BTSettingsProxyAddNon80.gif

When you're finished, just click OK.

Do the same for all different configuration pairs - always create a new connection group for all of them in the 'Work' (Programs that automatically connect to a private network should connect using) section. Make sure you name them properly so that their name reflects to what they configure.

That's all you need to know about easy switching the proxy/VPN information.

Please note that, if you (or anyone you know) happen to speak Hungarian, you may want to read my 170 kchar-long article on all this stuff at http://menneisyys.freeweb.hu/gprs/ . It contains everything about connectivity issues you need to know. Unfortunately, online English resources discussing how the Connectivity works are pretty rare; see for example http://www.pocketpcthoughts.com/forums/viewtopic.php?t=39784 on this.

Advanced stuff - how the Connectivity-related registry does work?

If you want to know what's happening behind the scenes and want to know how the Connectivity-related registry entries link each other, where they are located etc, read on.

1, If you use, for example, The Internet connection group (the default with Wi-Fi connections), go to Connectivity/Settings/Advanced/Select Networks and see what's listed in the upper drop-down menu. Any other group than My ISP can have a proxy server. Let's say it lists Bluetooth Settings - it's a connection group created by Bluetooth Manager when you set up a mobile phone-based connection. Anything else can be here - if the above-mentioned, restricted My ISP is here, just change it to, say, My Work Network to be able to set the proxy.

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/TheInternetAndWorkDefaultGroups.gif

2, now, if you haven't already done so, set up a proxy for the connection group you use. It has already been explained in the first section.

3, now, you'll need to find out the DestID value of Bluetooth Settings. Again, it's the group name I'm using for this example. It may be anything; the point is that it must be the chosen connection group in the above (that is, "The Internet") drop-down list on the Connectivity/Settings/Advanced/Select Networks screen. Go to with Resco Registry Editor (the only PPC regeditor that is able to export a given regkey and not just the entire registry structure; unfortunately, its best, free alternatives, PHM Registry Editor and Tascal Registry Editor, can't do the same) [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ConnMgr\Destinations\Bluetooth Settings] and write down (for example, copy it to the clipboard) the value of DestID:

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/ReadingDestID.gif

To be able to use exact figures in this tutorial, let's say it's {8831E4CC-C397-4337-B08D-0C66A6347D2F}.

4, now, go to [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ConnMgr\Providers].

There, there will be four groups:

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/FourGroupsInProviders.gif

You need to iterate over them until you find the group that also has subkeys that have HTTP in their names. It's the third group named {EF097F4C-DC4B-4c98-8FF6-AEF805DC0E8E} in the following picture:

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/FourGroupsInProviders-2.gif

(note that 'default' is an access point name I've used on the test machine. I didn't use other Access Points (AP); this is why there're no more AP names listed in the same group.)

5, now, go to [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ConnMgr\Providers\{EF097F4C-DC4B-4c98-8FF6-AEF805DC0E8E}\HTTP-{8831E4CC-C397-4337-B08D-0C66A6347D2F}]. Here, I've used bold to denote the DestID found in step 3 and underline to denote the proxy setting group under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ConnMgr\Providers found in step 4:

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/ExportTheProxyRelatedToTheGroup.gif

Export it.

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/ExportTheProxyRelatedToTheGroup-2.gif

6, transfer it to the desktop via, say, Total Commander and the WinCE FS plug-in (see http://pocketpcmag.com/forum/topic.asp?TOPIC_ID=15577 on setting it up and using) and edit it there by making differently-named copies of it and only editing the

"Proxy"="some proxy addy listening at port 80:8081"

row in it.

I recommend that you name the files according to the proxy server/port they use so that you always know what you load.

7, copy they back to the PDA, into any directory.

8, then, just click the given registry file before connecting to a network that uses the proxy in question. Fortunately, you don't need to reset your device to make the proxy change visible.

Menneisyys
05-09-2005, 01:39 PM
I'd also add that if you go on with the direct registry hacking method, you save a lot of effort:

- if you use this trick with modem-based connections (and not Wi-Fi, which is quite independent from the Connectivity mechanism defined here), the need for setting up the same connection in different connection groups. Then, as you only have one group to change its proxy server, you don't need to re-setup the same connection in several connection groups, which, if you have several proxy servers you want to frequently switch between, can be pretty tiring. Furthermore, keeping all those connections on sync is pretty complicated and error-prone if anything changes (for example, the dial-in [pseudo-]number).

- the need for clicking into Connectivtiy is eliminated, particularly if you put your registry files on your Today screen, changing proxy servers becomes really-really easy - you just click them on the Today screen and voilá - the new registry entry is imported.

How this can be done? It's pretty simple. As I consider Spb Pocket Plus (SPP) the best all-in-one today and generic system plug-in (you may want to read my SPP benchmarks at http://www.pocketpcthoughts.com/forums/viewtopic.php?t=36376 and my tutorial about relocating it to File Store at http://www.firstloox.org//forums/showthread.php?t=3752 ), I use it to show how it can be done.

1. click-and-tap the Today screen in the screen area of the plug-in where there're no icons, and choose Add/Remove Items...

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/REGFilesOntoTodayScreen-1.gif

2. on the next scren, choose Add/File, and go to the previously-uploaded registry file. Select it and press OK:

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/REGFilesOntoTodayScreen-2.gif

It'll be put in the Custom category:

http://menneisyys.freeweb.hu/EasyProxyAndVPNSwitching/REGFilesOntoTodayScreen-3.gif

Repeat the above steps (Add/File etc) for all the registry import files you want to put on your Today screen.

After this, simply clicking a registry file will automatically import its contents into the Registry (again, assuming Resco Registry Editor is installed).