# NanoMQ Configuration 0.14.0

# #============================================================
# # NanoMQ Broker
# #============================================================

system {
	# # daemon
	# # Run the NanoMQ broker in a daemon mode
	# #
	# # Value: true | false
	daemon = false
	
	# # num_taskq_thread
	# # Use a specified number of taskq threads 
	# #
	# # Value: 1-255, Obtain automatically if 0
	num_taskq_thread = 0
	
	# # max_taskq_thread
	# # Use a specified maximunm number of taskq threads
	# #
	# # Value: 1-255, Obtain automatically if 0
	max_taskq_thread = 0
	
	# # parallel
	# # Handle a specified maximum number of outstanding requests
	# #
	# # Value: 1-255, Obtain automatically if 0
	parallel = 0

	## enable internal IPC server
	## allow IPC server
	##
	## This is for CMD parsing & Gateway/Plugins control
	## Value: true | false
	enable_ipc_internal=true
}

mqtt.session {
	# # Property_size
	# # The max size for a MQTT user property
	# #
	# # Hot updatable
	# # Value: 1-infinity
	property_size = 32
	
	# # The max packet size of NanoMQ (Kbytes)
	# # Defines the max size of a packet that NanoMQ could accept
	# #
	# # Hot updatable
	# # Value: 1 Byte-260 Mb
	max_packet_size = 1024
	
	# # The default max packet size of each client (Kbytes)
	# # Defines the default max size limit of sending packet to each client
	# # Will be overwrite if client set its own max size limit
	# #
	# # Hot updatable
	# # Value: 1 Byte-260 Mb
	client_max_packet_size = 1024
	
	# # msq_len
	# # The queue length in-flight window
	# # This is essential for performance and memory consumption
	# #
	# # Hot updatable
	# # Value: 1-infinity
	msq_len = 2048
	
	# # qos_duration (s)
	# # The nano qos duration which also controls timer interval of each pipe
	# #
	# # Hot updatable
	# # Value: 1-infinity
	qos_duration = 10s
	
	# # The backoff for MQTT keepalive timeout.
	# # broker will discolse client when there is no activity for
	# # 'Keepalive * backoff * timeout.
	# #
	# # Hot updatable
	# # Value: Float > 0.5
	keepalive_backoff = 1250
	
	# # anonymous
	# # allow anonymous login
	# #
	# # Hot updatable
	# # Value: true | false
	allow_anonymous = true
	
	
}

listeners.tcp {
	# # enable tcp
	# # 
	# # Value: true | false
	enable = true
	
	# # bind
	# # Connect with the host and port
	# #
	# # Value: host:port
	bind = "0.0.0.0:1883"
}

# #============================================================
# # TLS/SSL
# #============================================================

listeners.ssl {
	# # enable tls
	# # 
	# # Value: true | false
	enable = false
	
	# # tls url
	# #
	# # Value: "host:port"
	bind = "0.0.0.0:8883"
	
	# # tls key password
	# # String containing the user's password. Only used if the private keyfile
	# # is password-protected.
	# #
	# # Value: String
	# key_password="yourpass"
	
	# # tls keyfile
	# # Path to the file containing the user's private PEM-encoded key.
	# #
	# # Value: File
	keyfile = "/etc/certs/key.pem"
	
	# # tls cert file
	# # Path to a file containing the user certificate.
	# #
	# # Value: File
	certfile = "/etc/certs/cert.pem"
	
	# # tls ca cert file
	# # Path to the file containing PEM-encoded CA certificates. The CA certificates
	# # are used during server authentication and when building the client certificate chain.
	# #
	# # Value: File
	cacertfile = "/etc/certs/cacert.pem"
	
	# # A server only does x509-path validation in mode verify_peer,
	# # as it then sends a certificate request to the client (this
	# # message is not sent if the verify option is verify_none).
	# # You can then also want to specify option fail_if_no_peer_cert.
	# #
	# # Value: true: verify_peer | false: verify_none
	verify_peer = false
	
	# # Used together with {verify, verify_peer} by an SSL server. If set to true,
	# # the server fails if the client does not have a certificate to send, that is,
	# # sends an empty certificate.
	# #
	# # Value: true | false
	fail_if_no_peer_cert = false
}

