forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combined frontend and velociraptor binaries.
Also embed static files in release binary for easy packaging.
- Loading branch information
Showing
16 changed files
with
176 additions
and
117 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// +build release | ||
|
||
// Build during release - embed all static assets in the binary. | ||
package api | ||
|
||
import ( | ||
"html/template" | ||
"net/http" | ||
"time" | ||
config "www.velocidex.com/golang/velociraptor/config" | ||
"www.velocidex.com/golang/velociraptor/gui/assets" | ||
) | ||
|
||
func install_mux(config_obj *config.Config, mux *http.ServeMux) { | ||
dir := "/static/" | ||
mux.Handle(dir, http.FileServer(static.HTTP)) | ||
} | ||
|
||
func GetTemplateHandler(config_obj *config.Config) (http.Handler, error) { | ||
data, err := static.ReadFile("/static/templates/index.html") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
tmpl, err := template.New("").Parse(string(data)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
args := _templateArgs{ | ||
Timestamp: time.Now().UTC().UnixNano() / 1000, | ||
Heading: "Heading", | ||
} | ||
err := tmpl.Execute(w, args) | ||
if err != nil { | ||
w.WriteHeader(500) | ||
} | ||
}), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// +build !release | ||
|
||
// Build during development (non release) - serve static assets | ||
// directly from filesystem. We assume we are run from the top level | ||
// directory using go run. e.g.: | ||
|
||
// go run bin/*.go frontend test_data/server.config.yaml | ||
package api | ||
|
||
import ( | ||
"html/template" | ||
"net/http" | ||
"time" | ||
config "www.velocidex.com/golang/velociraptor/config" | ||
"www.velocidex.com/golang/velociraptor/logging" | ||
) | ||
|
||
func install_mux(config_obj *config.Config, mux *http.ServeMux) { | ||
logging.NewLogger(config_obj).Info("Will serve files from directory gui/static") | ||
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer( | ||
http.Dir("gui/static")))) | ||
} | ||
|
||
func GetTemplateHandler(config_obj *config.Config) (http.Handler, error) { | ||
tmpl, err := template.ParseFiles("gui/static/templates/index.html") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
args := _templateArgs{ | ||
Timestamp: time.Now().UTC().UnixNano() / 1000, | ||
Heading: "Heading", | ||
} | ||
err := tmpl.Execute(w, args) | ||
if err != nil { | ||
w.WriteHeader(500) | ||
} | ||
}), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ab0x.go |
Oops, something went wrong.