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