Support credentials as hex value

This commit is contained in:
bumi 2020-11-20 23:46:43 +01:00
parent 704c4c9256
commit 2f7ae9202f
1 changed files with 2 additions and 1 deletions

View File

@ -13,7 +13,8 @@ module Lnrpc
self.address = options[:address] || DEFAULT_ADDRESS
if options.has_key?(:credentials)
self.credentials = options[:credentials]
# if there are non hex values prvided we assume it's the certificate file as string otherwise we assume it's the hex value
self.credentials = options[:credentials].match?(/\H/) ? options[:credentials] : [options[:credentials]].pack('H*')
elsif File.exists?(::File.expand_path(options[:credentials_path] || DEFAULT_CREDENTIALS_PATH))
self.credentials = ::File.read(::File.expand_path(options[:credentials_path] || DEFAULT_CREDENTIALS_PATH))
else