Version 0.2.0 - required ruby>=2.7. **-kw-options. BETA
This commit is contained in:
parent
0a0392d532
commit
6af5922217
1
Gemfile
1
Gemfile
|
@ -1,4 +1,5 @@
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
ruby '>=2.7'
|
||||||
|
|
||||||
# Specify your gem's dependencies in knot.gemspec
|
# Specify your gem's dependencies in knot.gemspec
|
||||||
gemspec
|
gemspec
|
||||||
|
|
|
@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
||||||
spec.summary = %q{Provides interface to knot-server.}
|
spec.summary = %q{Provides interface to knot-server.}
|
||||||
spec.description = %q{Implements knot-protocol to provide an interface to knot-DNS-server}
|
spec.description = %q{Implements knot-protocol to provide an interface to knot-DNS-server}
|
||||||
spec.homepage = 'https://git.denkn.at/deac/knot'
|
spec.homepage = 'https://git.denkn.at/deac/knot'
|
||||||
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
||||||
|
|
||||||
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
||||||
|
|
||||||
|
|
10
lib/knot.rb
10
lib/knot.rb
|
@ -2,3 +2,13 @@ require 'knot/version'
|
||||||
require 'knot/errors'
|
require 'knot/errors'
|
||||||
require 'knot/protocol'
|
require 'knot/protocol'
|
||||||
require 'knot/interface'
|
require 'knot/interface'
|
||||||
|
|
||||||
|
module Knot
|
||||||
|
class <<self
|
||||||
|
def new *as, **os
|
||||||
|
Protocol.new *as, **os
|
||||||
|
end
|
||||||
|
alias connect new
|
||||||
|
alias open new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -153,33 +153,36 @@ class Knot::Conf
|
||||||
|
|
||||||
$~.named_captures.delete_if {|_,v| v.nil? }
|
$~.named_captures.delete_if {|_,v| v.nil? }
|
||||||
|
|
||||||
|
when nil
|
||||||
|
{}
|
||||||
|
|
||||||
else
|
else
|
||||||
raise ArgumentError, "Invalid Item-format"
|
raise ArgumentError, "Invalid Item-format"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get item = nil
|
def get item = nil
|
||||||
@protocol.call (item ? parse_item( item) : {}).update( command: 'conf-get')
|
@protocol.call **parse_item( item).update( command: 'conf-get')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets or adds a new value to item.
|
# Sets or adds a new value to item.
|
||||||
# knot knows single-value items like `server.rundir` and multi-value items like `server.listen`.
|
# knot knows single-value items like `server.rundir` and multi-value items like `server.listen`.
|
||||||
# If you set a single-value, it will replace the old value. On a multi-value, it will add it.
|
# If you set a single-value, it will replace the old value. On a multi-value, it will add it.
|
||||||
def set item, value
|
def set item, value
|
||||||
@protocol.call parse_item( item).update( command: 'conf-set', data: value)
|
@protocol.call **parse_item( item).update( command: 'conf-set', data: value)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Removes value from item. If you provide a value, this value will be removed.
|
# Removes value from item. If you provide a value, this value will be removed.
|
||||||
def unset item, value = nil
|
def unset item, value = nil
|
||||||
@protocol.call parse_item( item).update( command: 'conf-unset', data: value)
|
@protocol.call **parse_item( item).update( command: 'conf-unset', data: value)
|
||||||
end
|
end
|
||||||
alias delete unset
|
alias delete unset
|
||||||
|
|
||||||
def list item = nil
|
def list item = nil
|
||||||
@protocol.call (item ? parse_item( item) : {}).update( command: 'conf-list')
|
@protocol.call **parse_item( item).update( command: 'conf-list')
|
||||||
end
|
end
|
||||||
|
|
||||||
def read item = nil
|
def read item = nil
|
||||||
@protocol.call (item ? parse_item( item) : {}).update( command: 'conf-read')
|
@protocol.call **parse_item( item).update( command: 'conf-read')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require 'iounpack'
|
require 'iounpack'
|
||||||
|
require 'stringio'
|
||||||
require_relative 'errors'
|
require_relative 'errors'
|
||||||
|
|
||||||
module Knot
|
module Knot
|
||||||
|
@ -51,6 +52,26 @@ module Knot::Protocol::Type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#class Knot::KnotC
|
||||||
|
# attr_accessor :debug, :binary
|
||||||
|
#
|
||||||
|
# def initialize path = nil, binary: nil
|
||||||
|
# @path = path
|
||||||
|
# @binary = binary || 'knotc'
|
||||||
|
# @conf = Knot::Conf.new self
|
||||||
|
# @zones = Hash.new {|h, zone| h[zone] = Knot::Zone.new zone, self }
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# def call command:, flags: nil, section: nil, item: nil, id: nil, zone: nil, owner: nil, ttl: nil, type: nil, data: nil, filter: nil
|
||||||
|
# cs =
|
||||||
|
# case command.to_s
|
||||||
|
# when 'conf-begin', 'conf-commit', 'conf-abort', 'status', 'stop', 'reload'
|
||||||
|
# [@binary, command, ]
|
||||||
|
# else raise ArgumentError, "Unknown Command: #{command}"
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
#end
|
||||||
|
|
||||||
module Knot::Protocol::Idx
|
module Knot::Protocol::Idx
|
||||||
Idx = [
|
Idx = [
|
||||||
:command, # 10, :CMD, # Control command name.
|
:command, # 10, :CMD, # Control command name.
|
||||||
|
@ -180,7 +201,7 @@ class Knot::Protocol
|
||||||
def zone( zone) @zones[zone.to_s.to_sym] end
|
def zone( zone) @zones[zone.to_s.to_sym] end
|
||||||
|
|
||||||
def conf_set( **opts) call **opts.update( command: 'conf-set') end
|
def conf_set( **opts) call **opts.update( command: 'conf-set') end
|
||||||
def conf_unset( **opts) call **opts.update( command: 'conf-set') end
|
def conf_unset( **opts) call **opts.update( command: 'conf-unset') end
|
||||||
|
|
||||||
def zone_set( **opts) call **opts.update( command: 'zone-set') end
|
def zone_set( **opts) call **opts.update( command: 'zone-set') end
|
||||||
def zone_unset( **opts) call **opts.update( command: 'zone-unset') end
|
def zone_unset( **opts) call **opts.update( command: 'zone-unset') end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module Knot
|
module Knot
|
||||||
VERSION = "0.1.2"
|
VERSION = "0.2.0"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue