diff --git a/README.md b/README.md index 2c7ce72..ae1a59e 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,226 @@ VolantMQ ======= -[![Build Status](https://travis-ci.org/VolantMQ/volantmq.svg?branch=master)](https://travis-ci.org/VolantMQ/volantmq) -[![BCH compliance](https://bettercodehub.com/edge/badge/VolantMQ/volantmq?branch=master)](https://bettercodehub.com/) +[![CircleCI](https://circleci.com/gh/VolantMQ/volantmq/tree/master.svg?style=svg)](https://circleci.com/gh/VolantMQ/volantmq/tree/master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/1a43f2f6e0534fd180d0a1b0b8c93614)](https://www.codacy.com/app/VolantMQ/volantmq?utm_source=github.com&utm_medium=referral&utm_content=VolantMQ/volantmq&utm_campaign=Badge_Grade) [![codecov.io](https://codecov.io/gh/VolantMQ/volantmq/coverage.svg?branch=master)](https://codecov.io/gh/VolantMQ/volantmq?branch=master) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) - + ![VolantMQ image](doc/images/logo-2.svg) -*VolantMQ image by [Marina Troian ][rf], licensed under [Creative Commons 3.0 Attributions license][cc3-by].* +*VolantMQ image by **Marina Troian**, licensed under [Creative Commons Attribution 4.0 International License][cc-by] VolantMQ is a high performance MQTT broker that aims to be fully compliant with MQTT specs -###Features, Limitations, and Future +##Features +###MQTT Specs +- [MQTT v3.1 - V3.1.1](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html) full support +- [MQTT V5.0](http://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html) limited support. see details below + - [x] Properties + - [x] Publish expire + - [x] Session expire + - [ ] [Shared topics](https://github.com/VolantMQ/volantmq/issues/149) + - [x] Subscription id + - [x] Subscription options + - [ ] [Enhanced authentication](https://github.com/VolantMQ/volantmq/issues/150) + - [x] Topic alias + - [x] Server disconnect + - [x] Flow control + - [x] Maximum Packet Size + - [x] Server Keep Alive + - [x] Assigned ClientID -**Features** -* [MQTT v3.1 - V3.1.1](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html) -* [MQTT V5.0](http://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html) -* WebSockets transport -* SSL for both plain tcp and WebSockets transports -* Independent auth providers for each transport -* Persistence providers +### Network Transports +- [x] TCP +- [x] TLS +- [x] WebSocket +- [x] WebSocket+TLS -**Persistence providers** -* [BBolt](https://github.com/coreos/bbolt) -* In memory +### Persistence +By default server starts with in-memory persistence which means all sessions and messages lost after server restart. -###Compatibility -Project has been tested with the following client libraries -* Paho MQTT Conformance/Interoperability Testing Suite (in Python) - * Pass with all of the test cases -* Paho C Client library (in C) - * Pass with all of the test cases +### Plugins +#### Auth +- [x] Server built-in basic auth.Key-value pairs in format `user: sha256 of password` provided by any of the following options + - Users and their password hashes in config file + ```yaml + - name: internal # authenticator name, used by listeners + backend: simpleAuth # authenticator type + config: + users: + testuser: "9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05" # testpassword + ``` + - Users and their password hashes in separate file + ```yaml + - name: internal # authenticator name, used by listeners + backend: simpleAuth # authenticator type + config: + users: # both can be used simultaneously + testuser: "9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05" # testpassword + usersFile: + ``` + +- [x] [![Build status](https://gitlab.com/volantmq/vlplugin/auth/http/badges/master/pipeline.svg)](https://gitlab.com/volantmq/vlplugin/auth/http/commits/master) [HTTP](https://gitlab.com/volantmq/vlplugin/auth/http) +#### Monitoring +- [x] [![Build status](https://gitlab.com/volantmq/vlplugin/monitoring/systree/badges/master/pipeline.svg)](https://gitlab.com/volantmq/vlplugin/monitoring/systree/commits/master) [Systree](https://gitlab.com/volantmq/vlplugin/monitoring/systree) +- [x] [![Build status](https://gitlab.com/volantmq/vlplugin/monitoring/prometheus/badges/master/pipeline.svg)](https://gitlab.com/volantmq/vlplugin/monitoring/prometheus/commits/master) [Prometheus](https://gitlab.com/volantmq/vlplugin/monitoring/prometheus) + - [ ] [Grafana dashboard](https://github.com/VolantMQ/volantmq/issues/151) +#### Persistence +- [x] In-Memory server built in +- [x] [![Build status](https://gitlab.com/volantmq/vlplugin/persistence/bbolt/badges/master/pipeline.svg)](https://gitlab.com/volantmq/vlplugin/persistence/bbolt/commits/master) [BBolt](https://gitlab.com/volantmq/vlplugin/persistence/bbolt) +#### Debug +- [x] [![Build status](https://gitlab.com/volantmq/vlplugin/debug/badges/master/pipeline.svg)](https://gitlab.com/volantmq/vlplugin/debug/commits/master) [PProf](https://gitlab.com/volantmq/debug/bbolt) +#### Health +- [x] [![Build status](https://gitlab.com/volantmq/vlplugin/health/badges/master/pipeline.svg)](https://gitlab.com/volantmq/vlplugin/health/commits/master) [Health](https://gitlab.com/volantmq/health/bbolt) +## Configuring +Server starts with default config from [here](configuration/defaultConfig.go). Any further configurations applied on top + +### Environment variables +- `VOLANTMQ_CONFIG` - path to configuration file described in [this section](#Config file). +- `VOLANTMQ_PLUGIN_AUTH_HTTP__TOKEN` - API token for auth plugins + For example to supply auth token into auth plugin `http1` from config below variable should be declared as `VOLANTMQ_PLUGIN_AUTH_HTTP_HTTP1_TOKEN` + +### Config file +File divided in a few sections +Complete example can be found [here](examples/config.yaml) + +#### System +```yaml +system: + log: + console: + level: info # available levels: debug, info, warn, error, dpanic, panic, fatal + http: + defaultPort: 8080 # default HTTP listener assigned. Assigned to plugins like debug/health/metrics if they dont specify own port +``` +#### Plugins +```yaml +plugins: + enabled: # list of plugins server will load on startup + - systree + - prometheus + - debug + - health + - auth_http + - persistence_bbolt + config: # configuration of each plugin + : + - backed: systree # plugin name, allowed: systree, prometheus, http, prof.profiler, health, bbolt + name: http1 # required by auth plugins only. Value used in auth.order + config: # configuration passed to plugin on load stage. refer to particular plugin for configuration +``` +#### Default auth config +```yaml +auth: + anonymous: false # anonymous auth is prohibited. Listener can override + order: # default auth order. Authenticators invoked in the order they present in the config. Listener can override + - internal +``` +#### MQTT specs +```yaml +mqtt: + version: // list of supported MQTT specifications + - v3.1.1 + - v5.0 + keepAlive: + period: 60 # KeepAlive The number of seconds to keep the connection live if there's no data. + # Default is 60 seconds + force: false # Force connection to use server keep alive interval (MQTT 5.0 only) + # Default is false + options: + connectTimeout: 10 # The number of seconds to wait for the CONNACK message before disconnecting. + # If not set then default to 2 seconds. + offlineQoS0: true # OfflineQoS0 tell server to either persist (true) or not persist (false) QoS 0 messages for non-clean sessions + # If not set than default is false + sessionPreempt: true # AllowDuplicates Either allow or deny replacing of existing session if there new client with same clientID + # If not set than default is false + retainAvail: true # don't set to use default + subsOverlap: false # tells server how to handle overlapping subscriptions from within one client + # - true server will send only one publish with max subscribed QoS even there are n subscriptions + # - false server will send as many publishes as amount of subscriptions matching publish topic exists + # Default is false + subsId: false # don't set to use default + subsShared: false # don't set to use default + subsWildcard: true # don't set to use default + receiveMax: 65535 # don't set to use default + maxPacketSize: 268435455 # don't set to use default + maxTopicAlias: 65535 # don't set to use default + maxQoS: 2 +``` +#### Listeners +```yaml +listeners: + defaultAddr: "0.0.0.0" # default 127.0.0.1 + mqtt: # there are two types of listeners allowed tcp and ws (aka WebSocket) + tcp: + 1883: # port number. can be as many ports configurations as needed + host: 127.0.0.1 # optional. listen address. defaultAddr is used if omitted + auth: # optional. default auth configuration is used if omitted + anonymous: true # optional. default auth configuration is used if omitted + order: # optional. default auth configuration is used if omitted + - internal + 1884: + auth: + anonymous: false + order: + - http1 + tls: # TLS configuration + cert: # path to certificate file + key: # path to key file + ws: + 8883: + path: mqtt + auth: + order: + - http1 + 8884: + path: mqtt + auth: + order: + - http1 + tls: # TLS configuration + cert: # path to certificate file + key: # path to key file +``` + +Reason to have multiple listeners comes from performance impact of TLS as well as authentication +Internal to system users can omit entire auth and TLS +```text + ┌──────────────┐ + │ │ + │ MQTT process │ + │ │ + └───────▲──────┘ + │ + │ ╔════════════════════════╗ + │ ║ VolantMQ ║ + │ ║ ║ + ╔════▼═══╗ ║ ║ + ║intranet◀═════════▶ 1883 # no auth, no TLS║ + ╚════════╝ ║ ║ + ╔════════╗ ║ ║ + ║internet◀═════════▶ 1884 # auth and TLS ║ + ╚═▲══▲══▲╝ ║ ║ + │ │ │ ╚════════════════════════╝ + │ │ │ + ┌────┘ │ └───┐ + │ │ │ + │ │ │ + │ │ │ +┌──▼─┐ ┌──▼─┐ ┌─▼──┐ +│IoT1│ │IoT2│ │IoTn│ +└────┘ └────┘ └────┘ +``` + +## Distribution +- [x] [Docker](https://hub.docker.com/repository/docker/volantmq/volantmq) image contains prebuilt plugins listed in this [section][#Plugins] +- [ ] [Helm](https://github.com/VolantMQ/volantmq/issues/147) ###How to use -Best option is to run prebuilt docker image ```bash -docker run --rm -p 1883:1883 -p 8080:8080 -v $(pwd)/examples/config.yaml:/etc/volantmq/config.yaml --env VOLANTMQ_CONFIG=/etc/volantmq/config.yaml volantmq/volantmq +docker run --rm -p 1883:1883 -p 8080:8080 -v $(pwd)/examples/config.yaml:/etc/volantmq/config.yaml \ +--env VOLANTMQ_CONFIG=/etc/volantmq/config.yaml volantmq/volantmq ``` -####Whats inside - -- In example above port 1883 is mqtt listener with default user/password testuser/testpassword -- Port 8080 exposes healthcheck endpoints as well as pprof at http://localhost:8080/debug/pprof ### [Contributing guidelines](https://github.com/volantmq/volantmq/blob/master/CONTRIBUTING.md) diff --git a/cmd/volantmq/main.go b/cmd/volantmq/main.go index ff712fc..e6a7c8d 100644 --- a/cmd/volantmq/main.go +++ b/cmd/volantmq/main.go @@ -303,7 +303,7 @@ func (ctx *appContext) loadAuth(cfg *configuration.Config) (*auth.Manager, error if pl, kk := authPlugins[backend]; kk { // check if there is environment variable with API token for this particular plugin if backend == "http" { - varName := fmt.Sprintf("VOLANTMQ_PLUGIN_AUTH_%s_TOKEN", strings.ToUpper(name)) + varName := fmt.Sprintf("VOLANTMQ_PLUGIN_AUTH_HTTP_%s_TOKEN", strings.ToUpper(name)) var val string val, ok = os.LookupEnv(varName) if ok { diff --git a/configuration/configTypes.go b/configuration/configTypes.go index 9ac4fc8..da450d8 100644 --- a/configuration/configTypes.go +++ b/configuration/configTypes.go @@ -114,11 +114,7 @@ type PortConfig struct { // MqttConfig server config type MqttConfig struct { - Version []string `yaml:"version,omitempty"` - Systree struct { - Enabled bool `yaml:"enabled,omitempty"` - UpdateInterval int `yaml:"updateInterval,omitempty"` - } `yaml:"systree,omitempty"` + Version []string `yaml:"version,omitempty"` KeepAlive struct { Period int `yaml:"period,omitempty"` Force bool `yaml:"force,omitempty"` diff --git a/configuration/defaultConfig.go b/configuration/defaultConfig.go index 439cf9f..5c7d641 100644 --- a/configuration/defaultConfig.go +++ b/configuration/defaultConfig.go @@ -30,9 +30,6 @@ mqtt: keepAlive: period: 60 force: false - systree: - enabled: true - updateInterval: 10 options: connectTimeout: 2 offlineQoS0: true diff --git a/doc/listeners-ascii.monopic b/doc/listeners-ascii.monopic new file mode 100644 index 0000000..63da576 Binary files /dev/null and b/doc/listeners-ascii.monopic differ diff --git a/examples/config.yaml b/examples/config.yaml index 4bf0d26..9efeff3 100644 --- a/examples/config.yaml +++ b/examples/config.yaml @@ -65,11 +65,6 @@ mqtt: # Default is 60 seconds force: false # Force connection to use server keep alive interval (MQTT 5.0 only) # Default is false - systree: - enabled: true # Either systree available or not - # Default is false - updateInterval: 10 # Systree update interval - # Default is 10 seconds options: connectTimeout: 5 # The number of seconds to wait for the CONNECT message before disconnecting. # If not set then default to 2 seconds.