Skip to content

Commit

Permalink
macOS: Detect VPN and warn user not to use VPN
Browse files Browse the repository at this point in the history
  • Loading branch information
vkedwardli committed Jan 12, 2025
1 parent 53280aa commit c846ef0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
20 changes: 20 additions & 0 deletions core/gdxsv/gdxsv_emu_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,26 @@ static void wireless_warning_popup() {
ImGui::PopStyleVar();
ImGui::EndPopup();
}

if (show_wireless_warning && no_popup_opened && connection_medium == "VPN") {
ImGui::OpenPopup("VPN connection detected");
show_wireless_warning = false;
}

if (ImGui::BeginPopupModal("VPN connection detected", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove)) {
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + 400.f * settings.display.uiScale);
ImGui::TextWrapped(" Please DO NOT use VPN! ");
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(16 * settings.display.uiScale, 3 * settings.display.uiScale));
float currentwidth = ImGui::GetContentRegionAvail().x;

ImGui::SetCursorPosX((currentwidth - 100.f * settings.display.uiScale) / 2.f + ImGui::GetStyle().WindowPadding.x);
if (ImGui::Button("OK", ImVec2(100.f * settings.display.uiScale, 0.f))) {
ImGui::CloseCurrentPopup();
}
ImGui::SetItemDefaultFocus();
ImGui::PopStyleVar();
ImGui::EndPopup();
}
}

bool gdxsv_is_using_memwatch() { return gdxsv.Enabled() && gdxsv_save_state.Enabled(); }
6 changes: 5 additions & 1 deletion shell/apple/emulator-osx/emulator-osx/osx-main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,13 @@ void os_LaunchFromURL(const std::string& url) {
return "Unknown";
}

if ([bestInterface hasPrefix:@"utun"] || [bestInterface hasPrefix:@"ppp"] || [bestInterface hasPrefix:@"tun"] || [bestInterface hasPrefix:@"vpn"]) {
return "VPN";
}

CFArrayRef ref = SCNetworkInterfaceCopyAll();
NSArray* networkInterfaces = (__bridge NSArray *)(ref);
NSString* interfaceType;
NSString* interfaceType = @"";
for(int i = 0; i < networkInterfaces.count; i++) {
SCNetworkInterfaceRef interface = (__bridge SCNetworkInterfaceRef)(networkInterfaces[i]);
NSString* bsdName = (NSString*) SCNetworkInterfaceGetBSDName(interface);
Expand Down

0 comments on commit c846ef0

Please sign in to comment.