summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-26 21:02:05 -0500
committerJeff Carr <[email protected]>2024-10-26 21:02:05 -0500
commit65b61769117db371c4ec8fc0094d67b8c1075c1b (patch)
tree68fd264a6a64f714acab2ceae2d727cfcd631389
parentcedee6e88af2350130e0808a1af6d792e0bb98cc (diff)
dump unused junk
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--dumpClient.go150
-rw-r--r--http.go9
-rw-r--r--jsonClient.go108
-rw-r--r--start.go11
-rw-r--r--structs.go1
5 files changed, 4 insertions, 275 deletions
diff --git a/dumpClient.go b/dumpClient.go
deleted file mode 100644
index 6c5c1af..0000000
--- a/dumpClient.go
+++ /dev/null
@@ -1,150 +0,0 @@
-package main
-
-import (
- "fmt"
- "io/ioutil"
- "net/http"
- "os"
- "time"
-
- "go.wit.com/log"
-)
-
-func dumpClient(accessf, clientf *os.File, r *http.Request) {
- var host, url, proto, addr, agent string
-
- host = r.Host
- url = r.URL.String()
- proto = r.Proto
- addr = r.RemoteAddr
- agent = r.UserAgent()
-
- log.Warn(host, proto, addr, url, agent)
-
- fmt.Fprintln(accessf, time.Now(), host, proto, addr, url, agent)
- // return
-
- fmt.Fprintln(clientf)
- fmt.Fprintln(clientf, time.Now())
- // Basic request information
- fmt.Fprintln(clientf, "Method:", r.Method)
- fmt.Fprintln(clientf, "URL:", r.URL)
- fmt.Fprintln(clientf, "Protocol:", r.Proto)
- fmt.Fprintln(clientf, "Host:", r.Host)
- fmt.Fprintln(clientf, "Remote Address:", r.RemoteAddr)
-
- // Headers
- fmt.Fprintln(clientf, "Headers:")
- for name, values := range r.Header {
- for _, value := range values {
- fmt.Fprintln(clientf, "Headers:", name, value)
- }
- }
-
- // Query parameters
- fmt.Fprintln(clientf, "Query Parameters:")
- for param, values := range r.URL.Query() {
- for _, value := range values {
- fmt.Fprintln(clientf, "Query:", param, value)
- }
- }
-
- // User-Agent
- fmt.Fprintln(clientf, "User-Agent:", r.UserAgent())
-
- // Content Length
- fmt.Fprintln(clientf, "Content Length:", r.ContentLength)
-
- // Cookies
- fmt.Fprintln(clientf, "Cookies:")
- for _, cookie := range r.Cookies() {
- fmt.Fprintln(clientf, cookie.Name, cookie.Value)
- }
-
- // Request Body (if applicable)
- if r.Body != nil {
- body, err := ioutil.ReadAll(r.Body)
- if err == nil {
- fmt.Fprintln(clientf, "Body:", string(body))
- }
- }
-}
-
-func registerClient(f *os.File, r *http.Request) bool {
- var host, url, proto, addr, agent string
- var giturl, gopath string
-
- host = r.Host
- url = r.URL.String()
- proto = r.Proto
- addr = r.RemoteAddr
- agent = r.UserAgent()
-
- log.Warn(host, proto, addr, url, agent)
-
- fmt.Fprintln(f, time.Now(), host, proto, addr, url, agent)
- // return
-
- fmt.Fprintln(f)
- fmt.Fprintln(f, time.Now())
- // Basic request information
- fmt.Fprintln(f, "Method:", r.Method)
- fmt.Fprintln(f, "URL:", r.URL)
- fmt.Fprintln(f, "Protocol:", r.Proto)
- fmt.Fprintln(f, "Host:", r.Host)
- fmt.Fprintln(f, "Remote Address:", r.RemoteAddr)
-
- // Headers
- fmt.Fprintln(f, "Headers:")
- for name, values := range r.Header {
- for _, value := range values {
- fmt.Fprintln(f, "Headers:", name, value)
- if name == "Giturl" {
- giturl = value
- }
- if name == "Gopath" {
- gopath = value
- }
- // Giturl https://git.wit.org/gui/go-gui-toolkits.git
- // Headers: Gopath
- }
- }
-
- // Query parameters
- fmt.Fprintln(f, "Query Parameters:")
- for param, values := range r.URL.Query() {
- for _, value := range values {
- fmt.Fprintln(f, "Query:", param, value)
- }
- }
-
- // User-Agent
- fmt.Fprintln(f, "User-Agent:", r.UserAgent())
-
- // Content Length
- fmt.Fprintln(f, "Content Length:", r.ContentLength)
-
- // Cookies
- fmt.Fprintln(f, "Cookies:")
- for _, cookie := range r.Cookies() {
- fmt.Fprintln(f, cookie.Name, cookie.Value)
- }
-
- // Request Body (if applicable)
- if r.Body != nil {
- body, err := ioutil.ReadAll(r.Body)
- if err == nil {
- fmt.Fprintln(f, "Body:", string(body))
- }
- }
-
- fmt.Fprintln(f, "gopath =", gopath, "giturl =", giturl)
- if gopath == "" {
- return false
- }
- if giturl == "" {
- return false
- }
- fmt.Fprintln(f, "Sent back OK")
- return true
-}
diff --git a/http.go b/http.go
index a4144e2..741f949 100644
--- a/http.go
+++ b/http.go
@@ -38,15 +38,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "OK")
return
}
- if tmp == "/me" {
- j, err := dumpJsonClient(r)
- if err != nil {
- fmt.Fprintln(w, "BAD ZOOT")
- return
- }
- fmt.Fprintln(w, j)
- return
- }
// exit the virtigo daemon & have systemd restart it
// this can happen & when it does, access to
diff --git a/jsonClient.go b/jsonClient.go
deleted file mode 100644
index 4dc9b10..0000000
--- a/jsonClient.go
+++ /dev/null
@@ -1,108 +0,0 @@
-package main
-
-import (
- "bytes"
- "encoding/json"
- "io/ioutil"
- "net/http"
-)
-
-// RequestInfo holds the extracted data from http.Request
-type RequestInfo struct {
- Host string `json:"host"`
- URL string `json:"url"`
- Proto string `json:"proto"`
- Addr string `json:"addr"`
- Agent string `json:"agent"`
- Headers map[string][]string `json:"headers"`
- Cookies map[string]string `json:"cookies"`
- QueryParams map[string][]string `json:"queryParams"`
- // Add other fields as needed
- Body string `json:"body"`
-}
-
-// dumpClient returns a string with JSON formatted http.Request information
-func dumpJsonClient(r *http.Request) (string, error) {
- // Extracting Cookies
- cookieMap := make(map[string]string)
- for _, cookie := range r.Cookies() {
- cookieMap[cookie.Name] = cookie.Value
- }
-
- // Read the body (Ensure to do this first)
- var bodyBytes []byte
- if r.Body != nil { // Read the body if it's not nil
- bodyBytes, _ = ioutil.ReadAll(r.Body)
- r.Body.Close() // Close the body when done reading
- r.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes)) // Reset the body
- }
-
- info := RequestInfo{
- Host: r.Host,
- URL: r.URL.String(),
- Proto: r.Proto,
- Addr: r.RemoteAddr,
- Agent: r.UserAgent(),
- Headers: r.Header,
- Cookies: cookieMap,
- QueryParams: r.URL.Query(),
- Body: string(bodyBytes),
- }
-
- // Marshal the struct to a JSON string
- jsonString, err := json.Marshal(info)
- if err != nil {
- return "", err // Return the error to the caller
- }
-
- var jsonData interface{}
- err = json.Unmarshal([]byte(jsonString), &jsonData)
- if err != nil {
- return "", err // Return the error to the caller
- }
-
- formattedJSON, err := json.MarshalIndent(jsonData, "", " ")
- if err != nil {
- return "", err // Return the error to the caller
- }
-
- return string(formattedJSON), nil
-}
-
-/*
-package main
-
-import (
- "bytes"
- "encoding/json"
- "io"
- "io/ioutil"
- "net/http"
-)
-
-type RequestInfo struct {
- // ... (other fields)
- Body string `json:"body"`
- // ... (other fields)
-}
-
-func dumpClient(r *http.Request) (string, error) {
- // ... (rest of your code to collect other request info)
-
- info := RequestInfo{
- // ... (other fields)
- Body: string(bodyBytes),
- // ... (other fields)
- }
-
- // Marshal the struct to a JSON string
- jsonString, err := json.Marshal(info)
- if err != nil {
- return "", err
- }
-
- return string(jsonString), nil
-}
-
-// ... (rest of your code)
-*/
diff --git a/start.go b/start.go
index f7c1fbf..433e0ab 100644
--- a/start.go
+++ b/start.go
@@ -12,7 +12,6 @@ import (
)
func newStart(start string, d *pb.Droplet) error {
- // d := me.cluster.FindDroplet(start)
if d == nil {
log.Info("log.Info: droplet is unknown:", start)
return errors.New("droplet is unknown: " + start)
@@ -20,16 +19,14 @@ func newStart(start string, d *pb.Droplet) error {
log.Info("start droplet here:", d.Hostname)
domcfg := &libvirtxml.Domain{}
- newAddXml(domcfg, "standard.x86")
- // addDefaultXml(domcfg, "memory")
- // addDefaultXml(domcfg, "network")
- newAddXml(domcfg, "spice")
- newAddXml(domcfg, "qcow")
+ mergeXML(domcfg, "standard.x86")
+ mergeXML(domcfg, "spice")
+ mergeXML(domcfg, "qcow")
return virtigoxml.GenerateDropletXml(me.dirs, d, domcfg, start)
}
-func newAddXml(domcfg *libvirtxml.Domain, filename string) error {
+func mergeXML(domcfg *libvirtxml.Domain, filename string) error {
fullname := "resources/xml/" + filename + ".xml"
pfile, err := resources.ReadFile(fullname)
if err != nil {
diff --git a/structs.go b/structs.go
index a6e323a..99d4ee0 100644
--- a/structs.go
+++ b/structs.go
@@ -5,5 +5,4 @@ var me Virtigod
// this app's variables
type Virtigod struct {
dirs []string
- // cluster *virtbuf.Cluster
}