# #============================================================
# # WebSocket
# #============================================================
listeners.ws {
	# # allow websocket
	# #
	# # Value: true | false
	enable = true
	
	# # websocket url
	# #
	# # Value: "host:port/path"
	bind = "0.0.0.0:8083/mqtt"
}


# # -------------------- SQLite Config -------------------- ##
sqlite {
	# # Enable sqlite cache
	# # Whether to enable sqlite
	# #
	# # Value: boolean
	enable = false,
	# # Max message limitation for caching
	# # ( 0 means ineffective )
	# # Value: 1-infinity
	disk_cache_size = 102400
	# # Mounted file path 
	# #
	# # Value: path
	# mounted_file_path="/tmp/"
	
	# # The threshold of flushing messages to flash. 
	# #
	# # Hot updatable
	# # Value: 1-infinity
	flush_mem_threshold = 100
	
	# # Resend interval (ms)
	# # The interval for resending the messages after failure recovered. (not related to trigger)
	# # 
	# # Value: 1-infinity 
	resend_interval = 5000
}

# #============================================================
# # Http server
# #============================================================
http_server {
	# # allow http server
	# #
	# # Value: true | false
	enable = false
	# # http server port
	# #
	# # Value: 0 - 65535
	port = 8081
	# # parallel for http server
	# # Handle a specified maximum number of outstanding requests
	# #
	# # Value: 1-infinity
	parallel = 32
	# # http server username
	# #
	# # Value: String
	username = admin
	# # http server password
	# #
	# # Value: String
	password = public
	# # http server auth type
	# # If set auth_type=jwt, make sure you have built JWT dependency with `-DENABLE_JWT=ON` first.
	# #
	# # Value: String basic | jwt
	auth_type = basic
	jwt {
		# # http server jwt public key file
		# # Used together with 'http_server.auth_type=jwt',
		# # Path to the file containing the user's private key.
		# #
		# # Value: File
		public.keyfile = "/etc/certs/jwt/jwtRS256.key.pub"
		# # http server jwt private key file
		# # Used together with 'http_server.auth_type=jwt',
		# # Path to the file containing the user's publick key.
		# #
		# # Value: File
		private.keyfile = "/etc/certs/jwt/jwtRS256.key"
	}
}

# # ------------------ Logging Config ------------------ ##
log {
	# # Where to emit the logs.
	# #
	# # - file: write logs to file
	# # - console: write logs to standard I/O
	# # - syslog: write logs to syslog
	# # Value: file | console | syslog
	# # Example: file,console,syslog
	to = [file, console]
	# # The log severity level.
	# #
	# # Value: trace | debug | info | warn | error | fatal
	# #
	# # Note: Only the messages with severity level higher than or equal to
	# #       this level will be logged.
	# #
	# # Default: warn
	level = warn
	# # The dir for log files.
	# #
	# # Value: Folder
	dir = "/tmp"
	# # The log filename for logs of level specified in "log.level".
	# #
	# # Value: String
	# # Default: nanomq.log
	file = "nanomq.log"
	rotation {
		# # Maximum size of each log file.
		# #
		# # Value: Number
		# # Default: 10M
		# # Supported Unit: KB | MB | GB
		size = 10MB
		# # Maximum rotation count of log files.
		# #
		# # Value: Number
		# # Default: 5
		count = 5
	}
}

# #============================================================
# # WebHook
# #============================================================

# webhook {
# ## Enable web hook
# ##
# ## Value: boolean
# enable=false
# ## Webhook URL
# ##
# ## Value: String
# url="http://127.0.0.1:80"
# ## HTTP Headers
# ##
# ## Example:
# ## 1. web.hook.headers.content-type="application/json"
# ## 2. web.hook.headers.accept="*"
# ##
# ## Value: String
# headers.content-type="application/json"
# ## The encoding format of the payload field in the HTTP body
# ## The payload field only appears in the on_message_publish and on_message_delivered actions
# ##
# ## Value: plain | base64 | base62
# body.encoding="plain"
# ## Connection process pool size
# ##
# ## Value: Number
# pool_size=32
# 
# # Unsupport now
# # tls {
# # 	keyfile="/etc/certs/key.pem"
# # 	certfile="/etc/certs/cert.pem"
# # 	cacertfile="/etc/certs/cacert.pem"
# # }
# 
# }

