micahmo / WgServerforWindows

Wg Server for Windows (WS4W) is a desktop application that allows running and managing a WireGuard server endpoint on Windows
MIT License
822 stars 79 forks source link

2.0.4: Can not generate client's ip address from server #70

Closed Weegley closed 1 year ago

Weegley commented 1 year ago

When pressing correspondent button following error occurs

2.0.3 version works well

micahmo commented 1 year ago

What's the value of your server address?

CC: @xeptore

Weegley commented 1 year ago

Now it's 172.16.0.1/24 First i tried 10.something which was default on fresh install. Also tried 2.0.2 and 2.0.3 - they generate like a charm from 172.16.0.1/24

micahmo commented 1 year ago

Thanks! Can you press Copy Details and paste the output here?

Weegley commented 1 year ago

It gives another error:
BUT (just found now), if i first enter ANYTHING in that field and press "generate from server" then it works.

xeptore commented 1 year ago

Hey @micahmo, I guess the issue is with these 2 lines, which when the input field is empty, the prop.Value is (strangely) null, and calling the .Split() causes a null reference error. And that's why @Weegley mentioned that having it filled with "something" resolves the issue. I suggest first having a default value for prop.Value, as I did in my PR, like var inputValue = prop.Value ?? ""; in the beginning of the validation fiunction, and use the inputValue for the rest of the function. Also, I can suggest using the StringSplitOptions.RemoveEmptyEntries option for all string.Split() calls, as I did in that link too, which eliminates the need for trimming IP addresses when they're separated by comma spaces, e.g., , without the need for chaining by a .Select(s => s.Trim()) call.

Hope that it helps.

xeptore commented 1 year ago

It gives another error:

@micahmo, also for this one I found this SO solution: https://stackoverflow.com/a/69081 (although I'm currently laughing at how/what MS is doing over there 😄).

I'm not sure whether the call to the clipboard in the application is done by you in case of unhandled exceptions, or it's the default behavior of .NET, but that might be helpful.

micahmo commented 1 year ago

@Weegley This should be fixed in 2.0.5. Can you give it a try? Thanks!

Weegley commented 1 year ago

Yes. Client ip (fill up?) working good now. But can't say about clipboard.

micahmo commented 1 year ago

Thanks for the update! No worries about the clipboard issue, that's just for troubleshooting anyway.