GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feature: Add support for HTTP_PROXY, HTTPS_PROXY, and NO_PROXY by peterguy · Pull Request #1260 · sourcegraph/src-cli

Conversation

@peterguy

@peterguy peterguy commented Feb 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Adds support for the standard environment variables HTTP_PROXY, HTTPS_PROXY, and NO_PROXY.

SRC_PROXY still takes precedence, including over NO_PROXY.

Test plan

Added CI tests validating proxy connection behavior.

Manual testing

Install mitmproxy, socat and squid (brew install mitmproxy socat squid for me).

Create an SSL cert for squid:

openssl req -x509 -newkey rsa:2048 \
  -keyout ${HOME}/squid-key.pem -out ${HOME}/squid-cert.pem \
  -days 365 -nodes -subj "/CN=localhost"
cat ${HOME}/squid-key.pem ${HOME}/squid-cert.pem > ${HOME}/squid-proxy.pem

Create a config for squid:

cat << EOF >${HOME}/squid.conf
https_port 8445 cert=${HOME}/squid-proxy.pem
sslproxy_session_cache_size 0
acl localnet src 127.0.0.1/32
http_access allow localhost
acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 443
acl Safe_ports port 1025-65535
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all
http_port 3128
EOF

Launch three terminals to run the proxies:

  • run socat -d -d unix-listen:${HOME}/src-proxy.sock,fork tcp:localhost:8080 in one.
  • run mitmproxy -v in another.
  • run squid - squid -f ${HOME}/squid.conf -N -d 1 - in the third.

In a fourth terminal, in the src-cli repo, build the binary: go build -o ./src-cli ./cmd/src

Ensure you have SRC_ENDPOINT and SRC_ACCESS_TOKEN set in your environment, and unset SRC_PROXY. SRC_ENDPOINT needs to be https://.

Connect with each proxy (mitmproxy is 8080, squid is 8445) and with no proxy:

