use proxy for omnifunc when configured in .gitconfig or .git/config#52
use proxy for omnifunc when configured in .gitconfig or .git/config#52shadowwa wants to merge 1 commit into
Conversation
|
hmm, I would have expected that config to be part of your ~/.curlrc |
|
I haven't fully thought this through, but I think it used to be common for the git config of gitlab to be different to the api/http stuff. |
|
I had a quick scan of rhubarb to see if it supports doing anything with gitconfig http proxy and it doesn't appear to. |
Do you mean when git use [remote "origin"]
url = git@my-ssh.gitlab.privateand the gitlab api is accessible via https://gitlab-url.private ? let g:gitlab_proxies = {'gitlab-url.private': 'socks5h://proxy-url:8082'}
It was my first idea but unfortunately, proxies can only be set global from HTTP_PROXY environment variables or in |
|
I have to say I am a bit baffled by this use case. |
|
Unfortunately, due to heterogeneous private networks, we don't have a transparent proxy, we have to use a proxy.pac file that set differents proxies for differents set of urls. I've modified my MR to use a gitlab_proxie configuration variable set in |
|
How about a wrapper for curl? something like: ~/.bin/curl #!/usr/bin/env bash
TARGET_URL="${@: -1}"
PROXY_ADDRESS=$(pactester -p /path/to/proxy.pac -u $TARGET_URL)
if [[ "$PROXY_SERVER" == "DIRECT" ]]; then
# Call the REAL curl without proxy
/usr/bin/curl "$@"
else
# Format "PROXY host:port" to "http://host:port"
PROXY_CLEAN=$(echo $PROXY_SERVER | sed 's/PROXY //;s/;//')
/usr/bin/curl -x "$PROXY_CLEAN" "$@"
fiI've not tested any of that as I don't have any pac files, the example is mostly AI generated, but will any of that work? |
|
After few fixes, I've ended up using this wrapper and it works fine. #!/usr/bin/env bash
# FIXME does not work if url is not the last argument
TARGET_URL="${*: -1}"
PROXY_SERVER=$(pactester -p /path/to/proxy.pac -u "$TARGET_URL")
if [[ "$PROXY_SERVER" == 'DIRECT' || -z "$PROXY_SERVER" ]]; then
# Call the REAL curl without proxy
/usr/bin/curl "$@"
else
# only keep the first proxy.
# TODO implement fallback if several proxies are defined
PROXY_SERVER="${PROXY_SERVER%;*}"
# Format "PROXY host:port" to "host:port"
# and "SOCKS5 host:port" to "socks5://port:host"
PROTOCOL="${PROXY_SERVER% *}"
PROXY_URL=${PROXY_SERVER##* }
if [[ "$PROTOCOL" == 'PROXY' ]]; then
PROTOCOL=''
else
PROTOCOL="${PROTOCOL,,}://"
fi
/usr/bin/curl -x "${PROTOCOL}${PROXY_URL}" "$@"
fi
It can be useful to avoid running problem with other script using curl (for instance putting option after the URL). |
When using a gitlab instance behind a proxy, I need to configure the proxy in ~/.gitconfig or .git/config file.
In fugitive-gitlab.vim, curl requests are not using this proxy hence the omnifunc does not works.
With this commit, if a proxy is configured in git config files, it will by used.