module NSCA

Public Class Methods

crc32(msg) click to toggle source
# File lib/nsca.rb, line 65
def crc32 msg
        NSCA::Helper.crc32_stream[ msg]
end
cstr2str( str, maxlen = nil) click to toggle source
# File lib/nsca.rb, line 82
def cstr2str( str, maxlen = nil)  str[ 0, str.index( ?\0) || ((maxlen||str.length+1)-1)]  end
destinations() click to toggle source
# File lib/nsca.rb, line 54
def destinations()  @destinations ||= []  end
nstr2str( str, maxlen = nil) click to toggle source
# File lib/nsca.rb, line 83
def nstr2str( str, maxlen = nil)  str[ 0, str.index( ' ') || ((maxlen||str.length+1)-1)].gsub( "\x00", ' ')  end
rand_padding( str, maxlen) click to toggle source
# File lib/nsca.rb, line 75
def rand_padding( str, maxlen) str + SecureRandom.random_bytes( maxlen - str.length) end
send(*results) click to toggle source
# File lib/nsca.rb, line 56
def send *results
        NSCA.destinations.each {|server| server.send *results }
        self
end
str2cstr(str, maxlen = nil) click to toggle source

Builds a null terminated, null padded string of length maxlen

# File lib/nsca.rb, line 70
def str2cstr str, maxlen = nil
        str = str.to_s
        str = str.to_s[0..(maxlen-2)]  if maxlen
        "#{str}\x00"
end
str2cstr_rand_padding( str, maxlen = nil) click to toggle source
# File lib/nsca.rb, line 76
def str2cstr_rand_padding( str, maxlen = nil) rand_padding str2cstr( str, maxlen), maxlen end
str2nstr(str, maxlen = nil) click to toggle source
# File lib/nsca.rb, line 77
def str2nstr str, maxlen = nil
        str = str.to_s.gsub ' ', "\x00"
        "#{str} "
end
str2nstr_rand_padding( str, maxlen = nil) click to toggle source
# File lib/nsca.rb, line 81
def str2nstr_rand_padding( str, maxlen = nil) rand_padding str2nstr( str, maxlen), maxlen end
xor(key, msg = nil, key_a = nil) click to toggle source
# File lib/nsca.rb, line 61
def xor key, msg = nil, key_a = nil
        NSCA::Helper.xor_stream( key_a || key)[ msg]
end