Compare commits
No commits in common. "1ad9ef6d93d444bef76ce98c5e3caaf3daa2ee4d" and "85bd71cff3db316dac241b8f8caa177e8029ae61" have entirely different histories.
1ad9ef6d93
...
85bd71cff3
3
acme.go
3
acme.go
@ -265,7 +265,7 @@ func makeTlsConfig(pagesDomain, path string, acmeClient *lego.Client) *tls.Confi
|
|||||||
defer unlockDomain(domain)
|
defer unlockDomain(domain)
|
||||||
|
|
||||||
// Request new certificate
|
// Request new certificate
|
||||||
log.Infof("Obtaining new certificate for %s...", domain)
|
log.Debugf("Obtaining new certificate for %s...", domain)
|
||||||
err := ObtainNewCertificate(
|
err := ObtainNewCertificate(
|
||||||
[]string{domain},
|
[]string{domain},
|
||||||
path,
|
path,
|
||||||
@ -284,6 +284,7 @@ func makeTlsConfig(pagesDomain, path string, acmeClient *lego.Client) *tls.Confi
|
|||||||
return cert.TlsCertificate, nil
|
return cert.TlsCertificate, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("TLS ServerName: %s", info.ServerName)
|
||||||
return Certificates.FallbackCertificate.TlsCertificate, nil
|
return Certificates.FallbackCertificate.TlsCertificate, nil
|
||||||
},
|
},
|
||||||
NextProtos: []string{
|
NextProtos: []string{
|
||||||
|
12
pages.go
12
pages.go
@ -43,9 +43,9 @@ func serveFile(username, reponame, path, giteaUrl string, w http.ResponseWriter)
|
|||||||
var mimeType string
|
var mimeType string
|
||||||
var err error
|
var err error
|
||||||
if found {
|
if found {
|
||||||
|
log.Debugf("Returning %s from cache", path)
|
||||||
content = entry.(PageContentCache).Content
|
content = entry.(PageContentCache).Content
|
||||||
mimeType = entry.(PageContentCache).mimeType
|
mimeType = entry.(PageContentCache).mimeType
|
||||||
log.Debugf("Found page in cache with mimeType '%s'", mimeType)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to do the raw request manually because the Gitea SDK does not allow
|
// We have to do the raw request manually because the Gitea SDK does not allow
|
||||||
@ -90,13 +90,6 @@ func serveFile(username, reponame, path, giteaUrl string, w http.ResponseWriter)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle 404s early.
|
|
||||||
// TODO: Maybe allow delivering a 404.html instead?
|
|
||||||
if resp.StatusCode == 404 {
|
|
||||||
w.WriteHeader(404)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
content, err = io.ReadAll(resp.Body)
|
content, err = io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to get file %s/%s/%s (%s)", username, reponame, path, err)
|
log.Errorf("Failed to get file %s/%s/%s (%s)", username, reponame, path, err)
|
||||||
@ -107,7 +100,6 @@ func serveFile(username, reponame, path, giteaUrl string, w http.ResponseWriter)
|
|||||||
pathParts := strings.Split(path, ".")
|
pathParts := strings.Split(path, ".")
|
||||||
ext := pathParts[len(pathParts)-1]
|
ext := pathParts[len(pathParts)-1]
|
||||||
mimeType = mime.TypeByExtension("." + ext)
|
mimeType = mime.TypeByExtension("." + ext)
|
||||||
log.Debugf("Returning MIME type '%s' for extension '%s", mimeType, ext)
|
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
pageCache.Set(
|
pageCache.Set(
|
||||||
@ -121,7 +113,7 @@ func serveFile(username, reponame, path, giteaUrl string, w http.ResponseWriter)
|
|||||||
)
|
)
|
||||||
|
|
||||||
log.Debugf("Page %s requested from Gitea and cached in memory at %v", path, now)
|
log.Debugf("Page %s requested from Gitea and cached in memory at %v", path, now)
|
||||||
w.Header().Set("Content-Type", mimeType)
|
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
|
w.Header().Set("Content-Type", mimeType)
|
||||||
w.Write(content)
|
w.Write(content)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user