-
Couldn't load subscription status.
- Fork 91
Add Proxy support for hub/auth/build downloads #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add Proxy support for hub/auth/build downloads #215
Conversation
Very rough code. I never really use C# to be honest, and my networking experience is lacking, but it does work, and fairly well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTICE: I am not a maintainer for the Launcher repo, these are suggestions
- The proxy will preferably be passed down to the client via environment variables, since the game client also has to go through the auth server at least once, which (usually) is subject to being blocked. (SOCKS5 can also pass UDP traffic, which to some can be useful)
This however may be out of scope for this pr, I would let this be decided by @PJB3005
I would at least have it passed down now for someone else to code later on to the engine.
-
I would say do it here next to the log launcher button
<CheckBox DockPanel.Dock="Left" VerticalAlignment="Center" Margin="4" IsChecked="{Binding LogLauncher}" Content="{loc:Loc login-log-launcher}" /> -
With the way this is currently coded, not sure how i would solve this... although you would at least need to check if we are connecting to an internal ip address (Upstream has a system you can probably borrow https://github.com/space-wizards/space-station-14/blob/45e5fbfcdf824de5b0416895b475a7c6ad386f0f/Content.Server/Connection/IPIntel/IPIntel.cs#L287-L377) and ignore running that through the proxy.
| <CheckBox VerticalAlignment="Center" Margin="4" IsChecked="{Binding ProxyEnable}">Enable proxy</CheckBox> | ||
| <TextBox Grid.Column="1" Watermark="http://example.com:80" Text="{Binding ProxyURL}" /> | ||
| </Grid> | ||
| <TextBlock VerticalAlignment="Center" TextWrapping="Wrap" | ||
| Text="Proxy information for connect to hub and auth center. (requires launcher restart)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to use localization strings instead so that people can translate everything.
Look at the other options above, and add it into the English text.ftl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. Thanks for your help! <3
The magic of reading documentation
| <TextBox Grid.Column="1" Watermark="http://example.com:80" Text="{Binding ProxyURL}" /> | ||
| </Grid> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make the watermark something like
http://optional-username:optional-password@example.com:80
Perhaps also localized IF possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, and will do, but it's worth keeping in mind socks5 proxies require a different syntax
socks5://127.0.0.1:1337
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, I dont want it to be too big though. You may point it out somewhere else perhaps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Does avalonia support tooltips (ie text that pops up on hover)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does, you will need to search that up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got the tooltip working
Co-authored-by: Myra <vascreeper@yahoo.com>
Co-authored-by: Myra <vascreeper@yahoo.com>
|
Note: Just tested the local URL changes. Connecting to the server and getting to the handshake stage works fine, but errors out with |
That sounds unrelated. Look at the stack trace on the client for a fuller picture. |
If you don't mind me asking, how so? It means local servers may still not work under proxy. |
|
Without the full error from the client. I can only make assumptions. The github comments are not the best place to have chatter about troubleshooting this, so it's probably best to talk on discord. |
Got it. This is generally not a huge issue either way, as it can be worked around w/port forwarding, but I'll do some testing whenever I can. |
|
IMO this is an issue that should be solved. Not all players will port forward to play on a server running on their OWN computer. Let alone have the expertise. |
|
I'm no network engineer so this is mostly beyond me but if this tells you something lmk My best guess? The robust engine network requests are maybe not getting proxied? Or perhaps the server needs to be proxied? I have no idea to be honest. Sorry if this isn't helpful, I'll be able to test this better later. LOCAL CONNECTION ERROR MESSAGE |
SS14.Launcher/HappyEyeballsHttp.cs
Outdated
| }; | ||
| if (!String.IsNullOrEmpty(proxyUrl)){ //Note: I'm VERY new to writing c#. This is heavily copied from koksnull's work in https://github.com/space-wizards/SS14.Launcher/pull/144 . I've just made some adjustments to make it work for the modern versions of .net | ||
| //I'm unsure of how to go about this, but having some way to sanity check the proxy before activating it (i.e. a test ping) would be great. | ||
| Uri proxyURI = new Uri(proxyUrl.Trim('"')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the value isn't a valid URI, this will cause the launcher to crash on startup. You're gonna need a way to handle that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever the reason for this proxyUrl.Trim('"') thing is, it needs to be figured out and removed for sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the value isn't a valid URI, this will cause the launcher to crash on startup. You're gonna need a way to handle that.
Fixed this in 8b1067f
SS14.Launcher/HappyEyeballsHttp.cs
Outdated
| WebProxy clientProxy = new WebProxy(proxyUrl.Trim('"')); //No clue why .trim('"') is required. C# jank? Doesn't work otherwise. | ||
| clientProxy.BypassProxyOnLocal = true; | ||
| if (!string.IsNullOrWhiteSpace(proxyURI.UserInfo)){ | ||
| string[] credentials = proxyURI.UserInfo.Split(new[] { ':' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splitting like this means that if the password has a : character in it, it won't get accepted correctly. Probably better to use IndexOf and only split on the first occurrence.
| <Grid ColumnDefinitions="Auto,*"> | ||
| <CheckBox VerticalAlignment="Center" Margin="4" IsChecked="{Binding ProxyEnable}" Content="{loc:Loc tab-options-desc-proxy-enable}" /> | ||
| <TextBox Grid.Column="1" Watermark="http://optional-username:optional-password@example.com:80" Text="{Binding ProxyURL}" ToolTip.Tip="{loc:Loc tab-options-desc-proxy-tooltip}"/> | ||
| </Grid> | ||
| <TextBlock VerticalAlignment="Center" TextWrapping="Wrap" | ||
| Text="{loc:Loc tab-options-desc-proxy-address}" | ||
| Margin="8" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have some form of error reporting for in case the URL is misformatted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have some form of error reporting for in case the URL is misformatted.
How would I go about this? I'd need some way to run Uri.TryCreate and I'm not exactly sure how to do that in avalonia. Would I run it in the UI script and show/hide a line of text indicating it?
|
Yes, having some sort of way to pass the proxy config to the client engine is gonna be a must. |
Does the client engine even have proxy support? Might need to make a separate PR to robust toolbox or something. Thanks for the reviews, I'll do my best to fix it up :3 |
Yeah, you're gonna need to add that. |
As I've mentioned before, I'm pretty new to C#, but a cursory look at the happy eyeballs implementation in robust toolbox tells me I should be able to do the same thing, but instead take the proxy address from the environment variables. I have no idea how to do this, but given enough time I should be able to figure it out. Any help/pointers would be greatly appreciated :3 |
Edit |
|
Ohhhh, I forgot I was supposed to finish that PR... |
|
May I continue my work on this task? Since this task has been hanging since mar |
|
You are more than free to if you want, no need to ask us, you have had requested changes that you need to solve before we can consider it. Most important being piping the proxy info robust toolbox |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
First off, this is HEAVILY based on koksnull's work in PR #144, with tweaks made to allow it to work w/modern libraries/main repo version. Note that I rarely if ever use C#, so expect to see some horrific code in here somewhere. I am fully open to any suggestions/changes.
This adds proxy functionality to the hub (via happyeyeballshttp) allowing for proxied server discovery, build downloads, etc.
I've tested this on OSX with a socks5 ssh tunnel proxy, and if anyone has other proxies they can test it with please do.
Known issues:
Bit of a mess, but this is my first time. Hopefully y'all can see what I can't so this can get merged. <3