OrchidTechnologies / orchid

Orchid: VPN, Personal Firewall
https://www.orchid.com/
GNU Affero General Public License v3.0
649 stars 103 forks source link

on Windows, non-ASCII adapter names broke client daemon #117

Closed Thoerix closed 2 years ago

Thoerix commented 2 years ago

Describe the bug Note: I was following this blog post After launching the app using orchidcd-win_0.9.36.exe --config orchid.cfg I've got an error:

Failed to configure the DHCP service. The interface may be disconnected. [./vpn/p2p/source/execute.hpp:38] system(netsh interface ip set address "Po" static 10.7.0.3 255.255.255.0) != 0 [@:1645120000642608] [T:3] [vpn/source/capture.cpp:819] orc_trace(): Shut terminate called without an active exception

I found a solution by disabling a network card starting with "Po" in the control panel. After that I get this:

[@:1645119716069903] [T:1] Error opening registry key: SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002BE10318}\Configuration\ComponentId [@:1645119716069903] [T:1] Error opening registry key: SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002BE10318}\Properties [@:1645119716069903] [T:1] [vpn/p2p/source/valve.cpp:86] stuck N3orc4SyncIN5boost4asio7windows19basic_stream_handleINS2_15any_io_executorEEENS_8SyncFileEEE terminate called without an active exception

Can't really tell what is causing this, but when I launched the app on a new Windows 10 VM the same error appeared again. There may be a problem that registry key (...)\Configuration\ComponentId just straight up doesn't exist and (...)\Properties cannot be accessed in any normal way.

Device information:

saurik commented 2 years ago

@Thoerix I am currently in an awkward place to help with this (as I am staying at a hotel and giving a talk at an event tomorrow morning), but I will get back to you in ~a couple~four days with some way to debug this.

Thoerix commented 2 years ago

Update: I successfully managed to make some progress, somehow "Po" from Failed to configure the DHCP service. The interface may be disconnected. [./vpn/p2p/source/execute.hpp:38] system(netsh interface ip set address "Po" static 10.7.0.3 255.255.255.0) != 0 is TAP network driver. On my host it still crashes after turning it on, but on a VM it works now. Later I'm going to test it on Windows 11 VM to see if it's just my system being weird.

saurik commented 2 years ago

@Thoerix So, I appreciate that it sucks that it took me so long to get you anything, but I ended up getting sick :/.

After spending some time realizing that getting the "stuck" error to be more useful was going to be extremely annoying, I have added support for a --verbose flag to the client which should output errors as they happen (as well as a bunch of other information that is probably not very useful). This feature is not in a "release" yet, but you can download it from GitHub Actions (which means you don't have to trust me if you trust our code and trust GitHub: this is actually safer than downloading a "release" from GitHub, as I upload those myself--and could thereby slip in extra behaviors--and GitHub could swap them out anyway) from https://github.com/OrchidTechnologies/orchid/actions/runs/1957066170 (look for the "orchidcd-win" artifact).

Thoerix commented 2 years ago

Hello @saurik, good to hear from you back. I have some good news. I found a way to fix it, and it's pretty simple. I've launched it with the --verbose flag, and in short - I didn't get anything useful, because the problem is present at the very beginning of the launching process. I have Windows 11 installed with Polish language as my default and the TAP driver, while installing successfully, would get a "Połączenie lokalne" label in Window's network driver manager ( or whatever it is called ), which translates to "Local connection". Because Orchid doesn't know what to do with different letters from other languages, it tries to read the "Połączenie lokalne" label and just stops before "ł", creating a "Po" string variable instead of "Połączenie lokalne". Then it tries to find "Po" network driver, but fails to do so and crashes. After renaming the label to "TAP_driver", the app boots up fine. I think that there are two solutions, the first one is just adding support for labels in foreign languages. The second one is on the screenshot.

image

Update: I tested it and everything works as expected. However, I have one question: is there a kill switch that I can enable via the app?

Thoerix commented 2 years ago

Hello again, I think I've found a bug. Basically the Orchid version with --verbose flag uses quite a bit of ram after a few hours... it hit 6gb after about 4 hours ( and I didn't launch it with --verbose flag, only --config ).

saurik commented 2 years ago

@Thoerix Can you add logdb = ""; to your config file and tell me if that helps? (I will look into this either way when I next am actually awake.) The default on that setting (which is used by the Traffic Analyzer feature in the front-end) is apparently still weird, and I don't really trust recent changes to that feature.

Thoerix commented 2 years ago

Hello! Adding logdb = ""; to my config file pretty much solved the problem. I can tell that was the case, because Orchid stopped adding about 15-25mb of memory to itself every 10 seconds.

saurik commented 2 years ago

(This issue is actually still open as the unicode adapter problem has yet to be fixed.)

saurik commented 2 years ago

I have locally replicated this issue and have fixed it with https://github.com/OrchidTechnologies/orchid/commit/325e1f361282ee34dcc68eb1f4c4921fa17d2f40 and https://github.com/OrchidTechnologies/orchid/commit/88bb3e55c804b9f11729293b9ee44c5321e2e9fb. (And, while it was a separate / off-topic discussion, I will also note that I isolated the memory leak and Greg is tracking it upstream in Wireshark at https://gitlab.com/wireshark/wireshark/-/issues/17998.) Thanks for the bug report!!