From eeba082e905905bb22358631f59930a88d91c12a Mon Sep 17 00:00:00 2001 From: Dillinger Date: Sat, 21 Aug 2021 22:07:00 +0000 Subject: [PATCH] Update 'src/eros/eros.go' added clientside api functionality for exploit; my json code might get cucked by json-iterator tho --- src/eros/eros.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/eros/eros.go b/src/eros/eros.go index 45530d9..1aff672 100644 --- a/src/eros/eros.go +++ b/src/eros/eros.go @@ -23,13 +23,12 @@ import ( bluetooth "git.tcp.direct/kayos/prototooth" "github.com/prologic/bitcask" "github.com/rs/zerolog/log" - - structs "protomolecule/src/eros/structs" + + structs "protomolecule/src/eros/structs" "github.com/labstack/echo/middleware" "github.com/labstack/echo" - "net/http" "fmt" - + "net/http" ) var ( @@ -269,11 +268,11 @@ func Hypnosis(repo string) { // CORS e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ AllowOrigins: []string{"*"}, - AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE} //TODO: possibly trim the methods + AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE} //TODO: possibly trim the methods for security purposes })) // GET - e.GET("/exploits", func(c echo.Context) error { // This will definitely need to be updated + e.GET("/exploits", func(c echo.Context) error { // Build request req, err := http.NewRequest("GET", repo, nil) if err != nil { @@ -281,7 +280,7 @@ func Hypnosis(repo string) { } // Certificate sanity checks - caCert, err := os.Readfile("server.crt") + caCert, err := ioutil.Readfile("server.crt") if err != nil { log.Fatal(err) } @@ -314,7 +313,7 @@ func Hypnosis(repo string) { defer res.Body.Close() // Late binding data from JSON - var exp Exploit + var exp structs.Exploit // Decode JSON stream If err := json.NewDecoder(res.Body).Decode(&exp); err != nil { @@ -322,7 +321,9 @@ func Hypnosis(repo string) { } return c.JSON(http.StatusOK, exp) + }) + } // Trauma - store details of an exploit/attack against BLE devices @@ -381,4 +382,4 @@ func Flashback(Addr string) (Exploit, error) { json.Unmarshal(bytes, &member) return member, err -} \ No newline at end of file +}