Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 25 additions & 3 deletions conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"path"
"time"

yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v2"

"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
Expand Down Expand Up @@ -106,6 +106,14 @@ type DNSSeed struct {
BPCount int `yaml:"BPCount"`
}

type MQTTBrokerInfo struct {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type MQTTBrokerInfo should have comment or be unexported

Addr string `yaml:"Addr"`
//if no user, use ThisNodeID
User string `yaml:"User,omitempty"`
Password string `yaml:"Password"`
IoTKeyfilePath string `yaml:"IoTKeyfilePath"`
}

// Config holds all the config read from yaml config file.
type Config struct {
UseTestMasterKey bool `yaml:"UseTestMasterKey,omitempty"` // when UseTestMasterKey use default empty masterKey
Expand All @@ -129,8 +137,9 @@ type Config struct {

DNSSeed DNSSeed `yaml:"DNSSeed"`

BP *BPInfo `yaml:"BlockProducer"`
Miner *MinerInfo `yaml:"Miner,omitempty"`
BP *BPInfo `yaml:"BlockProducer"`
Miner *MinerInfo `yaml:"Miner,omitempty"`
MQTTBroker *MQTTBrokerInfo `yaml:"MQTTBroker,omitempty"`

KnownNodes []proto.Node `yaml:"KnownNodes"`
SeedBPNodes []proto.Node `yaml:"-"`
Expand Down Expand Up @@ -182,6 +191,15 @@ func LoadConfig(configPath string) (config *Config, err error) {
config.DHTFileName = "dht.db"
}

if config.MQTTBroker != nil {
if config.MQTTBroker.User == "" {
config.MQTTBroker.User = string(config.ThisNodeID)
}
if config.MQTTBroker.IoTKeyfilePath == "" {
config.MQTTBroker.IoTKeyfilePath = "iot_private"
}
}

configDir := path.Dir(configPath)
if !path.IsAbs(config.PubKeyStoreFile) {
config.PubKeyStoreFile = path.Join(configDir, config.PubKeyStoreFile)
Expand All @@ -207,6 +225,10 @@ func LoadConfig(configPath string) (config *Config, err error) {
config.Miner.RootDir = path.Join(configDir, config.Miner.RootDir)
}

if config.MQTTBroker != nil && !path.IsAbs(config.MQTTBroker.IoTKeyfilePath) {
config.MQTTBroker.IoTKeyfilePath = path.Join(configDir, config.MQTTBroker.IoTKeyfilePath)
}

if len(config.KnownNodes) > 0 {
for _, node := range config.KnownNodes {
if node.ID == config.ThisNodeID {
Expand Down
4 changes: 4 additions & 0 deletions sqlchain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,10 @@ func (c *Chain) AddResponse(resp *types.SignedResponseHeader) (err error) {
return c.ai.addResponse(c.rt.getHeightFromTime(resp.GetRequestTimestamp()), resp)
}

func (c *Chain) GetPeerLeaderID() proto.NodeID {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported method Chain.GetPeerLeaderID should have comment or be unexported

return c.rt.peers.Leader
}

func (c *Chain) register(ack *types.SignedAckHeader) (err error) {
return c.ai.register(c.rt.getHeightFromTime(ack.GetRequestTimestamp()), ack)
}
Expand Down
31 changes: 31 additions & 0 deletions test/service/mqtt_broker/acl_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This affects access control for clients with no username.
#topic read $SYS/#

# This only affects clients with username "roger".
#user roger
#topic foo/bar
user 000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade
topic readwrite /cql/miner/000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade/#
topic read /cql/client/#

user 000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5
topic readwrite /cql/miner/000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5/#
topic read /cql/client/#

user 000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8
topic readwrite /cql/miner/000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8/#
topic read /cql/client/#

user client_test
topic readwrite /cql/client/client_test/#
topic readwrite /cql/client/client_test2/#
topic read /cql/miner/#

user client_test2
topic readwrite /cql/client/client_test2/#
topic read /cql/miner/#


# This affects all clients.
# pattern write $SYS/broker/connection/%c/state

Loading