|
|
@ -12,42 +12,41 @@ class LtnpRecord
|
|
|
|
getter p_name : String
|
|
|
|
getter p_name : String
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(record : String)
|
|
|
|
def initialize(record : String)
|
|
|
|
ser_record = RecordHelpers.clean_record(record)
|
|
|
|
ser_record = RecordHelpers.clean_record(record)
|
|
|
|
@proto = ser_record[0]
|
|
|
|
@proto = ser_record[0]
|
|
|
|
@address, @port = ser_address_port ser_record[3].split(':')
|
|
|
|
@address, @port = ser_address_port ser_record[3].split(':')
|
|
|
|
@f_address, @f_port = ser_address_port ser_record[4].split(':')
|
|
|
|
@f_address, @f_port = ser_address_port ser_record[4].split(':')
|
|
|
|
@state = ser_record[5]
|
|
|
|
@state = ser_record[5]
|
|
|
|
@pid, @p_name = ser_pid_p_name ser_record[6]
|
|
|
|
@pid, @p_name = ser_pid_p_name ser_record[6]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
def to_s
|
|
|
|
puts "%s, " * 8 % [
|
|
|
|
puts "%s, " * 8 % [
|
|
|
|
@proto, @state, @address, @port,
|
|
|
|
@proto, @state, @address, @port,
|
|
|
|
@f_address, @f_port, @pid, @p_name
|
|
|
|
@f_address, @f_port, @pid, @p_name,
|
|
|
|
]
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def ser_address_port(address_port : Array) : {String, String}
|
|
|
|
def ser_address_port(address_port : Array) : {String, String}
|
|
|
|
address = String.new
|
|
|
|
address = String.new
|
|
|
|
port = String.new
|
|
|
|
port = String.new
|
|
|
|
unless address_port.size > 2
|
|
|
|
unless address_port.size > 2
|
|
|
|
address = address_port[0]
|
|
|
|
address = address_port[0]
|
|
|
|
port = address_port[1]
|
|
|
|
port = address_port[1]
|
|
|
|
else
|
|
|
|
else
|
|
|
|
port = address_port[-1]
|
|
|
|
port = address_port[-1]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
{address, port}
|
|
|
|
{address, port}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def ser_pid_p_name(pid_pro_str : String) : {String, String}
|
|
|
|
def ser_pid_p_name(pid_pro_str : String) : {String, String}
|
|
|
|
pid = String.new
|
|
|
|
pid = String.new
|
|
|
|
p_name = String.new
|
|
|
|
p_name = String.new
|
|
|
|
unless pid_pro_str == "-"
|
|
|
|
unless pid_pro_str == "-"
|
|
|
|
pid_pro = pid_pro_str.split('/')
|
|
|
|
pid_pro = pid_pro_str.split('/')
|
|
|
|
pid = pid_pro[0]
|
|
|
|
pid = pid_pro[0]
|
|
|
|
p_name = pid_pro[1]
|
|
|
|
p_name = pid_pro[1]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
{pid, p_name}
|
|
|
|
{pid, p_name}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|