1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

added nkey seed

This commit is contained in:
postmannen 2021-05-20 12:27:25 +02:00
parent 4ba3a599a4
commit 91ac5da4d6
7 changed files with 24 additions and 60 deletions

2
.gitignore vendored
View file

@ -1,5 +1,7 @@
ship1/
ship2/
ship3/
central/
tmp/
var/
./incommmingBuffer.db

View file

@ -264,7 +264,7 @@ func (c *Configuration) WriteConfigFile() error {
if _, err := os.Stat(c.ConfigFolder); os.IsNotExist(err) {
err := os.MkdirAll(c.ConfigFolder, 0700)
if err != nil {
return fmt.Errorf("error: failed to create directory %v: %v", c.ConfigFolder, err)
return fmt.Errorf("error: failed to create config directory %v: %v", c.ConfigFolder, err)
}
}

View file

@ -1,54 +0,0 @@
BrokerAddress = "127.0.0.1:4222"
CentralNodeName = "central"
ConfigFolder = "./etc"
DefaultMessageRetries = 3
DefaultMessageTimeout = 5
NodeName = "central"
ProfilingPort = ""
PromHostAndPort = ":2112"
StartPubREQHello = 0
SubscribersDataFolder = "./var"
[StartSubREQCliCommand]
OK = true
Values = ["*"]
[StartSubREQErrorLog]
OK = true
Values = ["*"]
[StartSubREQHello]
OK = true
Values = ["*"]
[StartSubREQHttpGet]
OK = true
Values = ["*"]
[StartSubREQPing]
OK = true
Values = ["*"]
[StartSubREQPong]
OK = true
Values = ["*"]
[StartSubREQTailFile]
OK = false
Values = []
[StartSubREQToConsole]
OK = true
Values = ["*"]
[StartSubREQToFile]
OK = true
Values = ["*"]
[StartSubREQToFileAppend]
OK = true
Values = ["*"]
[StartSubREQnCliCommand]
OK = true
Values = ["*"]

View file

Binary file not shown.

View file

@ -86,6 +86,22 @@ func NewServer(c *Configuration) (*server, error) {
opt = nats.RootCAs(c.RootCAPath)
}
if c.NkeySeedFile != "" {
var err error
// fh, err := os.Open(c.NkeySeedFile)
// if err != nil {
// return nil, fmt.Errorf("error: failed to open nkey seed file: %v\n", err)
// }
// b, err := io.ReadAll(fh)
// if err != nil {
// return nil, fmt.Errorf("error: failed to read nkey seed file: %v\n", err)
// }
opt, err = nats.NkeyOptionFromSeed(c.NkeySeedFile)
if err != nil {
return nil, fmt.Errorf("error: failed to read nkey seed file: %v", err)
}
}
conn, err := nats.Connect(c.BrokerAddress, opt)
if err != nil {
er := fmt.Errorf("error: nats.Connect failed: %v", err)
@ -98,7 +114,7 @@ func NewServer(c *Configuration) (*server, error) {
if _, err := os.Stat(c.SocketFolder); os.IsNotExist(err) {
err := os.MkdirAll(c.SocketFolder, 0700)
if err != nil {
return nil, fmt.Errorf("error: failed to create directory %v: %v", c.SocketFolder, err)
return nil, fmt.Errorf("error: failed to create socket folder directory %v: %v", c.SocketFolder, err)
}
}
@ -138,7 +154,7 @@ func NewServer(c *Configuration) (*server, error) {
}
err := os.Mkdir(c.SubscribersDataFolder, 0700)
if err != nil {
return nil, fmt.Errorf("error: failed to create directory %v: %v", c.SubscribersDataFolder, err)
return nil, fmt.Errorf("error: failed to create data folder directory %v: %v", c.SubscribersDataFolder, err)
}
log.Printf("info: Creating subscribers data folder at %v\n", c.SubscribersDataFolder)

View file

@ -457,7 +457,7 @@ func (m methodREQToFileAppend) handler(proc process, message Message, node strin
if _, err := os.Stat(folderTree); os.IsNotExist(err) {
err := os.MkdirAll(folderTree, 0700)
if err != nil {
return nil, fmt.Errorf("error: failed to create directory %v: %v", folderTree, err)
return nil, fmt.Errorf("error: failed to create toFileAppend directory tree %v: %v", folderTree, err)
}
log.Printf("info: Creating subscribers data folder at %v\n", folderTree)
@ -518,7 +518,7 @@ func (m methodREQToFile) handler(proc process, message Message, node string) ([]
if _, err := os.Stat(folderTree); os.IsNotExist(err) {
err := os.MkdirAll(folderTree, 0700)
if err != nil {
return nil, fmt.Errorf("error: failed to create directory %v: %v", folderTree, err)
return nil, fmt.Errorf("error: failed to create toFile directory tree %v: %v", folderTree, err)
}
log.Printf("info: Creating subscribers data folder at %v\n", folderTree)
@ -603,7 +603,7 @@ func (m methodREQErrorLog) handler(proc process, message Message, node string) (
if _, err := os.Stat(folderTree); os.IsNotExist(err) {
err := os.MkdirAll(folderTree, 0700)
if err != nil {
return nil, fmt.Errorf("error: failed to create directory %v: %v", folderTree, err)
return nil, fmt.Errorf("error: failed to create errorLog directory tree %v: %v", folderTree, err)
}
log.Printf("info: Creating subscribers data folder at %v\n", folderTree)