mwiedemeyer / ProxySwitcher

Proxy Switcher allows you to automatically execute actions, based on the detected network connection. As the name indicates, Proxy Switcher comes with some default actions, for example setting proxy settings for Internet Explorer, Firefox and Opera.
Apache License 2.0
135 stars 60 forks source link

18 Proxies exceptions, nothing is bypassed #4

Closed xlash closed 8 years ago

xlash commented 9 years ago

Hi,

whenever I enter the 18 proxy exception for Windows 7 (64 bit), Proxy switcher does not save any entries, and does not bypass local addresses.

Regards,

mwiedemeyer commented 9 years ago

The problem can be found here. Exception length larger than 255 bytes has to be translated to two hex values. I have not implemented this years ago, because it seemed error prone and not realistic. If you really need such a long exception list, you can use a pac file instead.

If you want to fix it, feel free to submit a pull request.

xlash commented 9 years ago

How about just prompting an error to the user to avoid them thinking your great software doesn't work?

mattanja commented 9 years ago

I just hit the same issue - yes an error information to the user would be helpful. I was able to generalize the exceptions to a shorter string, but finding the issue took some time.

wobblybobz commented 9 years ago

Ok I have created what appears to be a working fix for this issue, not sure if there is an easier way to do this but anyway. am new to GitHub and not sure how pull requests work just yet. The from what I could determine you need to convert the exceptions.length to their hex values.. ie... a string length of 513 in hex is 201 the value in the registry is 01,02 so I convert the hex to byte array then reverse the byte array then pad it to 4 bytes and copy the bytes to merged

Here is the code that will fix this issue. Delete line 114 to 124 and paste in the below.

       //Convert exceptions string length to Hex Values
        string hexString = exceptions.Length.ToString("x");
        //first character should be 0 if string is not even length
        hexString = (hexString.Length % 2 == 0 ? "" : "0") + hexString;
        //Convert Hex String to Byte Array
        int NumberChars = hexString.Length;
        byte[] bytes = new byte[NumberChars / 2];
        for (int i = 0; i < NumberChars; i += 2)
        {
            bytes[i / 2] = Convert.ToByte(hexString.Substring(i, 2), 16);
        }
        //Reverse Byte Array
        Array.Reverse(bytes);
        Array.Resize(ref bytes, 4);

        bytes.CopyTo(merged, lastPosition);

Unrelated to this bug, I made another change to the code I made on line 63, to allow auto detect and proxy server settings enabled.

replace

        if (proxy.IsAutoConf && proxy.IsAutoDetect)

with

        if (proxy.IsAutoDetect && !String.IsNullOrEmpty(prx))
            enabled = (byte)11; //11=0b
        else if (proxy.IsAutoConf && proxy.IsAutoDetect)
wobblybobz commented 8 years ago

Just thought i would check in to see if any updates but noticed i forgot to mention the file i modified, Here is a copy of the patched file.

InternetExplorer8ProxyAction.zip

ImNotAProgramer commented 8 years ago

I just came accross this issue as well. For the time being I reduced the string length, but this is not really satisfying. I don't have the option to use a pac-file, as I am only a user of the system, not the admin.

@wobblybobz: Are you saying that your changes are now allowing to use more than 255 bytes for proxy exceptions? If so, how many? I currently would have to cover for 565 characters in the string.

Unfortunately I don't know how I can apply the changes you made. Obviously you meant anyone interested to compile the set of files (yours replacing the file residing in ProxySwitcher.Actions.DefaultActions) into a working program. But as I am not a programmer, I don't exactly know how to do this in order to get a working application out of it.

@all: Is there a guideline in this forum on how to do this and what is needed? Or any other resource already provided somewhere? I downloaded the files and the ones to be replaced. What's next? :)

wobblybobz commented 8 years ago

@ImNotAProgramer: Since i put this patch in i have not had a problem with any lengths of proxy exceptions. I am currently running with a proxy exceptions length that is at least double this software's original limitation, I think any limitation would be a windows / internet explorer issue now.

wobblybobz commented 8 years ago

@ImNotAProgramer: Here is a copy of the compiled DLL file just extract and overwrite the file in the "Proxy Switcher\Addins" folder this should solve your problems ProxySwitcher.Actions.DefaultActions.zip

wobblybobz commented 8 years ago

@mwiedemeyer : Maybe you can add this to the next release if you do one.

mwiedemeyer commented 8 years ago

Thank you @wobblybobz. Can you send your change as a pull request? Then I will merge it and compile a new release. The setup project is no longer supported in Visual Studio (and not really needed), so I will just create a zip file afterwards.

mwiedemeyer commented 8 years ago

Thanks @wobblybobz :+1: I've just merged it and created a new release: https://github.com/mwiedemeyer/ProxySwitcher/releases/tag/3.6.3 :shipit:

ImNotAProgramer commented 8 years ago

Thanks a lot @wobblybobz and @mwiedemeyer :)