add some debugging
This commit is contained in:
parent
671019ff26
commit
06ff140507
@ -15,7 +15,7 @@
|
|||||||
in {
|
in {
|
||||||
tsvnstat = pkgs.buildGoModule {
|
tsvnstat = pkgs.buildGoModule {
|
||||||
pname = "tsvnstat";
|
pname = "tsvnstat";
|
||||||
version = "v0.0.3";
|
version = "v0.0.4";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
vendorSha256 = "sha256-RNhu1gQ62Hg8Fhiw9uIS+b4YaAHtZMaqbelMKv+oZjM=";
|
vendorSha256 = "sha256-RNhu1gQ62Hg8Fhiw9uIS+b4YaAHtZMaqbelMKv+oZjM=";
|
||||||
|
25
main.go
25
main.go
@ -54,14 +54,16 @@ func main() {
|
|||||||
key := flag.String("key", "", "path to file containing the api key")
|
key := flag.String("key", "", "path to file containing the api key")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
keyData, err := os.ReadFile(*key)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
s := &tsnet.Server{
|
s := &tsnet.Server{
|
||||||
Hostname: *name,
|
Hostname: *name,
|
||||||
AuthKey: string(keyData),
|
}
|
||||||
|
|
||||||
|
if *key != "" {
|
||||||
|
keyData, err := os.ReadFile(*key)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
s.AuthKey = string(keyData)
|
||||||
}
|
}
|
||||||
|
|
||||||
ln, err := s.Listen("tcp", ":80")
|
ln, err := s.Listen("tcp", ":80")
|
||||||
@ -77,11 +79,12 @@ func main() {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
time.Sleep(10 * time.Second)
|
||||||
log.Printf("running %q in %q", tmpFile.Name(), tmpDir)
|
log.Printf("running %q in %q", tmpFile.Name(), tmpDir)
|
||||||
|
|
||||||
ifaces, err := net.Interfaces()
|
ifaces, err := net.Interfaces()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal("can't get interfaces...", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var ifNames []string
|
var ifNames []string
|
||||||
@ -93,10 +96,10 @@ func main() {
|
|||||||
genCmd.Dir = *dir
|
genCmd.Dir = *dir
|
||||||
out, err := genCmd.Output()
|
out, err := genCmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal("can't run generation script", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println(out)
|
log.Println(string(out))
|
||||||
|
|
||||||
time.Sleep(5 * time.Minute)
|
time.Sleep(5 * time.Minute)
|
||||||
}
|
}
|
||||||
@ -108,7 +111,7 @@ func main() {
|
|||||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
fileServer.ServeHTTP(w, r)
|
fileServer.ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
mux.HandleFunc("/index.html", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/index.html", func(w http.ResponseWriter, r *http.Request) {
|
||||||
images, err := os.ReadDir(*dir)
|
images, err := os.ReadDir(*dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
@ -146,7 +149,7 @@ func main() {
|
|||||||
fmt.Fprintf(w, "<img src=%q /><br />", in)
|
fmt.Fprintf(w, "<img src=%q /><br />", in)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
})
|
||||||
|
|
||||||
hs := &http.Server{
|
hs := &http.Server{
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
|
Loading…
Reference in New Issue
Block a user