Skip to content

Commit

Permalink
Merge pull request #1 from evilpacket/master
Browse files Browse the repository at this point in the history
Add --root option for flexability
  • Loading branch information
tomsteele committed Nov 4, 2014
2 parents a7589e6 + ef49bb9 commit d34ce09
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
)

var dir *string
var root *string
var host *string
var port *string
var iport int
Expand All @@ -27,11 +28,12 @@ func init() {
host = flag.String("host", "localhost", "host for the file server to listen on")
port = flag.String("port", "9999", "port for the file server to listen on")
dir = flag.String("dir", "", "directory with code to scan")
root = flag.String("root", "", "root to serve from")
burpBuddyURL = flag.String("burpbuddy", "http://localhost:8001", "HTTP API URL for burpbuddy")
flag.Parse()

if *dir == "" {
log.Fatal("dir is required")
log.Fatal("--dir is required")
}

d, err := filepath.Abs(*dir)
Expand All @@ -45,13 +47,13 @@ func init() {
log.Fatalf("Error converting port to int: %s", err.Error())
}
count = 0
localURL = fmt.Sprintf("http://%s:%s", *host, *port)
localURL = fmt.Sprintf("http://%s:%s%s", *host, *port, *root)
}

func main() {

go func() {
log.Fatal(http.ListenAndServe(*host+":"+*port, http.FileServer(http.Dir(*dir))))
log.Fatal(http.ListenAndServe(*host+":"+*port, http.StripPrefix(*root + "/", http.FileServer(http.Dir(*dir)))))
}()

log.Printf("Static file server listening on %s, serving %s", localURL, *dir)
Expand Down

0 comments on commit d34ce09

Please sign in to comment.