local-ip.sh/main.go

36 lines
561 B
Go
Raw Normal View History

2022-10-27 21:19:23 +00:00
package main
import (
2022-10-28 21:36:57 +00:00
"flag"
2023-02-26 13:06:15 +00:00
"time"
2022-10-27 21:19:23 +00:00
2023-02-26 13:06:15 +00:00
"local-ip.sh/certs"
2023-12-12 22:05:57 +00:00
"local-ip.sh/http"
"local-ip.sh/xip"
2022-10-27 21:19:23 +00:00
)
func main() {
2023-12-12 22:05:57 +00:00
port := flag.Int("port", 53, "port the DNS server should bind to")
2022-10-28 21:36:57 +00:00
flag.Parse()
2022-10-27 21:19:23 +00:00
2023-12-13 21:27:51 +00:00
n := xip.NewXip(*port)
2023-02-26 13:06:15 +00:00
go func() {
account := certs.LoadAccount()
2023-02-26 13:06:15 +00:00
certsClient := certs.NewCertsClient(n, account)
time.Sleep(5 * time.Second)
2023-02-26 13:06:15 +00:00
certsClient.RequestCertificate()
for {
2023-12-12 21:25:39 +00:00
// try to renew certificate every day
time.Sleep(24 * time.Hour)
2023-02-26 13:35:07 +00:00
certsClient.RequestCertificate()
2023-02-26 13:06:15 +00:00
}
}()
2023-12-12 22:05:57 +00:00
go http.ServeCertificate()
2022-10-28 21:36:57 +00:00
n.StartServer()
2022-10-27 21:19:23 +00:00
}