Skip to content

Commit

Permalink
Add --port, --host flag in server mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Oct 5, 2020
1 parent 3ba3402 commit 055a68b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
17 changes: 7 additions & 10 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
"github.com/spf13/cobra"
)

var port int
var host string

// serverCmd represents the server command
var serverCmd = &cobra.Command{
Use: "server",
Expand All @@ -18,14 +21,8 @@ var serverCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(serverCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// serverCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// serverCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
serverCmd.Flags().IntVar(&port, "port", 6664, "Bind Port")
serverCmd.Flags().StringVar(&host, "host", "0.0.0.0", "Bind address")
options.ServerHost = host
options.ServerPort = port
}
2 changes: 2 additions & 0 deletions pkg/model/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type Options struct {
Method string
NoSpinner bool
NoBAV bool
ServerHost string
ServerPort int
}

// Scan is struct of scan
Expand Down
3 changes: 2 additions & 1 deletion pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"net/http"
"time"
"strconv"

"github.com/hahwul/dalfox/pkg/model"
printing "github.com/hahwul/dalfox/pkg/printing"
Expand All @@ -29,7 +30,7 @@ func RunAPIServer(options model.Options) {
var scans []string
e := echo.New()
options.IsAPI = true
e.Server.Addr = ":6664"
e.Server.Addr = options.ServerHost+":"+strconv.Itoa(options.ServerPort)
e.Use(middleware.SecureWithConfig(middleware.SecureConfig{
XSSProtection: "",
ContentTypeNosniff: "",
Expand Down

0 comments on commit 055a68b

Please sign in to comment.