Added new AsteriskVersions to determineVersion()

Added up to Asterisk v17.
Added an attempt at getting newer versions too.
This commit is contained in:
Deantwo 2020-01-21 12:33:47 +01:00 committed by GitHub
parent acd9e885cc
commit 3adadb1c63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -167,7 +167,7 @@ namespace AsterNET.Manager
/// <summary> Default Slow Reconnect interval in milliseconds.</summary> /// <summary> Default Slow Reconnect interval in milliseconds.</summary>
private int reconnectIntervalMax = 10000; private int reconnectIntervalMax = 10000;
public char[] VAR_DELIMITER = { '|' }; public char[] VAR_DELIMITER = { '|' };
#endregion #endregion
@ -1646,43 +1646,68 @@ namespace AsterNET.Manager
if (m.Groups.Count >= 2) if (m.Groups.Count >= 2)
{ {
version = m.Groups[1].Value; version = m.Groups[1].Value;
if (version.StartsWith("1.4.")) if (version.StartsWith("1.4."))
{ {
VAR_DELIMITER = new char[] { '|' }; VAR_DELIMITER = new char[] { '|' };
return AsteriskVersion.ASTERISK_1_4; return AsteriskVersion.ASTERISK_1_4;
} }
else if (version.StartsWith("1.6.")) else if (version.StartsWith("1.6."))
{ {
VAR_DELIMITER = new char[] { '|' }; VAR_DELIMITER = new char[] { '|' };
return Manager.AsteriskVersion.ASTERISK_1_6; return Manager.AsteriskVersion.ASTERISK_1_6;
} }
else if (version.StartsWith("1.8.")) else if (version.StartsWith("1.8."))
{ {
VAR_DELIMITER = new char[] { '|' }; VAR_DELIMITER = new char[] { '|' };
return Manager.AsteriskVersion.ASTERISK_1_8; return Manager.AsteriskVersion.ASTERISK_1_8;
} }
else if (version.StartsWith("10.")) else if (version.StartsWith("10."))
{ {
VAR_DELIMITER = new char[] { '|' }; VAR_DELIMITER = new char[] { '|' };
return Manager.AsteriskVersion.ASTERISK_10; return Manager.AsteriskVersion.ASTERISK_10;
} }
else if (version.StartsWith("11.")) else if (version.StartsWith("11."))
{ {
VAR_DELIMITER = new char[] { ',' }; VAR_DELIMITER = new char[] { ',' };
return Manager.AsteriskVersion.ASTERISK_11; return Manager.AsteriskVersion.ASTERISK_11;
} }
else if (version.StartsWith("12.")) else if (version.StartsWith("12."))
{ {
VAR_DELIMITER = new char[] { ',' }; VAR_DELIMITER = new char[] { ',' };
return Manager.AsteriskVersion.ASTERISK_12; return Manager.AsteriskVersion.ASTERISK_12;
} }
else if (version.StartsWith("13.")) else if (version.StartsWith("13."))
{ {
VAR_DELIMITER = new char[] { ',' }; VAR_DELIMITER = new char[] { ',' };
return Manager.AsteriskVersion.ASTERISK_13; return Manager.AsteriskVersion.ASTERISK_13;
} }
else else if (version.StartsWith("14."))
throw new ManagerException("Unknown Asterisk version " + version); {
VAR_DELIMITER = new char[] { ',' };
return Manager.AsteriskVersion.ASTERISK_14;
}
else if (version.StartsWith("15."))
{
VAR_DELIMITER = new char[] { ',' };
return Manager.AsteriskVersion.ASTERISK_15;
}
else if (version.StartsWith("16."))
{
VAR_DELIMITER = new char[] { ',' };
return Manager.AsteriskVersion.ASTERISK_16;
}
else if (version.StartsWith("17."))
{
VAR_DELIMITER = new char[] { ',' };
return Manager.AsteriskVersion.ASTERISK_17;
}
else if (version.IndexOf('.') >= 2)
{
VAR_DELIMITER = new char[] { ',' };
return Manager.AsteriskVersion.ASTERISK_Newer;
}
else
throw new ManagerException("Unknown Asterisk version " + version);
} }
} }
} }
@ -1697,7 +1722,10 @@ namespace AsterNET.Manager
string line1; string line1;
line1 = (string)showVersionFilesResult[0]; line1 = (string)showVersionFilesResult[0];
if (line1 != null && line1.StartsWith("File")) if (line1 != null && line1.StartsWith("File"))
{
VAR_DELIMITER = new char[] { '|' };
return AsteriskVersion.ASTERISK_1_2; return AsteriskVersion.ASTERISK_1_2;
}
} }
} }
return AsteriskVersion.ASTERISK_1_0; return AsteriskVersion.ASTERISK_1_0;