using System.Net; namespace DahuaIPCRename { internal class Program { public static Dictionary listIPC = new Dictionary { {"172.22.10.221","Домофон|Глав.вход"}, {"172.22.10.222","Домофон|Линкор"}, {"172.22.10.223","Домофон|НЛК-1"}, {"172.22.10.224","Домофон|НЛК-2"}, {"172.22.10.225","Домофон|Ленмикс"}, {"172.22.10.226","Домофон|Карбон"} }; static async Task Main(string[] args) { foreach (var ipc in listIPC) { string baseUrl = $"http://{ipc.Key}"; var credCache = new CredentialCache(); credCache.Add(new Uri(baseUrl), "Digest", new NetworkCredential("admin", "4NUDZhJ7")); using (var handler = new HttpClientHandler { Credentials = credCache, ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true }) using (var httpClient = new HttpClient(handler)) { string requestUrl = $"{baseUrl}/cgi-bin/configManager.cgi?action=setConfig&ChannelTitle[0].Name={ipc.Value}"; var response = await httpClient.GetAsync(requestUrl); try { response.EnsureSuccessStatusCode(); Console.WriteLine($"{ipc.Key}\tOK\t{ipc.Value}"); } catch (Exception) { Console.WriteLine($"{ipc.Key}\tNO\t{ipc.Value}"); return; } } } Console.ReadKey(); } } }