|
@@ -35,7 +35,10 @@ var (
|
|
filter = flag.String("filter", "tcp", "PCAP filter expression")
|
|
filter = flag.String("filter", "tcp", "PCAP filter expression")
|
|
promiscuous = flag.Bool("promiscuous", false, "Switch interface into promiscuous mode?")
|
|
promiscuous = flag.Bool("promiscuous", false, "Switch interface into promiscuous mode?")
|
|
natsURL = flag.String("nats-url", "nats://127.0.0.1:4222", "The URL of the NATS server")
|
|
natsURL = flag.String("nats-url", "nats://127.0.0.1:4222", "The URL of the NATS server")
|
|
|
|
+ natsUser = flag.String("nats-user", "", "The user for NATS authentication")
|
|
|
|
+ natsPassword = flag.String("nats-password", "", "The password for NATS authentication")
|
|
natsQueue = flag.String("nats-queue", "requests", "The NATS queue name")
|
|
natsQueue = flag.String("nats-queue", "requests", "The NATS queue name")
|
|
|
|
+ natsCA = flag.String("nats-ca", "", "CA chain for NATS TLS")
|
|
sleepFor = flag.Duration("sleep", 0, "Sleep this long between sending data (only when replaying a file)")
|
|
sleepFor = flag.Duration("sleep", 0, "Sleep this long between sending data (only when replaying a file)")
|
|
requestsFile = flag.String("requests", "", "CSV file containing requests (IP and URL)")
|
|
requestsFile = flag.String("requests", "", "CSV file containing requests (IP and URL)")
|
|
protocol = flag.String("protocol", "http", "which protocol to parse: http or ajp13")
|
|
protocol = flag.String("protocol", "http", "which protocol to parse: http or ajp13")
|
|
@@ -69,6 +72,9 @@ type Config struct {
|
|
Promiscuous bool
|
|
Promiscuous bool
|
|
NatsURL string
|
|
NatsURL string
|
|
NatsQueue string
|
|
NatsQueue string
|
|
|
|
+ NatsUser string
|
|
|
|
+ NatsPassword string
|
|
|
|
+ NatsCA string
|
|
SleepFor duration
|
|
SleepFor duration
|
|
RequestsFile string
|
|
RequestsFile string
|
|
UseXForwardedAsSource bool
|
|
UseXForwardedAsSource bool
|
|
@@ -96,6 +102,9 @@ func (c Config) print() {
|
|
fmt.Printf("Promiscuous: %t\n", c.Promiscuous)
|
|
fmt.Printf("Promiscuous: %t\n", c.Promiscuous)
|
|
fmt.Printf("NatsURL: %s\n", c.NatsURL)
|
|
fmt.Printf("NatsURL: %s\n", c.NatsURL)
|
|
fmt.Printf("NatsQueue: %s\n", c.NatsQueue)
|
|
fmt.Printf("NatsQueue: %s\n", c.NatsQueue)
|
|
|
|
+ fmt.Printf("NatsUser: %s\n", c.NatsUser)
|
|
|
|
+ fmt.Printf("NatsPassword: %s\n", c.NatsPassword)
|
|
|
|
+ fmt.Printf("NatsCA: %s\n", c.NatsCA)
|
|
fmt.Printf("SleepFor: %s\n", c.SleepFor.String())
|
|
fmt.Printf("SleepFor: %s\n", c.SleepFor.String())
|
|
fmt.Printf("RequestsFile: %s\n", c.RequestsFile)
|
|
fmt.Printf("RequestsFile: %s\n", c.RequestsFile)
|
|
fmt.Printf("Apache Log: %s\n", c.ApacheLog)
|
|
fmt.Printf("Apache Log: %s\n", c.ApacheLog)
|
|
@@ -136,7 +145,14 @@ func main() {
|
|
log.Fatal("No NATS URL specified (-nats-url)!")
|
|
log.Fatal("No NATS URL specified (-nats-url)!")
|
|
}
|
|
}
|
|
|
|
|
|
- natsConn, err := nats.Connect(config.NatsURL)
|
|
|
|
|
|
+ var natsConn *nats.Conn
|
|
|
|
+ var err error
|
|
|
|
+
|
|
|
|
+ if config.NatsUser != "" && config.NatsPassword != "" && config.NatsCA != "" {
|
|
|
|
+ natsConn, err = nats.Connect(config.NatsURL, nats.UserInfo(config.NatsUser, config.NatsPassword), nats.RootCAs(config.NatsCA))
|
|
|
|
+ } else {
|
|
|
|
+ natsConn, err = nats.Connect(config.NatsURL)
|
|
|
|
+ }
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
@@ -541,6 +557,9 @@ func loadConfig() {
|
|
config.Promiscuous = *promiscuous
|
|
config.Promiscuous = *promiscuous
|
|
config.NatsURL = *natsURL
|
|
config.NatsURL = *natsURL
|
|
config.NatsQueue = *natsQueue
|
|
config.NatsQueue = *natsQueue
|
|
|
|
+ config.NatsUser = *natsUser
|
|
|
|
+ config.NatsPassword = *natsPassword
|
|
|
|
+ config.NatsCA = *natsCA
|
|
config.SleepFor.Duration = *sleepFor
|
|
config.SleepFor.Duration = *sleepFor
|
|
config.RequestsFile = *requestsFile
|
|
config.RequestsFile = *requestsFile
|
|
config.UseXForwardedAsSource = *useXForwardedAsSource
|
|
config.UseXForwardedAsSource = *useXForwardedAsSource
|