diff options
| author | Jeff Carr <[email protected]> | 2025-03-10 03:12:09 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-10 07:59:25 -0500 |
| commit | fba2d24625d844b7f6115a6cb86f7fc6e1f9e3d5 (patch) | |
| tree | f1e787166b7a9f9d54c9551b9bf3db6d89fc1e46 /http.go | |
| parent | dfbb8090acaba51ab29368202e5c97fd18856558 (diff) | |
start making it work in the real world
Diffstat (limited to 'http.go')
| -rw-r--r-- | http.go | 25 |
1 files changed, 14 insertions, 11 deletions
@@ -23,7 +23,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) { log.Info("Got URL Path: ", r.URL.Path) route := cleanURL(r.URL.Path) - domname := r.URL.Query().Get("domain") + // domname := r.URL.Query().Get("domain") flag := r.URL.Query().Get("flag") msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte @@ -38,12 +38,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) { return } - // exit the virtigo daemon & have systemd restart it - // this can happen & when it does, access to - // to libvirtd will hang (aka: virsh list will hang) - // One way to trigger this is to not properly close - // domain sockets opened from go-qemu/hypervisor - // it's a good idea in any case so leave it here + // exit gus if route == "/kill" { log.Warn("KILLED") fmt.Fprintln(w, "KILLED") @@ -51,10 +46,18 @@ func okHandler(w http.ResponseWriter, r *http.Request) { return } - // curl http://localhost:2520/import?domain=foo.bar.com - if route == "/import" { - fmt.Fprint(w, "import domain:", domname) - + if route == "/list" { + all := me.portmaps.All() + for all.Scan() { + pm := all.Next() + if !pm.Enabled { + continue + } + s := fmt.Sprintf("portmap enabled for port %d to %s", pm.Listen, pm.Connect) + log.Info(s) + fmt.Fprintln(w, s) + } + startHTTP() return } |