for x in http://localhost:8080 http://localhost:3128 https://localhost:8445
do
HTTPS_PROXY=${x} ./src-cli login --insecure-skip-verify=true
SRC_PROXY=${x} ./src-cli login --insecure-skip-verify=true
HTTPS_PROXY=${x} NO_PROXY=${${SRC_ENDPOINT#*://}%%/*} ./src-cli login --insecure-skip-verify=true
SRC_PROXY=${x} NO_PROXY=${${SRC_ENDPOINT#*://}%%/*} ./src-cli login --insecure-skip-verify=true
done
HTTPS_PROXY="" SRC_PROXY="" ./src-cli login --insecure-skip-verify=true
SRC_PROXY=${HOME}/src-proxy.sock ./src-cli login --insecure-skip-verify=true

You should get 14 "Authenticated as [USER] on [ENDPOINT]" messages in your terminal. You should see four connections in mitmproxy, six in squid, and several lines in socat indicating one connection.

This test ensures:

  • all of the proxy environment variables are supported (SRC_PROXY, HTTPS_PROXY, NO_PROXY)
  • NO_PROXY trumps HTTPS_PROXY
  • SRC_PROXY trumps HTTPS_PROXY and NO_PROXY
  • both plain HTTP and TLS-enabled proxies are supported
  • the ability to connect to UNIX Domain Sockets is preserved
  • communication with no proxy at all is successful

Cleanup from the test:

  • terminate all running proxy processes.
  • rm -f ${HOME}/squid-proxy.pem ${HOME}/squid-key.pem ${HOME}/squid-cert.pem ${HOME}/squid.conf ${HOME}/src-proxy.sock

Closes https://linear.app/sourcegraph/issue/CPL-236/src-cli-support-standard-http-proxy

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@keegancsmith
keegancsmith requested a review from a team February 26, 2026 07:12
bahrmichael
bahrmichael reviewed Feb 26, 2026
View reviewed changes
Comment thread internal/api/api.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

bahrmichael
bahrmichael reviewed Feb 26, 2026
View reviewed changes
Comment thread internal/api/api.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

keegancsmith
keegancsmith approved these changes Feb 26, 2026
View reviewed changes

@keegancsmith keegancsmith left a comment

Copy link
Copy Markdown
Member

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.

Nice! Inline comments, but otherwise LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread internal/api/api.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/api/proxy.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/api/proxy.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/api/proxy.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/api/proxy_test.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/api/proxy_test.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@keegancsmith

keegancsmith commented Feb 26, 2026

Copy link
Copy Markdown
Member

You might wanna rebase, I think william just did some CI updates which include things like go-lint/etc.

peterguy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@peterguy

peterguy commented Feb 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for all of your commentary; I forgot to open this PR in draft mode! Been trying to address what looks like flakey tests in the Ubuntu CI runner; I'll go through your very helpful comments soon.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@peterguy

peterguy commented Feb 27, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

This change is part of the following stack:

  • refactor: validate and parse the endpoint and proxy at program load #1267
    • feature: Add support for HTTP_PROXY, HTTPS_PROXY, and NO_PROXY #1260 ◀

Change managed by git-spice.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@peterguy
peterguy force-pushed the peterguy/support-http_proxy branch from b1d6176 to 05f0fbb Compare February 27, 2026 00:48
@keegancsmith

keegancsmith commented Feb 27, 2026

Copy link
Copy Markdown
Member

@peterguy alright just re-request review when ready.

peterguy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@peterguy
peterguy requested review from bahrmichael and keegancsmith February 27, 2026 19:32
@peterguy
peterguy force-pushed the peterguy/support-http_proxy branch from 622bd60 to 3536377 Compare February 27, 2026 19:40
keegancsmith
keegancsmith requested changes Mar 2, 2026
View reviewed changes

@keegancsmith keegancsmith left a comment

Copy link
Copy Markdown
Member

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.

Requesting changes since I just wanna re-review once you have addressed the comments. FYI I pushed some commits to resolve the CI issues.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread cmd/src/main.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/api/api.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/api/proxy_test.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/api/api.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/api/proxy.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/api/proxy.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cmd/src/main.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cmd/src/main_test.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cmd/src/main.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

keegancsmith
keegancsmith reviewed Mar 2, 2026
View reviewed changes
Comment thread internal/api/proxy.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bahrmichael

bahrmichael commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

I would wait for an update for Keegan's requested changes before doing my review pass if that's okay.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@keegancsmith
keegancsmith force-pushed the peterguy/support-http_proxy branch from 6ab67e5 to 78eadd2 Compare March 2, 2026 10:00
bahrmichael
bahrmichael reviewed Mar 4, 2026
View reviewed changes
Comment thread cmd/src/main.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

bahrmichael
bahrmichael reviewed Mar 4, 2026
View reviewed changes
Comment thread cmd/src/main.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

bahrmichael
bahrmichael reviewed Mar 4, 2026
View reviewed changes
Comment thread cmd/src/main.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@peterguy
peterguy changed the base branch from main to peterguy/clean-up-config March 8, 2026 03:32
@peterguy
peterguy force-pushed the peterguy/support-http_proxy branch from 78eadd2 to 54aada1 Compare March 8, 2026 03:32
@peterguy peterguy mentioned this pull request Mar 8, 2026
refactor: validate and parse the endpoint and proxy at program load #1267
Merged
@peterguy
peterguy force-pushed the peterguy/clean-up-config branch from cab95e8 to 97c1b0a Compare March 10, 2026 01:53
@peterguy
peterguy force-pushed the peterguy/support-http_proxy branch 4 times, most recently from 448305b to a0d8f91 Compare March 11, 2026 04:40
@peterguy
peterguy force-pushed the peterguy/clean-up-config branch from 5ccd030 to 9ad25e5 Compare March 11, 2026 06:01
@peterguy
peterguy force-pushed the peterguy/support-http_proxy branch from a0d8f91 to ed682d7 Compare March 11, 2026 06:11
@peterguy peterguy changed the title Add support for HTTP_PROXY, HTTPS_PROXY, and NO_PROXY feature: Add support for HTTP_PROXY, HTTPS_PROXY, and NO_PROXY Mar 12, 2026
peterguy added 17 commits March 31, 2026 19:02
@peterguy
check I/O errors; use resp.ProtoMajor instead of strings
70070ab
@peterguy
add test to confirm that closing the connection on handshake error (`…
70b1f0f
…tlsConn.Close()`) is necessary
@peterguy
fmt.Errorf --> errors.Newf
77ffe16
@peterguy
add test for https connection rejection - ensure correct error handli…
41c65e6
…ng in the custom dialer
@peterguy
add retry for test that is flaky on CI, probably due to resource cont…
b9aa6dc
…ention
@peterguy
another try at addressing CI test errors
7831cc9
@peterguy
clean up proxy and remove buffered reader - don't actually need it
73fb824
@peterguy
clean up and refactor tests
872fedf
@peterguy
refactor buildTransport to match incoming changes
2445d4e
@peterguy
fix error capitalization
7e37fb9
@peterguy
undo capitalization change
6aa57c0
@peterguy
fix rebase
9ca8fe1
@peterguy
remove the custom dialer - turns out it is not actually needed
7a74eb7
@peterguy
remove unused function
531566b
@peterguy
undo comment change as out of scope
8a5477e
@peterguy
pare down to smoke tests
cd0bd79
@peterguy
remove all tests - they really aren't useful
99ad843
@peterguy
peterguy force-pushed the peterguy/support-http_proxy branch from 6259749 to 99ad843 Compare April 1, 2026 02:02
bahrmichael
bahrmichael approved these changes Apr 1, 2026
View reviewed changes

@bahrmichael bahrmichael left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

Thank you for simplifying this so much! I'm surprised that we can delete so much code, but as you said it still works after removing the socks5 code.

Is the PR description still up to date?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
peterguy added 3 commits April 2, 2026 15:02
@peterguy
add some smoke tests for the proxy behavior
18d0560
@peterguy
facepalm moment: missed the fact that a bool was being used to track …
614796e
…race conditions
@peterguy
Merge branch 'main' into peterguy/support-http_proxy
8ae0bdc
@peterguy
peterguy marked this pull request as ready for review April 3, 2026 21:33
@peterguy

peterguy commented Apr 3, 2026

Copy link
Copy Markdown
Contributor Author

Description is accurate, Added some better smoke tests that I think are important to guard against future changes to withProxyTransport, even though the code is much more simple.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

keegancsmith
keegancsmith approved these changes May 4, 2026
View reviewed changes

@keegancsmith keegancsmith left a comment

Copy link
Copy Markdown
Member

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.

Sorry didn't realise it would wait until I approve before allowing you to merge.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@keegancsmith
Merge branch 'main' into peterguy/support-http_proxy
50584dd
@keegancsmith
keegancsmith enabled auto-merge (squash) May 4, 2026 15:40
@keegancsmith
keegancsmith disabled auto-merge May 5, 2026 06:47
@keegancsmith
keegancsmith merged commit 82de268 into main May 5, 2026
9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@keegancsmith
keegancsmith deleted the peterguy/support-http_proxy branch May 5, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@keegancsmith keegancsmith keegancsmith approved these changes
@bahrmichael bahrmichael bahrmichael approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@peterguy @keegancsmith @bahrmichael
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.