Permalink
Browse files

Merge pull request #6 from ukn/master

Redis password support
  • Loading branch information...
ripienaar committed Jul 26, 2016
2 parents 573fc5c + cb08b6c commit 421345322e06d7709f849f008518ed766779bbf2
Showing with 9 additions and 0 deletions.
  1. +4 −0 connector/redis/discovery/redis.rb
  2. +5 −0 connector/redis/redis.rb
@@ -10,9 +10,13 @@ def discover(filter, timeout, limit=0, client=nil)
host = config.pluginconf.fetch("redis.host", "localhost")
port = Integer(config.pluginconf.fetch("redis.port", "6379"))
db = Integer(config.pluginconf.fetch("redis.db", "1"))
+ password = config.pluginconf.fetch("redis.password", nil)
max_age = Integer(config.pluginconf.fetch("redis.max_age", 1800))
redis_opts = {:host => host, :port => port, :db => db}
+ unless @password.nil?
+ redis_opts.store(:password, @password)
+ end
@redis = ::Redis.new(redis_opts)
View
@@ -20,6 +20,7 @@ module Connector
# plugin.redis.host = localhost
# plugin.redis.port = 6379
# plugin.redis.db = 1
+ # plugin.redis.password = someStrongPassword (this is optional)
class Redis<Base
class ThreadsafeQueue
def initialize
@@ -66,10 +67,14 @@ def initialize
@host = @config.pluginconf.fetch("redis.host", "localhost")
@port = Integer(@config.pluginconf.fetch("redis.port", "6379"))
@db = Integer(@config.pluginconf.fetch("redis.db", "1"))
+ @password = @config.pluginconf.fetch("redis.password", nil)
end
def connect
redis_opts = {:host => @host, :port => @port, :db => @db}
+ unless @password.nil?
+ redis_opts.store(:password, @password)
+ end
Log.debug("Connecting to redis: %s" % redis_opts.inspect)

0 comments on commit 4213453

Please sign in to comment.