# # Hook Rules
# # These configuration items represent a list of events should be forwarded
# #
# # Format:
# #  webhook.rule.<HookName>=<Spec>
webhook.rule.client.connect = [{action: on_client_connect}]
webhook.rule.client.connack = [{action: on_client_connack}]
webhook.rule.client.connected = [{action: on_client_connected}]
webhook.rule.client.disconnected = [{action: on_client_disconnected}]
webhook.rule.client.subscribe = [{action: on_client_subscribe}]
webhook.rule.client.unsubscribe = [{action: on_client_unsubscribe}]
webhook.rule.session.subscribed = [{action: on_session_subscribed}]
webhook.rule.session.unsubscribed = [{action: on_session_unsubscribed}]
webhook.rule.session.terminated = [{action: on_session_terminated}]
webhook.rule.message.publish = [{action: on_message_publish}]
webhook.rule.message.delivered = [{action: on_message_delivered}]
webhook.rule.message.acked = [{action: on_message_acked}]


authorization {
	## Allow or deny if no ACL rules matched.
	##
	## Value: allow | deny
	no_match = allow
	
	## The action when acl check reject current operation
	##
	## Value: ignore | disconnect
	## Default: ignore
	deny_action = ignore

	cache = {
		## Whether to enable ACL cache.
		##
		## If enabled, ACLs roles for each client will be cached in the memory
		##
		## Value: on | off
		enable = false

		## The maximum count of ACL entries can be cached for a client.
		##
		## Value: Integer greater than 0
		## Default: 32
		max_size = 32

		## The time after which an ACL cache entry will be deleted
		##
		## Value: Duration
		## Default: 1 minute
		ttl = 1m
	}

	sources = [
		{
			type = simple
			enable = false

			users = [
				{
					username = "admin"
					password = "public"
				}
				{
					username = "client"
					password = "public"
				}
			]
		},
		{
			type = file
			enable = false

			rules = [
				## Allow MQTT client using username "dashboard"  to subscribe to "$SYS/#" topics
				{"permit": "allow", "username": "dashboard", "action": "subscribe", "topics": ["$SYS/#"]}

				## Deny "All Users" subscribe to "$SYS/#" "#" Topics
				{"permit": "deny", "username": "#", "action": "subscribe", "topics": ["$SYS/#", "#"]}

				## Allow any other publish/subscribe operation
				{"permit": "allow"}
			]
		},
		{
			type = http
			# # Enable Authentication/ACL with HTTP API
			# #
			# # Value: true | false
			enable = false
			auth_req {
				# # HTTP URL API path for Auth Request
				# #
				# # Value: URL
				# #
				# # Examples: http://127.0.0.1:80/mqtt/auth, https://[::1]:80/mqtt/auth
				url = "http://127.0.0.1:80/mqtt/auth"
				# # HTTP Request Method for Auth Request
				# #
				# # Value: post | get
				method = post
				# # HTTP Request Headers for Auth Request, Content-Type header is configured by default.
				# # The possible values of the Content-Type header: application/x-www-form-urlencoded, application/json
				# #
				# # Examples: auth.http.auth_req.headers.accept = */*
				headers.content-type = "application/x-www-form-urlencoded"
				# # Parameters used to construct the request body or query string parameters
				# # When the request method is GET, these parameters will be converted into query string parameters
				# # When the request method is POST, the final format is determined by content-type
				# #
				# # Available Variables:
				# #  - %u: username
				# #  - %c: clientid
				# #  - %a: ipaddress
				# #  - %r: protocol
				# #  - %P: password
				# #  - %p: sockport of server accepted
				# #  - %C: common name of client TLS cert
				# #  - %d: subject of client TLS cert
				# #
				# # Value: <K1>=<V1>,<K2>=<V2>,...
				params = {clientid = "%c", username = "%u", password = "%p"}
				# Unsupport now
				# tls {
				# keyfile="/etc/certs/key.pem"
				# certfile="/etc/certs/cert.pem"
				# cacertfile="/etc/certs/cacert.pem"
				# }
			}
			
			super_req {
				url = "http://127.0.0.1:80/mqtt/superuser"
				method = "post"
				headers.content-type = "application/x-www-form-urlencoded"
				params = {clientid = "%c", username = "%u", password = "%p"}
				# Unsupport now
				# tls {
				# keyfile="/etc/certs/key.pem"
				# certfile="/etc/certs/cert.pem"
				# cacertfile="/etc/certs/cacert.pem"
				# }
				
			}
			## HTTP ACL request is unsupported.
			acl_req {
				url = "http://127.0.0.1:8991/mqtt/acl"
				method = "post"
				headers.content-type = "application/x-www-form-urlencoded"
				params = {clientid = "%c", username = "%u", access = "%A", ipaddr = "%a", topic = "%t", mountpoint = "%m"}
				# Unsupport now
				# tls {
				# keyfile="/etc/certs/key.pem"
				# certfile="/etc/certs/cert.pem"
				# cacertfile="/etc/certs/cacert.pem"
				# }
				
			}
			
			# # HTTP URL API path for SuperUser Request
			# #
			# # Value: URL
			# #
			# # Examples: http://127.0.0.1:80/mqtt/superuser, https://[::1]:80/mqtt/superuser
			# auth.http.super_req.url = http://127.0.0.1:80/mqtt/superuser
			
			# # Time-out time for the request.
			# #
			# # Value: Duration
			# # -h: hour, e.g. '2h' for 2 hours
			# # -m: minute, e.g. '5m' for 5 minutes
			# # -s: second, e.g. '30s' for 30 seconds
			# #
			# # Default: 5s
			timeout = 5s
			# # Connection time-out time, used during the initial request,
			# # when the client is connecting to the server.
			# #
			# # Value: Duration
			# # -h: hour, e.g. '2h' for 2 hours
			# # -m: minute, e.g. '5m' for 5 minutes
			# # -s: second, e.g. '30s' for 30 seconds
			# #
			# # Default: 5s
			connect_timeout = 5s
			# # Connection process pool size
			# #
			# # Value: Number
			pool_size = 32	
		}
	]
}

