WIP: DKIM messages are accepted.
This commit is contained in:
		
							parent
							
								
									1a9666df23
								
							
						
					
					
						commit
						70fb6d130c
					
				
					 1 changed files with 24 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -463,12 +463,27 @@ class DNSManager::Storage::Zone
 | 
			
		|||
		enum HashAlgorithm
 | 
			
		||||
			SHA256
 | 
			
		||||
		end
 | 
			
		||||
		property v : Version            = Version::DKIM1
 | 
			
		||||
		property h : HashAlgorithm      = HashAlgorithm::SHA256
 | 
			
		||||
		property k : SignatureAlgorithm = SignatureAlgorithm::RSA
 | 
			
		||||
		property p : String # public key
 | 
			
		||||
		def initialize(@name, @ttl, @target, @v, @h, @k, @p)
 | 
			
		||||
 | 
			
		||||
		class DKIMProperties
 | 
			
		||||
			include JSON::Serializable
 | 
			
		||||
			property v : Version            = Version::DKIM1
 | 
			
		||||
			property h : HashAlgorithm      = HashAlgorithm::SHA256
 | 
			
		||||
			property k : SignatureAlgorithm = SignatureAlgorithm::RSA
 | 
			
		||||
			property p : String             # public key
 | 
			
		||||
			property n : String = ""        # notes
 | 
			
		||||
			def initialize(@v, @h, @k, @p, @n)
 | 
			
		||||
			end
 | 
			
		||||
			def to_s(io : IO)
 | 
			
		||||
				io << "v=#{v};h=#{h};k=#{k};p=#{p}"
 | 
			
		||||
				io << ";n=#{n}" unless n == ""
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		property dkim : DKIMProperties
 | 
			
		||||
 | 
			
		||||
		def initialize(@name, @ttl, @target, v, h, k, p, n)
 | 
			
		||||
			@rrtype = "DKIM"
 | 
			
		||||
			@dkim = DKIMProperties.new v, h, k, p, n
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		def get_errors : Array(Error)
 | 
			
		||||
| 
						 | 
				
			
			@ -488,14 +503,14 @@ class DNSManager::Storage::Zone
 | 
			
		|||
			io << "(#{ "%4d" % @rrid }) "
 | 
			
		||||
			io << "#{ "%30s" % @name} #{ "%6d" % @ttl} DKIM "
 | 
			
		||||
			io << "( "
 | 
			
		||||
			io << split_line "v=#{v};h=#{h};k=#{k};p=#{p}"
 | 
			
		||||
			io << split_line dkim.to_s
 | 
			
		||||
			io << " )"
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		def to_bind9(io : IO)
 | 
			
		||||
			io << "#{@name} #{@ttl} IN TXT "
 | 
			
		||||
			io << "( "
 | 
			
		||||
			io << split_line "v=#{v};h=#{h};k=#{k};p=#{p}"
 | 
			
		||||
			io << split_line dkim.to_s
 | 
			
		||||
			io << " )"
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
| 
						 | 
				
			
			@ -763,8 +778,9 @@ def split_line(line : String) : String
 | 
			
		|||
	slice = Bytes.new(50)
 | 
			
		||||
	lines = ""
 | 
			
		||||
	while rbytes = iostr.read slice
 | 
			
		||||
		break if rbytes == 0
 | 
			
		||||
		lines += '"'
 | 
			
		||||
		lines += String.new slice[0..rbytes]
 | 
			
		||||
		lines += String.new slice[0..rbytes -1]
 | 
			
		||||
		lines += '"'
 | 
			
		||||
		lines += "\n\t"
 | 
			
		||||
	end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue