2020-10-12 14:34:52 -06:00
|
|
|
// +build ignore
|
2020-09-21 15:23:51 -06:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-10-13 12:22:15 -06:00
|
|
|
"crypto/tls"
|
2020-09-21 15:23:51 -06:00
|
|
|
"log"
|
2020-10-13 12:22:15 -06:00
|
|
|
"time"
|
2020-09-21 17:17:10 -06:00
|
|
|
|
2020-10-28 12:59:45 -06:00
|
|
|
"git.sr.ht/~adnano/go-gemini"
|
2020-09-21 15:23:51 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2020-10-28 12:59:45 -06:00
|
|
|
var server gemini.Server
|
2020-10-31 19:07:02 -06:00
|
|
|
server.ReadTimeout = 1 * time.Minute
|
|
|
|
server.WriteTimeout = 2 * time.Minute
|
2020-10-28 12:59:45 -06:00
|
|
|
if err := server.Certificates.Load("/var/lib/gemini/certs"); err != nil {
|
2020-10-12 14:34:52 -06:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2020-10-28 12:59:45 -06:00
|
|
|
server.CreateCertificate = func(hostname string) (tls.Certificate, error) {
|
2020-10-31 14:33:56 -06:00
|
|
|
return gemini.CreateCertificate(gemini.CertificateOptions{
|
2020-10-28 12:59:45 -06:00
|
|
|
DNSNames: []string{hostname},
|
|
|
|
Duration: time.Minute, // for testing purposes
|
|
|
|
})
|
2020-10-13 12:22:15 -06:00
|
|
|
}
|
2020-10-12 14:34:52 -06:00
|
|
|
|
2020-10-28 12:59:45 -06:00
|
|
|
var mux gemini.ServeMux
|
|
|
|
mux.Handle("/", gemini.FileServer(gemini.Dir("/var/www")))
|
2020-09-21 15:23:51 -06:00
|
|
|
|
2020-10-21 14:28:50 -06:00
|
|
|
server.Register("localhost", &mux)
|
2020-10-12 14:34:52 -06:00
|
|
|
if err := server.ListenAndServe(); err != nil {
|
2020-10-11 22:13:24 -06:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2020-09-21 15:23:51 -06:00
|
|
|
}
|