target based upstream options

This commit is contained in:
2025-08-14 14:52:17 +08:00
parent f1fe70386d
commit 6681522678
9 changed files with 245 additions and 5 deletions

24
main.go
View File

@@ -13,9 +13,25 @@ import (
"edgaru089.ink/go/regolith/internal/conf"
"edgaru089.ink/go/regolith/internal/http"
"edgaru089.ink/go/regolith/internal/out"
"edgaru089.ink/go/regolith/internal/perm"
)
func readDialer() *out.Dialer {
out_buf, err := os.ReadFile("out.json")
if err != nil {
log.Print("error reading out.json: ", err)
return nil
}
var outcfg out.Config
err = json.Unmarshal(out_buf, &outcfg)
if err != nil {
log.Print("error unmarshaling out.json: ", err)
return nil
}
return out.New(outcfg)
}
func main() {
var s *http.Server
@@ -34,6 +50,9 @@ func main() {
}
}
dialer := readDialer()
s.SetDialer(dialer)
var conf conf.Config
{
conf_buf, err := os.ReadFile("config.json")
@@ -75,7 +94,7 @@ func main() {
go func() {
for {
<-sighup_chan
log.Printf("SIGHUP received, reloading permissions")
log.Printf("SIGHUP received, reloading")
perm_buf, err := os.ReadFile("perm.json")
if err != nil {
log.Printf("skipping reload: error opening perm.json: %e", err)
@@ -88,6 +107,9 @@ func main() {
continue
}
s.Perm.Load(perm_json)
dialer := readDialer()
s.SetDialer(dialer)
}
}()