Skip to content

Commit

Permalink
Fix IE11 websockets.
Browse files Browse the repository at this point in the history
Closes qzind#6
Improves readability of bitwise logic block
  • Loading branch information
tresf committed Apr 20, 2016
1 parent 9ecb07b commit a77a351
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/qz/deploy/WindowsDeploy.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,39 +77,48 @@ public boolean hasDesktopShortcut() {
}

/**
* Enables websockets in IE by treating "localhost" the same as an internet zone
* This setting must be unchecked in order for websockets to communicate back to localhost via:
* - Internet Options > Security > Local Intranet > Sites > [ ] Include (intranet) sites not listed in other zones
* Note, the IE settings dialog won't reflect this change until after a browser restart
* Enables websockets in IE by checking "Automatically detect intranet network"
*
* @return true if successful
*/
public static boolean configureIntranetZone() {
String path = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\1";
String name = "Flags";
int mask = 16;
int value = 256;

// If the above mask exists, remove it using XOR, thus disabling this default setting
// If the above value does not exist, add it using bitwise OR, thus enabling this setting
int data = ShellUtilities.getRegistryDWORD(path, name);
return !(data != -1 && (data & mask) == mask) || ShellUtilities.setRegistryDWORD(path, name, data ^ mask);
if (data != -1) {
if ((data & value) != value) {
return ShellUtilities.setRegistryDWORD(path, name, data | value);
}
return true; // already set
}
return false;
}

/**
* Enables websockets in Microsoft Edge by allowing loopback connections to "localhost"
* This setting must be checked in order for websockets to communicate back to localhost via:
* - about:flags > Developer Settings > Allow localhost loopback (this might put your device at risk)
* Due to the volatility of this registry path, this registry key path may need to change over time
* Legacy Edge version: Configure loopback connections via
* - about:flags > Developer Settings > Allow localhost loopback
*
* Modern Edge versions: Utilize CheckNetIsolation.exe via desktop installer instead.
*
* @return true if successful
*/
public static boolean configureEdgeLoopback() {
String path = "HKCU\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\AppContainer\\Storage\\microsoft.microsoftedge_8wekyb3d8bbwe\\MicrosoftEdge\\ExperimentalFeatures";
String name = "AllowLocalhostLoopback";
int mask = 1;
int value = 1;

// If the above mask exists, remove it using XOR, thus disabling this default setting
// If the above value does not exist, add it using bitwise OR, thus enabling this setting
int data = ShellUtilities.getRegistryDWORD(path, name);
return !(data != -1 && (data & mask) != mask) || ShellUtilities.setRegistryDWORD(path, name, data | mask);
if (data != -1) {
if ((data & value) != value) {
return ShellUtilities.setRegistryDWORD(path, name, data | value);
}
return true; // already set
}
return false;
}

/**
Expand Down

0 comments on commit a77a351

Please sign in to comment.