diff --git a/emaild/Makefile b/emaild/Makefile index 28eca96..e66c826 100644 --- a/emaild/Makefile +++ b/emaild/Makefile @@ -3,7 +3,9 @@ all: go run alfonso.go -run: +# this is the raw socket server. it will +# show all socket connects recieved +raw-socket: go run server.go build: diff --git a/emaild/alfonso.go b/emaild/alfonso.go index d73eaa7..86a2635 100644 --- a/emaild/alfonso.go +++ b/emaild/alfonso.go @@ -13,6 +13,10 @@ func handler(w http.ResponseWriter, r *http.Request) { } func handler2(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") + w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization") + spew.Dump(r) fmt.Fprintf(w, "Hi there, handler2 %s!", r.URL.Path[1:]) @@ -30,9 +34,13 @@ func handler2(w http.ResponseWriter, r *http.Request) { case http.MethodDelete: // Remove the record. log.Printf("handler2 DELETE") + case http.MethodOptions: + // Remove the record. + log.Printf("handler2 OPTIONS") default: // Give an error message. - log.Printf("handler2 DEFAULT") + log.Printf("handler2 DEFAULT Method=", r.Method) + spew.Dump(r.Method) } } diff --git a/emaild/server.go b/emaild/server.go index 14da621..cd9d4c6 100644 --- a/emaild/server.go +++ b/emaild/server.go @@ -20,7 +20,7 @@ import "github.com/davecgh/go-spew/spew" const ( CONN_HOST = "localhost" - CONN_PORT = "3333" + CONN_PORT = "9000" CONN_TYPE = "tcp" ) @@ -38,20 +38,6 @@ func random() int { } func main() { -/* - // redirect all this output to systemd - dnssecsocket.UseJournalctl() - - hostname := fqdn.Get() - log.Println("FQDN hostname is", hostname) - - // lookup the IP address from DNS - dnsRR := dnssecsocket.Dnstrace(hostname, "AAAA") - spew.Dump(dnsRR) - ipaddr := dns.Field(dnsRR, 1) - log.Println("ipaddr", ipaddr) -*/ - listenstr := "[" + "localhost" + "]:" + CONN_PORT log.Println("listenstr", listenstr) @@ -103,6 +89,7 @@ func HandleConnection(conn *net.TCPConn) { log.Println("Waiting for the client to tell me its name") netData, err := newreader.ReadString('\n') spew.Dump(netData) + log.Println("netData =", string(netData)) if err != nil { log.Println(err) return @@ -124,14 +111,6 @@ func HandleConnection(conn *net.TCPConn) { } log.Println("Recieved: ", temp) - if (temp == "list") { - log.Println("Should run list here") - } - - if (temp == "cpuinfo") { - log.Println("Should cat /proc/cpuinfo") - } - result := strconv.Itoa(random()) + "\n" conn.Write([]byte(string(result))) return