From 8a81429f0eb8aa5041d47557d0c5b5359bb959e6 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 25 May 2016 13:13:30 +0200 Subject: copy over all files from rewritten attempt I started a nickserver from scratch to implement the things that are independent of our choice of stack (eventmachine or other). This commit copies them over and tests both things in parallel. --- lib/nickserver/hkp/parse_key_info.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/nickserver/hkp/parse_key_info.rb') diff --git a/lib/nickserver/hkp/parse_key_info.rb b/lib/nickserver/hkp/parse_key_info.rb index 8934829..d8abe4f 100644 --- a/lib/nickserver/hkp/parse_key_info.rb +++ b/lib/nickserver/hkp/parse_key_info.rb @@ -1,11 +1,11 @@ # -# Simple parser for HKP KeyInfo responses. +# Simple parser for Hkp KeyInfo responses. # # Focus is on simple here. Trying to avoid state and sideeffects. # Parsing a response with 12 keys and validating them takes 2ms. # So no need for memoization and making things more complex. # -module Nickserver; module HKP +module Nickserver; module Hkp class ParseKeyInfo # for this regexp to work, the source text must end in a trailing "\n", -- cgit v1.2.3 From f567ed80427d43019ceb1aaf77d4bc6c01e62729 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 11 Jun 2016 15:19:50 +0200 Subject: use adapter for FetchKeyInfo --- lib/nickserver/hkp/parse_key_info.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'lib/nickserver/hkp/parse_key_info.rb') diff --git a/lib/nickserver/hkp/parse_key_info.rb b/lib/nickserver/hkp/parse_key_info.rb index d8abe4f..9d59d6b 100644 --- a/lib/nickserver/hkp/parse_key_info.rb +++ b/lib/nickserver/hkp/parse_key_info.rb @@ -12,18 +12,26 @@ module Nickserver; module Hkp # which the output of sks does. MATCH_PUB_KEY = /(^pub:.+?\n(^uid:.+?\n)+)/m - # header -- header of the hkp response + # status -- http status of the hkp response # vindex_result -- raw output from a vindex hkp query (machine readable) - def initialize(header, vindex_result) - @header = header + def initialize(status, vindex_result) + @status = status @vindex_result = vindex_result end - def status(uid) + def status_for(uid) if hkp_ok? && keys(uid).empty? error_status(uid) else - header.status + status + end + end + + def response_for(uid) + if keys(uid).any? + keys(uid) + else + msg(uid) end end @@ -41,7 +49,7 @@ module Nickserver; module Hkp protected - attr_reader :header + attr_reader :status attr_reader :vindex_result def error_status(uid) @@ -78,7 +86,7 @@ module Nickserver; module Hkp end def hkp_ok? - header.status == 200 + status == 200 end def error_message(uid, key, err) -- cgit v1.2.3