From 5aa5857d7a87df29234ae59ff3312713eeffd1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ja=CC=88ger?= Date: Tue, 24 Jul 2018 18:57:01 +0200 Subject: [PATCH 1/3] handle Exchange 2013 SP1 correctly (based on build number) --- lib/autodiscover/server_version_parser.rb | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/autodiscover/server_version_parser.rb b/lib/autodiscover/server_version_parser.rb index cc8fde2..b83e251 100644 --- a/lib/autodiscover/server_version_parser.rb +++ b/lib/autodiscover/server_version_parser.rb @@ -1,27 +1,27 @@ module Autodiscover class ServerVersionParser - VERSIONS = { 8 => { - 0 => "Exchange2007", - 1 => "Exchange2007_SP1", - 2 => "Exchange2007_SP1", - 3 => "Exchange2007_SP1", + 0 => 'Exchange2007', + 1 => 'Exchange2007_SP1', + 2 => 'Exchange2007_SP1', + 3 => 'Exchange2007_SP1' }, 14 => { - 0 => "Exchange2010", - 1 => "Exchange2010_SP1", - 2 => "Exchange2010_SP2", - 3 => "Exchange2010_SP2", + 0 => 'Exchange2010', + 1 => 'Exchange2010_SP1', + 2 => 'Exchange2010_SP2', + 3 => 'Exchange2010_SP2' }, 15 => { - 0 => "Exchange2013", - 1 => "Exchange2013_SP1", + 0 => 'Exchange2013', # Minor builds starting from 847 are Exchange2013_SP1 + 1 => 'Exchange2016', + 20 => 'Exchange2016' # This is Office365 } - } + }.freeze def initialize(hexversion) - @version = hexversion.hex.to_s(2).rjust(hexversion.size*4, '0') + @version = hexversion.hex.to_s(2).rjust(hexversion.size * 4, '0') end def major @@ -37,9 +37,9 @@ def build end def exchange_version - v = VERSIONS[major][minor] - v.nil? ? VERIONS[8][0] : v + version = VERSIONS[major][minor] || VERSIONS[8][0] + version = 'Exchange2013_SP1' if version == 'Exchange2013' && build >= 847 + version end - end end From 812ec7d215470b5c2ca09c865e9c7fd6400942d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ja=CC=88ger?= Date: Wed, 14 Oct 2020 12:02:21 +0200 Subject: [PATCH 2/3] add support for Exchange 2019 --- .gitignore | 1 + lib/autodiscover/errors.rb | 1 + lib/autodiscover/server_version_parser.rb | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f0cf96e..c4377e5 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ mkmf.log scratch.rb *.sw[op] +.idea diff --git a/lib/autodiscover/errors.rb b/lib/autodiscover/errors.rb index c86d0ce..709849c 100644 --- a/lib/autodiscover/errors.rb +++ b/lib/autodiscover/errors.rb @@ -2,4 +2,5 @@ module Autodiscover class Error < ::StandardError; end class ArgumentError < Error; end + class VersionError < Error; end end diff --git a/lib/autodiscover/server_version_parser.rb b/lib/autodiscover/server_version_parser.rb index b83e251..f937823 100644 --- a/lib/autodiscover/server_version_parser.rb +++ b/lib/autodiscover/server_version_parser.rb @@ -16,6 +16,7 @@ class ServerVersionParser 15 => { 0 => 'Exchange2013', # Minor builds starting from 847 are Exchange2013_SP1 1 => 'Exchange2016', + 2 => 'Exchange2019', 20 => 'Exchange2016' # This is Office365 } }.freeze @@ -37,7 +38,9 @@ def build end def exchange_version - version = VERSIONS[major][minor] || VERSIONS[8][0] + version = VERSIONS[major][minor] + raise Autodiscover::VersionError, "Unknown version string: #{@version}" unless version + version = 'Exchange2013_SP1' if version == 'Exchange2013' && build >= 847 version end From 4665dbaf0e6cde6a5f32b4e2c9c760f6f141fa88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ja=CC=88ger?= Date: Wed, 14 Oct 2020 12:03:30 +0200 Subject: [PATCH 3/3] bump version number --- lib/autodiscover/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/autodiscover/version.rb b/lib/autodiscover/version.rb index f7880f7..04e8b0e 100644 --- a/lib/autodiscover/version.rb +++ b/lib/autodiscover/version.rb @@ -1,3 +1,3 @@ module Autodiscover - VERSION = "1.0.2" + VERSION = '1.0.3'.freeze end