diff --git a/README.md b/README.md index 9938f6b..9c3cd01 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,13 @@ A tool for testing xmpp servers load | Variable | Required | Default Value | Description | | ------------------------------------------------- | -------- | --------------------------------- | ---------------------------------------------- | -| **Service:** | -| OPENFIRE_PORT | NO | 5222 | Port for openfire server | -| OPENFIRE_ADRESS | YES | | Openfire server address | -| OPENFIRE_DOMAIN | YES | | Domain | -| | | **Credentials:** | | | | CREDENTIALS_FILE_LOCATION | NO | input.json | Database username | | | | **GeneralOptions:** | | | -| MASSAGE_DELAY | NO | 120000000000 - 2 mins | Delay for online presence message loop | -| STATUS_MASSAGE_DELAY | NO | 10 sec | Delay for online presence message loop | +| PRESENCE_STATUS_DELAY | NO | 120000000000 - 2 mins | Delay for online presence message loop | +| COMMAND_REPLY_DELAY | NO | 10 sec | Delay for online presence message loop | | | diff --git a/config/config.go b/config/config.go index 4af88c3..55b3a0f 100644 --- a/config/config.go +++ b/config/config.go @@ -9,16 +9,14 @@ func Load() { AppConfig = Config{ Service: Service{ - Port: getEnv("OPENFIRE_PORT", "5222"), - Address: mustGetEnv("OPENFIRE_ADRESS"), - Domain: mustGetEnv("OPENFIRE_DOMAIN"), + Port: getEnv("OPENFIRE_PORT", "5222"), }, Credentials: Credentials{ CredentialsFileLocation: getEnv("CREDENTIALS_FILE_LOCATION", "input.json"), }, GeneralOptions: GeneralOptions{ - DelayBetweenMassages: int64(getEnvInt("MASSAGE_DELAY", 120000000000)), - StatusMessageDelay: getEnvInt("STATUS_MASSAGE_DELAY", 10), + PresenceStatusDelay: int64(getEnvInt("PRESENCE_STATUS_DELAY", 2) * 60), + CommandReplyDelay: getEnvInt("COMMAND_REPLY_DELAY", 10), }, } } diff --git a/config/models.go b/config/models.go index 74c6d9e..b23de43 100644 --- a/config/models.go +++ b/config/models.go @@ -21,6 +21,6 @@ type Credentials struct { // GeneralOptions contains information for general configuration options type GeneralOptions struct { - DelayBetweenMassages int64 - StatusMessageDelay int + PresenceStatusDelay int64 + CommandReplyDelay int } diff --git a/go.mod b/go.mod index 7712de9..c19d7c4 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,10 @@ module github.com/xmpploadtesting go 1.17 +require gosrc.io/xmpp v0.5.1 + require ( github.com/google/uuid v1.1.1 // indirect golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 // indirect - gosrc.io/xmpp v0.5.1 // indirect nhooyr.io/websocket v1.6.5 // indirect ) diff --git a/main.go b/main.go index b6b89d0..f7cc2ac 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,7 @@ func main() { } // Delay before sending another message - time.Sleep(time.Duration(appConfig.AppConfig.GeneralOptions.DelayBetweenMassages)) + time.Sleep(time.Duration(appConfig.AppConfig.GeneralOptions.PresenceStatusDelay)) } diff --git a/services/xmppsService.go b/services/xmppsService.go index 997f61d..67a6b6c 100644 --- a/services/xmppsService.go +++ b/services/xmppsService.go @@ -211,10 +211,10 @@ func handleMessage(s xmpp.Sender, p stanza.Packet) { } log.Printf("<%v> received following message: %v", msg.To, msg.Body) - statusMesageDelay := int64(rand.Intn(appConfig.AppConfig.GeneralOptions.StatusMessageDelay)) - log.Printf("DELAYING FOR: %v", statusMesageDelay*1000000000) + commandReplyDelay := int64(rand.Intn(appConfig.AppConfig.GeneralOptions.CommandReplyDelay)) + log.Printf("Waiting FOR: %v", commandReplyDelay*1000000000) // Delay For two seccond to allow all clients to connect - time.Sleep(time.Duration(statusMesageDelay * 1000000000)) + time.Sleep(time.Duration(commandReplyDelay * 1000000000)) reply := stanza.Message{Attrs: stanza.Attrs{To: msg.From}, Body: `{"status": "OK"}`} err := s.Send(reply) diff --git a/xmpploadtesting b/xmpploadtesting new file mode 100755 index 0000000..1ad7a44 Binary files /dev/null and b/xmpploadtesting differ