Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/caddyserver/caddy
19 July 2023, 20:10:49 UTC
  • Code
  • Branches (26)
  • Releases (119)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/2.5.2-grace-noblock
    • refs/heads/2.6.2-exported-name
    • refs/heads/2.6.2-version-patch
    • refs/heads/active-health-check-headers
    • refs/heads/cache-ask
    • refs/heads/cmd-issuer
    • refs/heads/config-adapter-fix
    • refs/heads/document-interfaces
    • refs/heads/file-placeholder
    • refs/heads/fileserver-show
    • refs/heads/fuzz-seed-corpus
    • refs/heads/ident-storage
    • refs/heads/master
    • refs/heads/metrics-improvements
    • refs/heads/proxy-res-templates
    • refs/heads/proxy-success-ratio
    • refs/heads/proxy-upstream-ids
    • refs/heads/public-ip-certs
    • refs/heads/querymatcher
    • refs/heads/response-controller
    • refs/heads/rewrite-modify-query
    • refs/heads/strict
    • refs/heads/v1
    • refs/heads/virtualconns
    • refs/heads/ws-close-timeouts
    • refs/tags/v2.2.1
    • f857b32d65de882dbc945c94029849a7fc895e36
    • v2.7.0-beta.2
    • v2.7.0-beta.1
    • v2.6.4
    • v2.6.3
    • v2.6.2
    • v2.6.1
    • v2.6.0-beta.5
    • v2.6.0-beta.4
    • v2.6.0-beta.3
    • v2.6.0-beta.2
    • v2.6.0-beta.1
    • v2.6.0
    • v2.5.2
    • v2.5.1
    • v2.5.0-rc.1
    • v2.5.0-beta.1
    • v2.5.0
    • v2.4.6
    • v2.4.5
    • v2.4.4
    • v2.4.3
    • v2.4.2
    • v2.4.1
    • v2.4.0-rc.1
    • v2.4.0-beta.2
    • v2.4.0-beta.1
    • v2.4.0
    • v2.3.0-rc.2
    • v2.3.0-rc.1
    • v2.3.0-beta.1
    • v2.3.0
    • v2.2.3
    • v2.2.0-rc.3
    • v2.2.0-rc.2
    • v2.2.0-rc.1
    • v2.2.0
    • v2.1.1
    • v2.1.0-beta.2
    • v2.1.0-beta.1
    • v2.1.0
    • v2.0.0-rc.3
    • v2.0.0-rc.2
    • v2.0.0-rc.1
    • v2.0.0-beta.20
    • v2.0.0-beta.19
    • v2.0.0-beta.18
    • v2.0.0-beta.17
    • v2.0.0-beta.16
    • v2.0.0-beta.15
    • v2.0.0-beta.14
    • v2.0.0-beta.13
    • v2.0.0-beta12
    • v2.0.0-beta11
    • v2.0.0-beta10
    • v2.0.0-beta9
    • v2.0.0-beta8
    • v2.0.0-beta7
    • v2.0.0-beta6
    • v2.0.0-beta5
    • v2.0.0-beta4
    • v2.0.0-beta3
    • v2.0.0-beta2
    • v2.0.0-beta1
    • v2.0.0
    • v1.0.5
    • v1.0.4
    • v1.0.3
    • v1.0.2
    • v1.0.1
    • v1.0.0-beta2
    • v1.0.0-beta1
    • v1.0.0
    • v0.11.5
    • v0.11.4
    • v0.11.3
    • v0.11.2
    • v0.11.1
    • v0.11.0
    • v0.10.14
    • v0.10.13
    • v0.10.12
    • v0.10.11
    • v0.10.10
    • v0.10.9
    • v0.10.8
    • v0.10.7
    • v0.10.6
    • v0.10.5
    • v0.10.4
    • v0.10.3
    • v0.10.2
    • v0.10.1
    • v0.10.0
    • v0.9-beta.2
    • v0.9-beta.1
    • v0.9.5
    • v0.9.4
    • v0.9.3
    • v0.9.2
    • v0.9.1
    • v0.9.0
    • v0.8-beta.4
    • v0.8-beta.3
    • v0.8-beta.2
    • v0.8-beta.1
    • v0.8.3
    • v0.8.2
    • v0.8.1
    • v0.8.0
    • v0.7.6
    • v0.7.5
    • v0.7.4
    • v0.7.3
    • v0.7.2
    • v0.7.1
    • v0.7.0
    • v0.6.0
    • v0.5.1
    • v0.5.0
  • 73506f2
  • /
  • modules
  • /
  • caddyhttp
  • /
  • http2listener.go
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:51b356a7779c66756cb193ed644a7fac86736306
origin badgedirectory badge
swh:1:dir:e3159b7c681b4759009361c5bf280701d157c062
origin badgerevision badge
swh:1:rev:f857b32d65de882dbc945c94029849a7fc895e36
origin badgesnapshot badge
swh:1:snp:7f1b08475871b71d5487ad059a1b400d9e28831b

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: f857b32d65de882dbc945c94029849a7fc895e36 authored by bt90 on 17 July 2023, 20:16:43 UTC
go.mod: update quic-go to v0.36.2 (#5636)
Tip revision: f857b32
http2listener.go
package caddyhttp

import (
	"context"
	"crypto/tls"
	weakrand "math/rand"
	"net"
	"net/http"
	"sync/atomic"
	"time"

	"golang.org/x/net/http2"
)

// http2Listener wraps the listener to solve the following problems:
// 1. server h2 natively without using h2c hack when listener handles tls connection but
// don't return *tls.Conn
// 2. graceful shutdown. the shutdown logic is copied from stdlib http.Server, it's an extra maintenance burden but
// whatever, the shutdown logic maybe extracted to be used with h2c graceful shutdown. http2.Server supports graceful shutdown
// sending GO_AWAY frame to connected clients, but doesn't track connection status. It requires explicit call of http2.ConfigureServer
type http2Listener struct {
	cnt uint64
	net.Listener
	server   *http.Server
	h2server *http2.Server
}

type connectionStateConn interface {
	net.Conn
	ConnectionState() tls.ConnectionState
}

func (h *http2Listener) Accept() (net.Conn, error) {
	for {
		conn, err := h.Listener.Accept()
		if err != nil {
			return nil, err
		}

		if csc, ok := conn.(connectionStateConn); ok {
			// *tls.Conn will return empty string because it's only populated after handshake is complete
			if csc.ConnectionState().NegotiatedProtocol == http2.NextProtoTLS {
				go h.serveHttp2(csc)
				continue
			}
		}

		return conn, nil
	}
}

func (h *http2Listener) serveHttp2(csc connectionStateConn) {
	atomic.AddUint64(&h.cnt, 1)
	h.runHook(csc, http.StateNew)
	defer func() {
		csc.Close()
		atomic.AddUint64(&h.cnt, ^uint64(0))
		h.runHook(csc, http.StateClosed)
	}()
	h.h2server.ServeConn(csc, &http2.ServeConnOpts{
		Context:    h.server.ConnContext(context.Background(), csc),
		BaseConfig: h.server,
		Handler:    h.server.Handler,
	})
}

const shutdownPollIntervalMax = 500 * time.Millisecond

func (h *http2Listener) Shutdown(ctx context.Context) error {
	pollIntervalBase := time.Millisecond
	nextPollInterval := func() time.Duration {
		// Add 10% jitter.
		//nolint:gosec
		interval := pollIntervalBase + time.Duration(weakrand.Intn(int(pollIntervalBase/10)))
		// Double and clamp for next time.
		pollIntervalBase *= 2
		if pollIntervalBase > shutdownPollIntervalMax {
			pollIntervalBase = shutdownPollIntervalMax
		}
		return interval
	}

	timer := time.NewTimer(nextPollInterval())
	defer timer.Stop()
	for {
		if atomic.LoadUint64(&h.cnt) == 0 {
			return nil
		}
		select {
		case <-ctx.Done():
			return ctx.Err()
		case <-timer.C:
			timer.Reset(nextPollInterval())
		}
	}
}

func (h *http2Listener) runHook(conn net.Conn, state http.ConnState) {
	if h.server.ConnState != nil {
		h.server.ConnState(conn, state)
	}
}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API