# #====================================================================
# # MQTT Broker Bridge
# #====================================================================
bridges.mqtt {
	nodes = [
		{
			# # Bridge node name.
			# #
			# # This is a bridge node name.
			# #
			# # Value: String
			name = emqx
			# # Whether to enable bridge mode for mqtt bridge
			# #
			# # This option is prepared for the mqtt broker which does not
			# # support bridge_mode such as the mqtt-plugin of the rabbitmq
			# #
			# # Value: boolean
			enable = true
			connector {
				# # Bridge address: host:port .
				# #
				# # Value: String
				# # Example: mqtt-tcp://127.0.0.1:1883
				# #          tls+mqtt-tcp://127.0.0.1:8883
				# #          mqtt-quic://54.75.171.11:14567
				
				server = "mqtt-tcp://127.0.0.1:1883"
				# # Protocol version of the bridge.
				# #
				# # Value: Enum
				# # - 5: mqttv5
				# # - 4: mqttv311
				# # - 3: mqttv31
				proto_ver = 4
				# # The ClientId of a remote bridge.
				# # Default random string.
				# #
				# # Value: String
				# clientid="bridge_client"
				
				# # Ping: interval of a downward bridge.
				# #
				# # Value: Duration
				# # Default: 10 seconds
				keepalive = 60s
				# # The Clean start flag of a remote bridge.
				# #
				# # Value: boolean
				# # Default: false
				# #
				# # NOTE: Some IoT platforms require clean_start
				# #       must be set to 'true'
				clean_start = false
				# # The username for a remote bridge.
				# #
				# # Value: String
				username = username
				# # The password for a remote bridge.
				# #
				# # Value: String
				password = passwd
				
				# # Properties for MQTT V5
				conn_properties = {
					# # Maximum Packet Size
					# #
					# # If the Maximum Packet Size is not present, no limit on the packet size is imposed beyond 
					# # the limitations in the protocol as a result of the remaining length encoding and the protocol header sizes.
					# # Value: 1 ~ 4294967295
					maximum_packet_size = 1024
					
					# # Receive Maximum
					# #
					# # The Client uses this value to limit the number of QoS 1 and QoS 2 publications that it is willing to process concurrently. 
					# # There is no mechanism to limit the QoS 0 publications that the Server might try to send.
					# # The value of Receive Maximum applies only to the current Network Connection. 
					# # If the Receive Maximum value is absent then its value defaults to 65,535.
					# #
					# # Value: 1 ~ 65535
					receive_maximum = 65535
					
					# # Topic Alias Maximum
					# #
					# # If the Topic Alias Maximum property is absent, the default value is 0.
					# # This value indicates the highest value that the Client will accept as a Topic Alias sent by the Server. 
					# # The Client uses this value to limit the number of Topic Aliases that it is willing to hold on this Connection.
					# # Default: 0
					# # Value: 0 ~ 65535
					topic_alias_maximum = 0
					
					# # Request Problem Information
					# #
					# # If the Request Problem Information is absent, the value of 1 is used.
					# # The Client uses this value to indicate whether the Reason String or User Properties are sent in the case of failures.
					# # If the value of Request Problem Information is 0, the Server MAY return a Reason String or User Properties on a CONNACK or DISCONNECT packet, 
					# # but MUST NOT send a Reason String or User Properties on any packet other than PUBLISH, CONNACK, or DISCONNECT. 
					# # If the value is 0 and the Client receives a Reason String or User Properties in a packet other than PUBLISH, CONNACK, or DISCONNECT, 
					# # it uses a DISCONNECT packet with Reason Code 0x82 (Protocol Error) as described in section 4.13 Handling errors.
					# # If this value is 1, the Server MAY return a Reason String or User Properties on any packet where it is allowed.
					# # 
					# # Default: 1
					# # Value: 0 | 1
					request_problem_infomation = 1
					
					# # Request Response Information
					# #
					# # If the Request Response Information is absent, the value of 0 is used.
					# # The Client uses this value to request the Server to return Response Information in the CONNACK. 
					# # A value of 0 indicates that the Server MUST NOT return Response Information. 
					# # If the value is 1 the Server MAY return Response Information in the CONNACK packet.
					# #
					# # Default: 0
					# # Value: 0 | 1
					request_response_infomation = 0
					
					# # Session Expiry Interval
					# #
					# # If the Session Expiry Interval is absent the value 0 is used. 
					# # If it is set to 0, or is absent, the Session ends when the Network Connection is closed.
					# # If the Session Expiry Interval is 4294967295 (UINT_MAX), the Session does not expire.
					# #
					# # Value: 0 ~ 4294967295
					session_expiry_interval = 0
					
					# # User Property
					# #
					# # The User Property is allowed to appear multiple times to represent multiple name, value pairs. 
					# # The same name is allowed to appear more than once.
					# # Value: Map[key(String) - value(String)]
					user_property = {
						key1 = value1
						key2 = value2
					}
				}
				
				# # Ssl config ##
				# # Ssl config is invalid when working in MQTT over QUIC mode ##
				ssl {
					# # enable ssl
					# # 
					# # Value: true | false
					enable = false
					# # Ssl key password
					# # String containing the user's password. Only used if the private keyfile
					# # is password-protected.
					# #
					# # Value: String
					key_password = "yourpass"
					# # Ssl keyfile
					# # Path of the file containing the client's private key.
					# #
					# # Value: File
					keyfile = "/etc/certs/key.pem"
					# # Ssl cert file
					# # Path of the file containing the client certificate.
					# #
					# # Value: File
					certfile = "/etc/certs/cert.pem"
					# # Ssl ca cert file
					# # Path of the file containing the server's root CA certificate.  
					# # 
					# # This certificate is used to identify the AWS IoT server and is publicly
					# # available.
					# #
					# # Value: File
					cacertfile = "/etc/certs/cacert.pem"
				}
			}
			
			# # Topics that need to be forward to IoTHUB
			# #
			# # Value: String
			# # Example: topic1/#,topic2/#
			forwards = ["topic1/#", "topic2/#"]
			
			# #--------------------------------------------------------------------
			# # The following config params only effective when set QUIC as the
			# # transport layer of bridging connection (mqtt-quic://{host}:{port})!
			# #  
			
			# # Ping: interval of a sending keepalive packet via QUIC transport.
			# #
			# # Value: Duration
			# # Default: 120 seconds
			quic_keepalive = 120s
			# # Idle Timeout: How long a connection can go idle before it is gracefully shut down.
			# #  0 to disable timeout, which may lost disconnect event msg.
			# # Value: Duration
			# # Default: 120 seconds
			quic_idle_timeout = 120s
			# # Disconnect Timeout: How long to wait for an ACK before declaring 
			# # a path dead and disconnecting, This affects stream living time.
			# # Value: Duration
			# # Default: 20 seconds
			quic_discon_timeout = 20s
			# # Handshake Timeout: the Max time NanoMQ waits for establishing QUIC connection
			# # How long a handshake can idle before it is discarded
			# # Value: Duration
			# # Default: 60 seconds
			quic_handshake_timeout = 60s
			# # Hybrid bridging: enable or disable the hybrid bridging mode
			# # Recommend to enable it when you want to take advantage of QUIC
			# # but not sure if the public network support QUIC.
			# # Value: True/False
			# # Default: False
			hybrid_bridging = false
			# # multi-stream mode: enable or disable the multi-stream bridging mode
			# # Warning: This is a feature WIP. Do not enable it!
			# # Value: True/False 
			# # Default: False
			quic_multi_stream = false

			## qos_priority: send QoS 1/2 msg in high prority
			## QoS 0 messages remain as same
			## Value: true/false
			## Default: true
			quic_qos_priority=true
			
			subscription = [
				{
					# # Need to subscribe to remote broker topics
					# #
					# # Value: String
					topic = "cmd/topic1"
					# # Need to subscribe to remote topics QoS.
					# # Please set QoS for each subscription topic
					# # otherwise topic is invalid, NanoMQ won't sub to any topic
					# # Value: Number
					qos = 1
				}
				{
					topic = "cmd/topic2"
					qos = 2
				}
			]

			// Properties of subscribe for MQTT V5
			sub_properties {
				# # Subscription Identifier
				# #
				# # The Subscription Identifier can have the value of 1 to 268,435,455.
				# # It is a Protocol Error if the Subscription Identifier has a value of 0. 
				# # It is a Protocol Error to include the Subscription Identifier more than once.
				# # The Subscription Identifier is associated with any subscription created or modified as the result of this SUBSCRIBE packet. 
				# # If there is a Subscription Identifier, it is stored with the subscription. 
				# # If this property is not specified, then the absence of a Subscription Identifier is stored with the subscription.
				# #
				# # Value: 1 ~ 268,435,455
				identifier = 1
				
				# # User Property
				# #
				# # The User Property is allowed to appear multiple times to represent multiple name, value pairs. 
				# # The same name is allowed to appear more than once.
				# # 
				# # Value: Map[key(String) - value(String)]
				user_property = {
					key1 = value1
					key2 = value2
				}
			}
			
			parallel = 2
			
			# # max send queue length
			# # Handle a specified maximum number of message send queue length
			# #
			# # Value: 1-infinity
			max_send_queue_len = 32
			
			# # max receive queue length
			# # Handle a specified maximum number of message receive queue length
			# #
			# # Value: 1-infinity
			max_recv_queue_len = 128
		}
	]
	sqlite {
		# # Enable sqlite cache
		# # Whether to enable sqlite
		# #
		# # Value: boolean
		enable = false
		# # Max message limitation for caching
		# # ( 0 means ineffective )
		# # Value: 1-infinity
		disk_cache_size = 102400
		# # Mounted file path 
		# #
		# # Value: path
		# mounted_file_path="/tmp/"
		
		# # The threshold of flushing messages to flash. 
		# #
		# # Value: 1-infinity
		flush_mem_threshold = 100
		
		# # Resend interval (ms)
		# # The interval for resending the messages after failure recovered. (not related to trigger)
		# # 
		# # Value: 1-infinity 
		resend_interval = 5000
	}

}

