fork-dev / TrackerWin

Bug and issue tracker for Fork for Windows
461 stars 10 forks source link

How to set Proxy server #1953

Open MasonAlice opened 1 year ago

MasonAlice commented 1 year ago

I just want to config a proxy server for fork, instead of setting global proxy config for git.

DanPristupov commented 1 year ago

Why is that important? What is the use case?

MasonAlice commented 1 year ago

Why is that important? What is the use case?

Because I am in China, github can only be accessed through proxies!

DanPristupov commented 1 year ago

Then configure proxy in the command line: https://github.com/fork-dev/TrackerWin/issues/220

gobater commented 9 months ago

@DanPristupov , how does gitfork access to gravatar.com? The gravatar's stopped working in fork. Not sure if it might be due to the corporate proxy? (access to git is fine)

DanPristupov commented 9 months ago

@gobater

how does gitfork access to gravatar.com?

I just checked the source code:

var client = new System.Net.WebClient();
client.DownloadDataCompleted += (sender, args) => { /* */}
client.DownloadDataAsync(GravatarUri(email));

The gravatar's stopped working in fork. Not sure if it might be due to the corporate proxy? (access to git is fine)

It could be. Looks like WebClient doesn't use system proxy by default.

https://stackoverflow.com/a/21183464

As a test, try to add to %localappdata%\fork\app-1.92.0\Fork.exe.config:

<system.net>
    <defaultProxy useDefaultCredentials="true" />
</system.net>
gobater commented 9 months ago

Hi @DanPristupov ,

Now it works. It's curious that if I remove the Proxy setting in the config and restart fork, I still see the avatars. Are they cached?

DanPristupov commented 9 months ago

It's curious that if I remove the Proxy setting in the config and restart fork, I still see the avatars. Are they cached?

No, not intentionally, at least. May be there is a cache on the system level, but Fork does not cache avatars between sessions.

gobater commented 9 months ago

Just had some time to further detail the issue...

My enterprise uses a proxy, which is setup via PAC. When I'm not connected to the enterprise network, PAC configuration fails, and many tools fallback to "no-proxy" (e.g. chrome, edge, firefox... which all are configured to use the system settings). However, in this case, Git Fork fails to connect to gravatar (independently of the settings in Fork.exe.config)

As soon as I connect to the enterprise network (e.g. via VPN) Git Fork connects to gravatar without issues (independently of the settings in Fork.exe.config) --> so the real problem I'm facing is falling back to "no-proxy" when the configured proxy cannot be reached or when PAC cannot be reached...

brandonh-msft commented 5 months ago

I would like to see a way to do this outside of the netfx app config file. Requiring this method means every time Fork updates, I have to go into the new app-<version> folder and make the same edit to it.

Additionally, for proxies that require certs this doesn't appear to work. I have the CA Bundle specified in my global git config, but Fork cannot pull, push, fetch from the remote repositories. Git in terminal, however, can just fine.

For reference, here are the http settings I have set:

http.sslbackend=openssl
http.proxy=http://<my-corp-proxy>:8080
http.sslcainfo=C:/Users/<me>/cacert.mycorp.pem
https.proxy=http://<my-corp-proxy>:8080

In Fork on a fetch I get

fatal: unable to access 'https://github.com/my-corp/my-repo.git/': schannel: CertGetCertificateChain trust error CERT_TRUST_REVOCATION_STATUS_UNKNOWN

while git fetch works just fine from terminal