vici: Use default Unix vici socket if none passed to ruby constructor

While we currently have a static path instead of one generated with Autotools,
this at least is congruent to what we have in the Python library.
This commit is contained in:
Martin Willi 2015-02-27 14:03:35 +01:00
parent 61fb10c8cf
commit fb8b119cfa
2 changed files with 7 additions and 4 deletions

View File

@ -821,9 +821,9 @@ during encoding.
## Connecting to the daemon ##
To create a connection to the daemon, a socket must be passed to the
_Connection_ constructor. There is no default, but on Unix systems usually
a Unix socket over _/var/run/charon.vici_ is used:
To create a connection to the daemon, a socket can be passed to the
_Connection_ constructor. If none is passed, a default Unix socket at
_/var/run/charon.vici_ is used:
require "vici"
require "socket"

View File

@ -390,7 +390,10 @@ module Vici
# during encoding.
class Connection
def initialize(socket)
def initialize(socket = nil)
if socket == nil
socket = UNIXSocket.new("/var/run/charon.vici")
end
@transp = Transport.new(socket)
end