Skip to content

Commit

Permalink
allow disabling go-flo tls connection
Browse files Browse the repository at this point in the history
  • Loading branch information
bitspill committed Apr 9, 2019
1 parent 8a78fb9 commit 4589764
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cmd/oipd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ func main() {
host := viper.GetString("flod.host")
user := viper.GetString("flod.user")
pass := viper.GetString("flod.pass")
tls := viper.GetBool("flod.tls")

err := flo.WaitForFlod(tenMinuteCtx, host, user, pass)
err := flo.WaitForFlod(tenMinuteCtx, host, user, pass, tls)
if err != nil {
log.Error("Unable to connect to Flod", logger.Attrs{"host": host, "err": err})
shutdown(err)
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func loadDefaults() {
defaultFlodDir := floutil.AppDataDir("flod", false)
defaultFlodCert := filepath.Join(defaultFlodDir, "rpc.cert")
viper.SetDefault("flod.certFile", defaultFlodCert)
viper.SetDefault("flod.tls", true)
viper.SetDefault("flod.host", "127.0.0.1:8334")
viper.SetDefault("flod.user", "user")
viper.SetDefault("flod.pass", "pass")
Expand Down
2 changes: 2 additions & 0 deletions config/defaults/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ flod:
# Flod RPC authentication
user: user
pass: pass

tls: true
# Flod RPC authorization certificate
# By default reads certificate directly from Flod data directory
# certFile: certs/rpc.cert
Expand Down
19 changes: 11 additions & 8 deletions flo/flo.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func AddCore(host, user, pass string) error {
return err
}

func WaitForFlod(ctx context.Context, host, user, pass string) error {
func WaitForFlod(ctx context.Context, host, user, pass string, tls bool) error {
attempts := 0
a := logger.Attrs{"host": host, "attempts": attempts}
b := backoff.NewWithoutJitter(10*time.Minute, 1*time.Second)
Expand All @@ -47,7 +47,7 @@ func WaitForFlod(ctx context.Context, host, user, pass string) error {
attempts++
a["attempts"] = attempts
log.Info("attempting connection to flod", a)
err := AddFlod(host, user, pass)
err := AddFlod(host, user, pass, tls)
if err != nil {
a["err"] = err
log.Error("unable to connect to flod", a)
Expand Down Expand Up @@ -77,12 +77,15 @@ func WaitForFlod(ctx context.Context, host, user, pass string) error {
return nil
}

func AddFlod(host, user, pass string) error {
// Connect to flod RPC server using websockets.
certFile := config.GetFilePath("flod.certFile")
certs, err := ioutil.ReadFile(certFile)
if err != nil {
return errors.Wrap(err, "unable to read rpc.cert")
func AddFlod(host, user, pass string, tls bool) error {
var certs []byte
var err error
if tls {
certFile := config.GetFilePath("flod.certFile")
certs, err = ioutil.ReadFile(certFile)
if err != nil {
return errors.Wrap(err, "unable to read rpc.cert")
}
}

ntfnHandlers := rpcclient.NotificationHandlers{
Expand Down

0 comments on commit 4589764

Please sign in to comment.