Skip to content
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

Question: Getting http.proxy to work #1429

Closed
pushad opened this issue Mar 23, 2017 · 10 comments
Closed

Question: Getting http.proxy to work #1429

pushad opened this issue Mar 23, 2017 · 10 comments

Comments

@pushad
Copy link

pushad commented Mar 23, 2017

Hey guys,

I've got a repo set up at bitbucket. This repository is initialized locally with a reference to the http link provided from the site.

I am using LibGit2Sharp 0.23.1, and I am using the following to fetch from the remote server:

private bool fetch()
        {
            string logMessage = "";
            using (var repo = new Repository(settings.directory))
            {
                Remote remote = repo.Network.Remotes["origin"];
                IEnumerable<string> refSpecs = remote.FetchRefSpecs.Select(x => x.Specification);
                FetchOptions options = new FetchOptions();

                options.CredentialsProvider = getCredentials();
                Commands.Fetch(repo, remote.Name, refSpecs, options, logMessage);
            }
            Logger.debug(logMessage);
            return true;
        }

Inside config file of git I have the following added:

[http]
	proxy = http://<IP>:8888

I am using wireshark to sniff my outgoing packets and can confirm that using command-line git fetch, it is indeed using the configured proxy. Removing this setting from the config also confirms that it is not using the proxy. Also at my proxy server I can confirm that there is a connection going to bitbucket when fetching.

However when I use my code, which points to the same location where the repository is sitting at, it does not use the proxy at all. I don't see any packets going to the proxy server in my Wireshark instance, nor in the logs of my proxy server. It is indeed fetching, just directly to the server.

I've googled quite a bit, I've tried setting up environment proxy variable, setting up proxy in Internet Explorer, setting up proxy on remote only. None of them work with my client.

I'm guessing I've got something misconfigured, just not sure what.

Hopefully you guys can help me out!

@bording
Copy link
Member

bording commented Apr 11, 2017

@pushad Taking a look at the code, I think there might be a problem here.

It looks like GitProxyOptions were added in 88cf9a7, and they are being used in Commands.Fetch, as you can see here.

However, it appears that currently everywhere in the codebase, the GitProxyType of GitProxyOptions is always being initialized to 0, which is None. Looking at the libgit2 code for git_proxy_t, it appears that None disables using any proxies.

@ethomson Is there something I'm missing here in my analysis, or is LibGit2Sharp currently disabling working properly with proxies?

@ethomson
Copy link
Member

Yes, it does look like this is disabling proxies... The default transport on Windows (WinHTTP) does not support proxies, IIRC, so this is basically a noop there. But turning on auto support would help when libgit2 itself is built with libcurl support.

@bording
Copy link
Member

bording commented Apr 11, 2017

The default transport on Windows (WinHTTP) does not support proxies, IIRC

Really? That's unfortunate. Is that a limitation of how it's implemented in libgit2? AFAIK WinHTTP itself should support proxies.

@pushad
Copy link
Author

pushad commented May 1, 2017

Thanks for the replies guys!

Seeing how it has stalled for now, are there any steps I can take to route libgit2sharp through a proxy anyways? Perhaps with use of different libraries, building with certain options enabled. Even third party applications could be considered.

Any pointers are greatly appreciated.

@lanfeust69
Copy link

It used to work with version 0.22, where http.proxy would be picked up. Might depend on the proxy authentication scheme to actually work.

@plainionist
Copy link

any thoughts on timeline for fixing the issue?

@cornerpirate
Copy link

Also interested in hearing if this got resolved along with an example of how to set it?

@pfeigl
Copy link

pfeigl commented Sep 29, 2021

Is there any known workaround to actually get libgit2sharp to work with proxies? Besides having the correct .gitconfig I also tried setting ´HTTP(S)_PROXY` env variables, but also this didn't seem to work for me.

It's kinda hard to believe that this usecase is not working at all, it feels like alot of people should have this problem?

@vilasapj
Copy link

vilasapj commented Sep 4, 2023

We also have an use case to support a client running behind a proxy.
Is there a possibility to get the PR from @jones-gareth in?
Or any other solution possible?

@bording
Copy link
Member

bording commented Dec 3, 2023

LibGit2Sharp 0.29.0 has been released, which adds proxy options to make proxies fully configurable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants