Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cactus/go-camo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: pypi/camo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 18 commits
  • 7 files changed
  • 2 contributors

Commits on Jun 29, 2022

  1. make work with cabotage

    ewdurbin committed Jun 29, 2022
    Copy the full SHA
    27d9554 View commit details
  2. Copy the full SHA
    65a0c9b View commit details
  3. Merge pull request #2 from pypi/configurable_max_size_via_env

    make max-size configurable via environment
    ewdurbin authored Jun 29, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7df1dac View commit details
  4. Copy the full SHA
    0d00dc7 View commit details
  5. Merge pull request #3 from pypi/max_size_redirect

    redirect when max-size is exceeded and a max-size-redirect is configured
    ewdurbin authored Jun 29, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    cc40fa2 View commit details

Commits on Mar 6, 2023

  1. update dockerfile

    ewdurbin committed Mar 6, 2023
    Copy the full SHA
    3a2461f View commit details
  2. Copy the full SHA
    42ee215 View commit details
  3. Copy the full SHA
    ae74361 View commit details
  4. Merge pull request #4 from pypi/merge_from_upstream

    merge from upstream
    ewdurbin authored Mar 6, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d222b4d View commit details

Commits on Mar 10, 2023

  1. Copy the full SHA
    816afa1 View commit details

Commits on Jul 14, 2023

  1. deploy

    ewdurbin committed Jul 14, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    ewdurbin Ee Durbin
    Copy the full SHA
    b5f718b View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    ewdurbin Ee Durbin
    Copy the full SHA
    983b385 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    ewdurbin Ee Durbin
    Copy the full SHA
    075858e View commit details

Commits on Aug 30, 2023

  1. Set --server-name

    di authored Aug 30, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    773ba32 View commit details
  2. Merge pull request #5 from pypi/di-patch-1

    Set `--server-name` to something PyPI-specific
    di authored Aug 30, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    71fcf27 View commit details

Commits on Jun 18, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    ewdurbin Ee Durbin
    Copy the full SHA
    d5e82b1 View commit details
  2. Merge pull request #6 from pypi/merge_master

    Merge from upstream
    ewdurbin authored Jun 18, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    30acfc5 View commit details

Commits on Jul 11, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    ewdurbin Ee Durbin
    Copy the full SHA
    6d05634 View commit details
Showing with 14 additions and 4 deletions.
  1. +1 −1 .github/workflows/codeql-analysis.yml
  2. +1 −1 .github/workflows/unit-tests.yml
  3. +1 −0 Dockerfile.cabotage
  4. +1 −1 Procfile
  5. +1 −0 README.adoc
  6. +2 −0 cmd/go-camo/main.go
  7. +7 −1 pkg/camo/proxy.go
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ on:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
branches: [main]
schedule:
- cron: '0 15 * * 4'

2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ on:
push:
branches: ["**"]
pull_request:
branches: [master]
branches: [main]

jobs:
test:
1 change: 1 addition & 0 deletions Dockerfile.cabotage
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: go-camo --listen=0.0.0.0:$PORT -k $HMAC_KEY
web: /bin/go-camo --socket-listen=/var/run/cabotage/cabotage.sock --server-name=https://github.com/pypi/camo --max-size=$GOCAMO_MAXSIZE --max-size-redirect=$GOCAMO_MAXSIZEREDIRECT --header="Access-Control-Allow-Origin: $ALLOW_ORIGIN"
1 change: 1 addition & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -302,6 +302,7 @@ Flags:
--ssl-key=STRING ssl private key (key.pem) path
--ssl-cert=STRING ssl cert (cert.pem) path
--max-size=INT-64 Max allowed response size (KB)
--max-size-redirect URL to redirect to when max-size is exceeded
--timeout=4s Upstream request timeout
--max-redirects=3 Maximum number of redirects to follow
--metrics Enable Prometheus compatible metrics endpoint
2 changes: 2 additions & 0 deletions cmd/go-camo/main.go
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@ type CLI struct {
MaxSize int64 `name:"max-size" help:"Max allowed response size (KB)"`
ReqTimeout time.Duration `name:"timeout" default:"4s" help:"Upstream request timeout"`
MaxRedirects int `name:"max-redirects" default:"3" help:"Maximum number of redirects to follow"`
MaxSizeRedirect string `long:"max-size-redirect" description:"URL to redirect when max-size is exceeded"`
Metrics bool `name:"metrics" help:"Enable Prometheus compatible metrics endpoint"`
NoDebugVars bool `name:"no-debug-vars" help:"Disable the /debug/vars/ metrics endpoint. This option has no effects when the metrics are not enabled."`
NoLogTS bool `name:"no-log-ts" help:"Do not add a timestamp to logging"`
@@ -227,6 +228,7 @@ func (cli *CLI) Run() {
config.MaxSize = cli.MaxSize * 1024
config.RequestTimeout = cli.ReqTimeout
config.MaxRedirects = cli.MaxRedirects
config.MaxSizeRedirect = cli.MaxSizeRedirect
config.ServerName = ServerName

// configure metrics collection in camo
8 changes: 7 additions & 1 deletion pkg/camo/proxy.go
Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@ type Config struct {
HMACKey []byte
// MaxSize is the maximum valid image size response (in bytes).
MaxSize int64
// MaxSizeRedirect is the URL to redirect when MaxSize is exceeded.
MaxSizeRedirect string
// MaxRedirects is the maximum number of redirects to follow.
MaxRedirects int
// Request timeout is a timeout for fetching upstream data.
@@ -246,7 +248,11 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if mlog.HasDebug() {
mlog.Debugx("content length exceeded", mlog.A("url", sURL))
}
http.Error(w, "Content length exceeded", http.StatusNotFound)
if p.config.MaxSizeRedirect != "" {
http.Redirect(w, req, p.config.MaxSizeRedirect, http.StatusFound)
} else {
http.Error(w, "Content length exceeded", http.StatusNotFound)
}
return
}