diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2025-12-29 12:40:18 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2025-12-29 13:30:44 +0000 |
| commit | 1b9f64757a7358e28cc89893899f4016d8d7b223 (patch) | |
| tree | 7f26171994d695bac8252ed6ad922de250e2aa0b /syz-hub | |
| parent | 4e5820c0c41b0c979471b66497f055f5631dfd65 (diff) | |
pkg/tool: add ServeHTTP function
Dedup code in syz-ci and syz-hub.
Diffstat (limited to 'syz-hub')
| -rw-r--r-- | syz-hub/http.go | 15 | ||||
| -rw-r--r-- | syz-hub/hub.go | 5 |
2 files changed, 4 insertions, 16 deletions
diff --git a/syz-hub/http.go b/syz-hub/http.go index 14fa43f7f..46994ed2f 100644 --- a/syz-hub/http.go +++ b/syz-hub/http.go @@ -6,7 +6,6 @@ package main import ( "fmt" "html/template" - "net" "net/http" "sort" "strings" @@ -14,20 +13,6 @@ import ( "github.com/google/syzkaller/pkg/log" ) -func (hub *Hub) initHTTP(addr string) { - http.HandleFunc("/", hub.httpSummary) - - ln, err := net.Listen("tcp4", addr) - if err != nil { - log.Fatalf("failed to listen on %v: %v", addr, err) - } - log.Logf(0, "serving http on http://%v", ln.Addr()) - go func() { - err := http.Serve(ln, nil) - log.Fatalf("failed to serve http: %v", err) - }() -} - func (hub *Hub) httpSummary(w http.ResponseWriter, r *http.Request) { hub.mu.Lock() defer hub.mu.Unlock() diff --git a/syz-hub/hub.go b/syz-hub/hub.go index 4b7b61354..cbeb57b12 100644 --- a/syz-hub/hub.go +++ b/syz-hub/hub.go @@ -6,6 +6,7 @@ package main import ( "flag" "fmt" + "net/http" "strings" "sync" "time" @@ -14,6 +15,7 @@ import ( "github.com/google/syzkaller/pkg/config" "github.com/google/syzkaller/pkg/log" "github.com/google/syzkaller/pkg/rpctype" + "github.com/google/syzkaller/pkg/tool" "github.com/google/syzkaller/syz-hub/state" ) @@ -59,7 +61,8 @@ func main() { hub.keys[mgr.Name] = mgr.Key } - hub.initHTTP(cfg.HTTP) + http.HandleFunc("/", hub.httpSummary) + tool.ServeHTTP(cfg.HTTP) go hub.purgeOldManagers() s, err := rpctype.NewRPCServer(cfg.RPC, "Hub", hub) |