# #====================================================================
# # AWS IoT Core Bridge
# #====================================================================

bridges.aws.nodes = [
	{
		# # Bridge node name.
		# #
		# # This is a bridge node name.
		# #
		# # Value: String
		name = aws
		# # Whether to enable bridge mode for mqtt bridge
		# #
		# # This option is prepared for the mqtt broker which does not
		# # support bridge_mode such as the mqtt-plugin of the rabbitmq
		# #
		# # Value: boolean
		enable = false
		
		connector {
			# # Aws address: host:port .
			# #
			# # Value: String
			hosts = "127.0.0.1:8883"
			# # Protocol version of the bridge.
			# #
			# # Value: Enum
			# # - 5: mqttv5
			# # - 4: mqttv311
			proto_ver = 4
			# # The ClientId of a remote bridge.
			# # Default random string.
			# #
			# # Value: String
			clientid = "aws_bridge_client"
			# # Ping interval of a down bridge.
			# #
			# # Value: Duration
			# # Default: 10 seconds
			keepalive = 60s
			# # The Clean start flag of a remote bridge.
			# #
			# # Value: boolean
			# # Default: true
			# #
			# # NOTE: Some IoT platforms require clean_start
			# #       must be set to 'true'
			clean_start = true
			# # The username for a remote bridge.
			# #
			# # Value: String
			# username = "username"
			# # The password for a remote bridge.
			# #
			# # Value: String
			# password = "passwd"
			
			ssl {
				# # enable ssl
				# # 
				# # Value: true | false
				enable = false
				# # Ssl key password
				# # String containing the user's password. Only used if the private keyfile
				# # is password-protected.
				# #
				# # Value: String
				key_password = "yourpass"
				# # Ssl keyfile
				# # Path of the file containing the client's private key.
				# #
				# # Value: File
				keyfile = "/etc/certs/key.pem"
				# # Ssl cert file
				# # Path of the file containing the client certificate.
				# #
				# # Value: File
				certfile = "/etc/certs/cert.pem"
				# # Ssl ca cert file
				# # Path of the file containing the server's root CA certificate.  
				# # 
				# # This certificate is used to identify the AWS IoT server and is publicly
				# # available.
				# #
				# # Value: File
				cacertfile = "/etc/certs/cacert.pem"
			}
			
		}
		# # Topics that need to be forward to IoTHUB
		# #
		# # Value: String
		# # Example: topic1/#,topic2/#
		forwards = ["topic1/#", "topic2/#"]
		subscription = [
			{
				# # Need to subscribe to remote broker topics
				# #
				# # Value: String
				topic = "cmd/topic1"
				# # Need to subscribe to remote topics QoS.
				# #
				# # Value: Number
				qos = 1
			},
			{
				topic = "cmd/topic2"
				qos = 2
			}
		]
		# # parallel
		# # Handle a specified maximum number of outstanding requests
		# #
		# # Value: 1-infinity
		parallel = 2
		# # Ssl config ##
		# # Ssl config is invalid when working in MQTT over QUIC mode ##
	}
]


