Skip to content

Commit

Permalink
cmd/go-import-redirector: revert all Let's Encrypt bullshit
Browse files Browse the repository at this point in the history
  • Loading branch information
4ad committed Feb 13, 2018
1 parent 940a108 commit 45deff0
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions cmd/go-import-redirector/main.go
Expand Up @@ -52,7 +52,6 @@ package main

import (
"bytes"
"crypto/tls"
"flag"
"fmt"
"html/template"
Expand Down Expand Up @@ -104,32 +103,18 @@ func main() {
importPath = strings.TrimSuffix(importPath, "/*")
repoPath = strings.TrimSuffix(repoPath, "/*")
}

mux := http.NewServeMux()
mux.HandleFunc(strings.TrimSuffix(importPath, "/")+"/", redirect)
mux.HandleFunc(importPath+"/.ping", pong) // non-redirecting URL for debugging TLS certificates
http.HandleFunc(strings.TrimSuffix(importPath, "/")+"/", redirect)
http.HandleFunc(importPath+"/.ping", pong) // non-redirecting URL for debugging TLS certificates
if !*serveTLS {
log.Fatal(http.ListenAndServe(*addr, mux))
log.Fatal(http.ListenAndServe(*addr, nil))
}

host := importPath
if i := strings.Index(host, "/"); i >= 0 {
host = host[:i]
}

certManager := autocert.Manager{
Prompt: autocert.AcceptTOS,
Cache: autocert.DirCache("certs"),
}
server := &http.Server{
Addr: ":443",
Handler: mux,
TLSConfig: &tls.Config{
GetCertificate: certManager.GetCertificate,
},
}
go log.Fatal(http.ListenAndServe(":80", certManager.HTTPHandler(nil)))
log.Fatal(server.ListenAndServeTLS("", ""))
log.Fatal(http.Serve(autocert.NewListener(host), nil))
}

var tmpl = template.Must(template.New("main").Parse(`<!DOCTYPE html>
Expand Down

0 comments on commit 45deff0

Please sign in to comment.