# #============================================================
# # MQTT Rule Engine
# #============================================================

# # Rule engine option, when persistence with 
# # rule engine, this option is must be ON.
# # 
# # Value: ON | OFF
rules.option = ON

rules.sqlite {
	# # Rule engine option SQLite3 database path
	# # Rule engine db path, default is exec path.
	# # 
	# # Value: File
	path = "/tmp/sqlite_rule.db"
	# # Rule engine option repub database enable status
	# # Rule engine db enable status.
	# # 
	# # Value: Boolen
	enable = true
	rules = [
		{
			# # Rule engine option repub database enable status
			# # Rule engine db enable status
			# # 
			# # Value: Boolen
			enable = true
			# # Rule engine option sql
			# # Rule engine sql clause.
			# # 
			# # Value: String
			sql = "SELECT payload.x.y as y, payload.z as z FROM \"#\" WHERE y > 10 and z != 'str'"
			# # Rule engine option SQLite3 database table name
			# # Rule engine db table name.
			# # 
			# # Value: String
			table = broker
		},
		{
			enable = true
			sql = "SELECT topic, payload FROM \"abc\""
			table = broker1
		}
	]
}

# #====================================================================
# # MQTT Rule Engine for Repub
# #====================================================================
rules.repub {
	# # Rule engine option repub database enable status
	# # Rule engine db enable status.
	# # 
	# # Value: Boolen
	enable = true
	rules = [
		{
			# # Rule engine option repub database enable status
			# # Rule engine db enable status.
			# # 
			# # Value: Boolen
			enable = true
			# # Repub address: host:port .
			# #
			# # Value: String
			# # Example: mqtt-tcp://127.0.0.1:1883
			address = "mqtt-tcp://localhost:1883"
			# # Repub topic .
			# #
			# # Value: String
			# # Example: topic/repub
			topic = "topic/repub1"
			# # Protocol version of the Repub.
			# #
			# # Value: Enum
			# # - 5: mqttv5
			# # - 4: mqttv311
			# # - 3: mqttv31
			proto_ver = 4
			# # The ClientId of a Repub client.
			# # Default random string.
			# #
			# # Value: String
			clientid = "repub_client1"
			# # Ping interval of a Repub client.
			# #
			# # Value: Duration
			# # Default: 60 seconds
			keepalive = 60s
			# # The Clean start flag of a Repub client.
			# #
			# # Value: boolean
			# # Default: true
			# #
			# # NOTE: Some IoT platforms require clean_start
			# #       must be set to 'true'
			clean_start = true
			# # The username for a Repub client.
			# #
			# # Value: String
			username = username
			# # The password for a Repub.
			# #
			# # Value: String
			password = passwd
			# # Rule engine option sql
			# # Rule engine sql clause.
			# # 
			# # Value: String
			sql = "SELECT payload.x.y as y, payload.z as z FROM \"#\" WHERE y > 10 and z != 'str'"
		},
		{
			enable = true
			server = "mqtt-tcp://localhost:1883"
			topic = "topic/repub2"
			proto_ver = 4
			clientid = "repub_client2"
			keepalive = 60s
			clean_start = true
			username = username
			password = passwd
			sql = "SELECT topic, payload FROM \"abc\""
		}
	]
}

# #====================================================================
# # MQTT Rule Engine for Mysql
# #====================================================================
rules.mysql {
	# # Rule engine option mysql database name
	# # Rule engine db path, default is exec path.
	# # 
	# # Value: File
	name = "mysql_rule_db"
	# # Rule engine option mysql database enable status
	# # Rule engine db enable status.
	# # 
	# # Value: Boolen
	enable = false
	rules = [
		{
			# # Rule engine option mysql database enable status
			# # Rule engine db enable status.
			# # 
			# # Value: Boolen
			enable = true
			# # Rule engine option mysql database table name
			# # Rule engine db table name.
			# # 
			# # Value: String
			table = broker
			# # The host for a mqsql client.
			# #
			# # Value: String
			host = localhost
			# # The username for a mqsql client.
			# #
			# # Value: String
			username = username
			# # The password for a mysql client.
			# #
			# # Value: String
			password = password
			# # Rule engine option sql
			# # Rule engine sql clause.
			# # 
			# # Value: String
			sql = "SELECT payload.x.y as y, payload.z as z FROM \"#\" WHERE y > 10 and z != 'str'"
		},
		{
			enable = true
			table = broker1
			host = localhost
			username = username
			password = password
			sql = "SELECT * FROM \"abc\""
		}
	]
}
