private void GetHostAddressesCallback(IAsyncResult ar) { // Make sure the request was still relevant if ((ar.AsyncState as string) != Text) { try { _ = Dns.EndGetHostAddresses(ar); } catch { } return; } Resolving = false; IpAddresses = null; try { IpAddresses = Dns.EndGetHostAddresses(ar).Where(a => a.AddressFamily == AddressFamily.InterNetwork || a.AddressFamily == AddressFamily.InterNetworkV6); } catch (SocketException) { } if (IpAddresses == null || !IpAddresses.Any()) { OnResolveFailed(Text); ForeColor = ErrorForeColor; return; } ResolvedSuccessfully = true; OnResolveSuccessful(Text, IpAddresses); }
private Client(string apiKey, string username, string password, string baseUri, string apiVersion, HttpClient httpClient) { _mustDisposeHttpClient = httpClient == null; _httpClient = httpClient; #if DEBUG Version = "DEBUG"; #else var assemblyVersion = typeof(Client).GetTypeInfo().Assembly.GetName().Version; Version = $"{assemblyVersion.Major}.{assemblyVersion.Minor}.{assemblyVersion.Build}"; #endif _fluentClient = new FluentClient(new Uri($"{baseUri.TrimEnd('/')}/{apiVersion.TrimStart('/')}"), httpClient) .SetUserAgent($"StrongGrid/{Version} (+https://github.com/Jericho/StrongGrid)") .SetRequestCoordinator(new SendGridRetryStrategy()); _fluentClient.Filters.Remove <DefaultErrorFilter>(); _fluentClient.Filters.Add(new DiagnosticHandler()); _fluentClient.Filters.Add(new SendGridErrorHandler()); if (!string.IsNullOrEmpty(apiKey)) { _fluentClient.SetBearerAuthentication(apiKey); } if (!string.IsNullOrEmpty(username)) { _fluentClient.SetBasicAuthentication(username, password); } AccessManagement = new AccessManagement(_fluentClient); Alerts = new Alerts(_fluentClient); ApiKeys = new ApiKeys(_fluentClient); Batches = new Batches(_fluentClient); Blocks = new Blocks(_fluentClient); Bounces = new Bounces(_fluentClient); Campaigns = new Campaigns(_fluentClient); Categories = new Categories(_fluentClient); Contacts = new Contacts(_fluentClient); CustomFields = new CustomFields(_fluentClient); GlobalSuppressions = new GlobalSuppressions(_fluentClient); InvalidEmails = new InvalidEmails(_fluentClient); IpAddresses = new IpAddresses(_fluentClient); IpPools = new IpPools(_fluentClient); Lists = new Lists(_fluentClient); Mail = new Mail(_fluentClient); Segments = new Segments(_fluentClient); SenderIdentities = new SenderIdentities(_fluentClient); Settings = new Settings(_fluentClient); SpamReports = new SpamReports(_fluentClient); Statistics = new Statistics(_fluentClient); Subusers = new Subusers(_fluentClient); Suppressions = new Suppressions(_fluentClient); Teammates = new Teammates(_fluentClient); Templates = new Templates(_fluentClient); UnsubscribeGroups = new UnsubscribeGroups(_fluentClient); User = new User(_fluentClient); WebhookSettings = new WebhookSettings(_fluentClient); WebhookStats = new WebhookStats(_fluentClient); Whitelabel = new Whitelabel(_fluentClient); }
public override bool OnDnsSwitchDo(IpAddresses dns) { if (GetDnsSwitchMode() == "rename") { if (FileExists("/etc/resolv.conf.eddie") == false) { if (FileExists("/etc/resolv.conf")) { Engine.Instance.Logs.Log(LogType.Verbose, Messages.DnsRenameBackup); FileMove("/etc/resolv.conf", "/etc/resolv.conf.eddie"); } } Engine.Instance.Logs.Log(LogType.Verbose, Messages.DnsRenameDone); string text = "# " + Engine.Instance.GenerateFileHeader() + "\n\n"; foreach (IpAddress dnsSingle in dns.IPs) { text += "nameserver " + dnsSingle.Address + "\n"; } FileContentsWriteText("/etc/resolv.conf", text); Platform.Instance.FileEnsurePermission("/etc/resolv.conf", "644"); } base.OnDnsSwitchDo(dns); return(true); }
public override void OnUpdateIps() { if (m_activated == false) { return; } IpAddresses ipsWhiteListOutgoing = GetIpsWhiteListOutgoing(true); // ClodoTemp: can be 'false', but pinger don't work string currentIpsWhiteListOutgoing = ""; foreach (IpAddress ip in ipsWhiteListOutgoing.IPs) { if (currentIpsWhiteListOutgoing != "") { currentIpsWhiteListOutgoing += ","; } currentIpsWhiteListOutgoing += ip.ToCIDR(); } if (currentIpsWhiteListOutgoing != m_lastestIpsWhiteListOutgoing) { if (m_lastestIpsWhiteListOutgoing != "") { SystemShell.ShellCmd("netsh advfirewall firewall set rule name=\"Eddie - Out - Allow IPs\" dir=out new action=allow remoteip=\"" + currentIpsWhiteListOutgoing + "\""); } else { SystemShell.ShellCmd("netsh advfirewall firewall add rule name=\"Eddie - Out - Allow IPs\" dir=out action=allow remoteip=\"" + currentIpsWhiteListOutgoing + "\""); } m_lastestIpsWhiteListOutgoing = currentIpsWhiteListOutgoing; } }
public async Task AddAsync() { // Arrange var apiResponse = @"{ ""ips"": [ { ""ip"": ""1.2.3.4"", ""subusers"": [ ""jdesautels"" ] } ], ""remaining_ips"":2, ""warmup"": false }" ; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Post, Utils.GetSendGridApiUri(ENDPOINT)).Respond("application/json", apiResponse); var client = Utils.GetFluentClient(mockHttp); var ipAddresses = new IpAddresses(client); // Act var result = await ipAddresses.AddAsync(2, new[] { "user", "subuser1" }, true, CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); result.ShouldNotBeNull(); result.IpAddresses.ShouldNotBeNull(); result.IpAddresses.Length.ShouldBe(1); result.IpAddresses[0].Address.ShouldBe("1.2.3.4"); result.RemainingIpAddresses.ShouldBe(2); result.WarmingUp.ShouldBeFalse(); }
public async Task GetRemainingCountAsync() { // Arrange var apiResponse = @"{ 'results': [ { 'remaining': 2, 'period': 'month', 'price_per_ip': 20 } ] }" ; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri(ENDPOINT, "remaining")).Respond("application/json", apiResponse); var client = Utils.GetFluentClient(mockHttp); var ipAddresses = new IpAddresses(client); // Act var result = await ipAddresses.GetRemainingCountAsync(CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); result.ShouldNotBeNull(); result.Period.ShouldBe("month"); result.PricePerIp.ShouldBe(20.0); result.Remaining.ShouldBe(2); }
public override IpAddresses ResolveDNS(string host) { IpAddresses result = new IpAddresses(); string getentPath = LocateExecutable("getent"); if (getentPath != "") { // Note: CNAME record are automatically followed. SystemShell s = new SystemShell(); s.Path = getentPath; s.Arguments.Add("ahosts"); s.Arguments.Add(SystemShell.EscapeHost(host)); s.NoDebugLog = true; if (s.Run()) { string o = s.Output; o = o.CleanSpace(); foreach (string line in o.Split('\n')) { string[] fields = line.Split(' '); if (fields.Length < 2) { continue; } if (fields[1].Trim() != "STREAM") { continue; } result.Add(fields[0].Trim()); } } } return(result); }
private void stopIt_Click(object sender, EventArgs e) { listenerWorker.CancelAsync(); IpAddresses.Rows.Clear(); IpAddresses.Refresh(); MessageBox.Show("Listening Stopped!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public override IpAddresses DetectDNS() { IpAddresses list = new IpAddresses(); // Method1: Don't return DHCP DNS string networksetupPath = LocateExecutable("networksetup"); if (networksetupPath != "") { string[] interfaces = GetInterfaces(); foreach (string i in interfaces) { string i2 = i.Trim(); string current = SystemShell.Shell(networksetupPath, new string[] { "-getdnsservers", SystemShell.EscapeInsideQuote(i2) }); foreach (string line in current.Split('\n')) { string field = line.Trim(); list.Add(field); } } } // Method2 - More info about DHCP DNS string scutilPath = LocateExecutable("scutil"); if (scutilPath != "") { string scutilOut = SystemShell.Shell1(scutilPath, "--dns"); List <List <string> > result = UtilsString.RegExMatchMulti(scutilOut.Replace(" ", ""), "nameserver\\[[0-9]+\\]:([0-9:\\.]+)"); foreach (List <string> match in result) { foreach (string field in match) { list.Add(field); } } } // Method3 - Compatibility if (FileExists("/etc/resolv.conf")) { string o = FileContentsReadText("/etc/resolv.conf"); foreach (string line in o.Split('\n')) { if (line.Trim().StartsWith("#")) { continue; } if (line.Trim().StartsWith("nameserver")) { string field = line.Substring(11).Trim(); list.Add(field); } } } return(list); }
private Client(string apiKey, string username, string password, HttpClient httpClient, bool disposeClient, StrongGridClientOptions options) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient; _options = options ?? GetDefaultOptions(); _fluentClient = new FluentClient(new Uri(SENDGRID_V3_BASE_URI), httpClient) .SetUserAgent(Client.UserAgent) .SetRequestCoordinator(new SendGridRetryStrategy()); _fluentClient.Filters.Remove <DefaultErrorFilter>(); // Order is important: DiagnosticHandler must be first. // Also, the list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(_options.LogLevelSuccessfulCalls, _options.LogLevelFailedCalls)); _fluentClient.Filters.Add(new SendGridErrorHandler()); if (!string.IsNullOrEmpty(apiKey)) { _fluentClient.SetBearerAuthentication(apiKey); } if (!string.IsNullOrEmpty(username)) { _fluentClient.SetBasicAuthentication(username, password); } AccessManagement = new AccessManagement(_fluentClient); Alerts = new Alerts(_fluentClient); ApiKeys = new ApiKeys(_fluentClient); Batches = new Batches(_fluentClient); Blocks = new Blocks(_fluentClient); Bounces = new Bounces(_fluentClient); Campaigns = new Campaigns(_fluentClient); Categories = new Categories(_fluentClient); Contacts = new Contacts(_fluentClient); CustomFields = new CustomFields(_fluentClient); Designs = new Designs(_fluentClient); EmailActivities = new EmailActivities(_fluentClient); EmailValidation = new EmailValidation(_fluentClient); GlobalSuppressions = new GlobalSuppressions(_fluentClient); InvalidEmails = new InvalidEmails(_fluentClient); IpAddresses = new IpAddresses(_fluentClient); IpPools = new IpPools(_fluentClient); Lists = new Lists(_fluentClient); Mail = new Mail(_fluentClient); Segments = new Segments(_fluentClient); SenderIdentities = new SenderIdentities(_fluentClient); Settings = new Settings(_fluentClient); SpamReports = new SpamReports(_fluentClient); Statistics = new Statistics(_fluentClient); Subusers = new Subusers(_fluentClient); Suppressions = new Suppressions(_fluentClient); Teammates = new Teammates(_fluentClient); Templates = new Templates(_fluentClient); UnsubscribeGroups = new UnsubscribeGroups(_fluentClient); User = new User(_fluentClient); WebhookSettings = new WebhookSettings(_fluentClient); WebhookStats = new WebhookStats(_fluentClient); SenderAuthentication = new SenderAuthentication(_fluentClient); }
public override void OnUpdateIps() { if (m_activated == false) { return; } IpAddresses ipsFirewalled = GetAllIps(true); // ClodoTemp: can be 'false', but pinger don't work string ipList = ""; foreach (IpAddress ip in ipsFirewalled.IPs) { if (ipList != "") { ipList += ","; } ipList += ip.ToCIDR(); } if (ipList != m_lastestIpList) { if (m_lastestIpList != "") { SystemShell.ShellCmd("netsh advfirewall firewall set rule name=\"Eddie - Out - AllowAirIPS\" dir=out new action=allow remoteip=\"" + ipList + "\""); } else { SystemShell.ShellCmd("netsh advfirewall firewall add rule name=\"Eddie - Out - AllowAirIPS\" dir=out action=allow remoteip=\"" + ipList + "\""); } m_lastestIpList = ipList; } }
public override bool OnDnsSwitchDo(IpAddresses dns) { string mode = Engine.Instance.Storage.GetLower("dns.mode"); if (mode == "auto") { string[] interfaces = GetInterfaces(); foreach (string i in interfaces) { string i2 = i.Trim(); string currentStr = SystemShell.Shell("/usr/sbin/networksetup", new string[] { "-getdnsservers", SystemShell.EscapeInsideQuote(i2) }); // v2 IpAddresses current = new IpAddresses(); foreach (string line in currentStr.Split('\n')) { string ip = line.Trim(); if (IpAddress.IsIP(ip)) { current.Add(ip); } } if (dns.Equals(current) == false) { DnsSwitchEntry e = new DnsSwitchEntry(); e.Name = i2; e.Dns = current.Addresses; m_listDnsSwitch.Add(e); SystemShell s = new SystemShell(); s.Path = LocateExecutable("networksetup"); s.Arguments.Add("-setdnsservers"); s.Arguments.Add(SystemShell.EscapeInsideQuote(i2)); if (dns.IPs.Count == 0) { s.Arguments.Add("empty"); } else { foreach (IpAddress ip in dns.IPs) { s.Arguments.Add(ip.Address); } } s.Run(); Engine.Instance.Logs.Log(LogType.Verbose, MessagesFormatter.Format(Messages.NetworkAdapterDnsDone, i2, ((current.Count == 0) ? "Automatic" : current.Addresses), dns.Addresses)); } } Recovery.Save(); } base.OnDnsSwitchDo(dns); return(true); }
public void AddIp(IPAddress ip) { var ips = IpAddresses.ToList(); ips.Add(ip); IpAddresses = ips.ToArray(); }
private void FillCollection_Button_OnClick(object sender, RoutedEventArgs e) { for (int i = 0; i < 10; i++) { IpAddresses.Add(new Address("8.8.8.8","Google")); } }
/// <summary> /// Specify the IPAddress of the entitled machine /// </summary> /// <param name="address">IP Address of the machine to run the entitled application(s).</param> /// <returns>A new entitlement</returns> public NodeEntitlements AddIpAddress(IPAddress address) { if (address == null) { throw new ArgumentNullException(nameof(address)); } return(new NodeEntitlements(this, addresses: IpAddresses.Add(address))); }
public override int GetHashCode() { unchecked { var hashCode = AgentID; hashCode = (hashCode * 397) ^ (MachineID != null ? MachineID.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DeviceGuid != null ? DeviceGuid.GetHashCode() : 0); hashCode = (hashCode * 397) ^ CustomerID; hashCode = (hashCode * 397) ^ (CustomerName != null ? CustomerName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ FolderID.GetHashCode(); hashCode = (hashCode * 397) ^ (AgentName != null ? AgentName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SystemName != null ? SystemName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MachineName != null ? MachineName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DomainName != null ? DomainName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CurrentLoggedUsers != null ? CurrentLoggedUsers.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ComputerDescription != null ? ComputerDescription.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Monitored.GetHashCode(); hashCode = (hashCode * 397) ^ LastPatchManagementReceived.GetHashCode(); hashCode = (hashCode * 397) ^ (AgentVersion != null ? AgentVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Favorite.GetHashCode(); hashCode = (hashCode * 397) ^ ThresholdID.GetHashCode(); hashCode = (hashCode * 397) ^ MonitoredAgentID.GetHashCode(); hashCode = (hashCode * 397) ^ Created.GetHashCode(); hashCode = (hashCode * 397) ^ Modified.GetHashCode(); hashCode = (hashCode * 397) ^ Online.GetHashCode(); hashCode = (hashCode * 397) ^ (ReportedFromIP != null ? ReportedFromIP.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AppViewUrl != null ? AppViewUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Motherboard != null ? Motherboard.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Processor != null ? Processor.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Memory.GetHashCode(); hashCode = (hashCode * 397) ^ (Display != null ? Display.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Sound != null ? Sound.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ProcessorCoresCount.GetHashCode(); hashCode = (hashCode * 397) ^ (SystemDrive != null ? SystemDrive.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProcessorClock != null ? ProcessorClock.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Vendor != null ? Vendor.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (VendorSerialNumber != null ? VendorSerialNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (VendorBrandModel != null ? VendorBrandModel.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProductName != null ? ProductName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OS != null ? OS.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OSType != null ? OSType.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OSVersion != null ? OSVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OSBuild != null ? OSBuild.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (WindowsSerialNumber != null ? WindowsSerialNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Office != null ? Office.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OfficeSP != null ? OfficeSP.GetHashCode() : 0); hashCode = (hashCode * 397) ^ OfficeOEM.GetHashCode(); hashCode = (hashCode * 397) ^ (OfficeSerialNumber != null ? OfficeSerialNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OfficeFullVersion != null ? OfficeFullVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (LastLoginUser != null ? LastLoginUser.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HardwareDisks?.Sum(x => x.GetHashCode()) ?? 0); hashCode = (hashCode * 397) ^ (MacAddresses?.Sum(x => x.GetHashCode()) ?? 0); hashCode = (hashCode * 397) ^ (IpAddresses?.Sum(x => x.GetHashCode()) ?? 0); return(hashCode); } }
private void ScannerOnVlcHostFound(object sender, string s) { if (ComputerAdapter.Computers.Any(i => i.Ip == s)) { return; } IpAddresses.Add(new ComputerModel(s)); RunOnUiThread(() => ComputerAdapter.NotifyDataSetChanged()); }
/// <summary> /// Initializes a new instance of the <see cref="BaseClient" /> class. /// </summary> /// <param name="apiKey">Your api key.</param> /// <param name="httpClient">Allows you to inject your own HttpClient. This is useful, for example, to setup the HtppClient with a proxy.</param> /// <param name="disposeClient">Indicates if the http client should be dispose when this instance of BaseClient is disposed.</param> /// <param name="options">Options for the SendGrid client.</param> /// <param name="logger">Logger.</param> public BaseClient(string apiKey, HttpClient httpClient, bool disposeClient, StrongGridClientOptions options, ILogger logger = null) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient; _options = options; _logger = logger ?? NullLogger.Instance; _fluentClient = new FluentClient(new Uri(SENDGRID_V3_BASE_URI), httpClient) .SetUserAgent($"StrongGrid/{Version} (+https://github.com/Jericho/StrongGrid)") .SetRequestCoordinator(new SendGridRetryStrategy()); _fluentClient.Filters.Remove <DefaultErrorFilter>(); // Remove all the built-in formatters and replace them with our custom JSON formatter _fluentClient.Formatters.Clear(); _fluentClient.Formatters.Add(new JsonFormatter()); // Order is important: DiagnosticHandler must be first. // Also, the list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(_options.LogLevelSuccessfulCalls, _options.LogLevelFailedCalls, _logger)); _fluentClient.Filters.Add(new SendGridErrorHandler()); if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentNullException(apiKey); } _fluentClient.SetBearerAuthentication(apiKey); AccessManagement = new AccessManagement(FluentClient); Alerts = new Alerts(FluentClient); ApiKeys = new ApiKeys(FluentClient); Batches = new Batches(FluentClient); Blocks = new Blocks(FluentClient); Bounces = new Bounces(FluentClient); Designs = new Designs(FluentClient); EmailActivities = new EmailActivities(FluentClient); EmailValidation = new EmailValidation(FluentClient); GlobalSuppressions = new GlobalSuppressions(FluentClient); InvalidEmails = new InvalidEmails(FluentClient); IpAddresses = new IpAddresses(FluentClient); IpPools = new IpPools(FluentClient); Mail = new Mail(FluentClient); Settings = new Settings(FluentClient); SpamReports = new SpamReports(FluentClient); Statistics = new Statistics(FluentClient); Subusers = new Subusers(FluentClient); Suppressions = new Suppressions(FluentClient); Teammates = new Teammates(FluentClient); Templates = new Templates(FluentClient); UnsubscribeGroups = new UnsubscribeGroups(FluentClient); User = new User(FluentClient); WebhookSettings = new WebhookSettings(FluentClient); WebhookStats = new WebhookStats(FluentClient); SenderAuthentication = new SenderAuthentication(FluentClient); }
public override void OnUpdateIps() { base.OnUpdateIps(); IpAddresses ipsFirewalled = GetAllIps(true); // Remove IP not present in the new list foreach (IpAddress ip in m_currentList.IPs) { if (ipsFirewalled.Contains(ip) == false) { // Remove if (ip.IsV4) { if (m_supportIPv4) { DoIptablesShell("iptables", "-D OUTPUT -d " + ip.ToCIDR() + " -j ACCEPT"); } } else if (ip.IsV6) { if (m_supportIPv6) { DoIptablesShell("ip6tables", "-D OUTPUT -d " + ip.ToCIDR() + " -j ACCEPT"); } } } } // Add IP foreach (IpAddress ip in ipsFirewalled.IPs) { if (m_currentList.Contains(ip) == false) { // Add if (ip.IsV4) { if (m_supportIPv4) { DoIptablesShell("iptables", "-I OUTPUT 1 -d " + ip.ToCIDR() + " -j ACCEPT"); } } else if (ip.IsV6) { if (m_supportIPv6) { DoIptablesShell("ip6tables", "-I OUTPUT 1 -d " + ip.ToCIDR() + " -j ACCEPT"); } } } } m_currentList = ipsFirewalled; }
private void Dg_data_OnKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { var grid = sender as DataGrid; if (grid.SelectedItem != null) { IpAddresses.RemoveAt(grid.SelectedIndex); } } }
public override void OnUpdateIps() { base.OnUpdateIps(); IpAddresses ipsWhiteListOutgoing = GetIpsWhiteListOutgoing(true); // Remove IP not present in the new list foreach (IpAddress ip in m_ipsWhiteListOutgoing.IPs) { if (ipsWhiteListOutgoing.Contains(ip) == false) { // Remove if (ip.IsV4) { if (m_supportIPv4) { DoIptablesShell("iptables", "-D OUTPUT -d " + ip.ToCIDR() + " -j ACCEPT"); } } else if (ip.IsV6) { if (m_supportIPv6) { DoIptablesShell("ip6tables", "-D OUTPUT -d " + ip.ToCIDR() + " -j ACCEPT"); } } } } // Add IP foreach (IpAddress ip in ipsWhiteListOutgoing.IPs) { if (m_ipsWhiteListOutgoing.Contains(ip) == false) { // Add if (ip.IsV4) { if (m_supportIPv4) { DoIptablesShell("iptables", "-I OUTPUT 1 -d " + ip.ToCIDR() + " -j ACCEPT"); } } else if (ip.IsV6) { if (m_supportIPv6) { DoIptablesShell("ip6tables", "-I OUTPUT 1 -d " + ip.ToCIDR() + " -j ACCEPT"); } } } } m_ipsWhiteListOutgoing = ipsWhiteListOutgoing; }
public void EnableIde() { IpAddresses ip = new IpAddresses(TxtIP.StringValue); if (ip.Count == 0) { LblHelp.StringValue = Messages.WindowsSettingsRouteInvalid + "\n" + Messages.WindowsSettingsRouteEditIp; CmdOk.Enabled = false; } else { LblHelp.StringValue = ip.ToString() + "\n" + Messages.WindowsSettingsRouteEditIp; CmdOk.Enabled = true; } }
private void EnableIde() { IpAddresses ip = new IpAddresses(txtHost.Text); if (ip.Count == 0) { lblHostHelp.Text = GuiUtils.NormalizeString(LanguageManager.GetText("WindowsSettingsRouteInvalid") + "\n" + LanguageManager.GetText("WindowsSettingsRouteEditIp")); cmdOk.Enabled = false; } else { lblHostHelp.Text = ip.ToString() + "\n" + LanguageManager.GetText("WindowsSettingsRouteEditIp"); cmdOk.Enabled = true; } }
public void EnableIde() { IpAddresses ip = new IpAddresses(TxtIP.StringValue); if (ip.Count == 0) { LblHelp.StringValue = LanguageManager.GetText("WindowsSettingsRouteInvalid") + "\n" + LanguageManager.GetText("WindowsSettingsRouteEditIp"); CmdOk.Enabled = false; } else { LblHelp.StringValue = ip.ToString() + "\n" + LanguageManager.GetText("WindowsSettingsRouteEditIp"); CmdOk.Enabled = true; } }
private void EnableIde() { IpAddresses ip = new IpAddresses(txtHost.Text); if (ip.Count == 0) { lblHostHelp.Text = Platform.Instance.NormalizeString(Messages.WindowsSettingsRouteInvalid + "\n" + Messages.WindowsSettingsRouteEditIp); cmdOk.Enabled = false; } else { lblHostHelp.Text = ip.ToString() + "\n" + Messages.WindowsSettingsRouteEditIp; cmdOk.Enabled = true; } }
public override void OnUpdateIps() { if (m_activated == false) { return; } IpAddresses ipsWhiteListOutgoing = GetIpsWhiteListOutgoing(false); if (ipsWhiteListOutgoing.ToString() != m_lastestIpsWhiteListOutgoing.ToString()) { string ipv4 = ""; string ipv6 = ""; foreach (IpAddress ip in ipsWhiteListOutgoing.IPs) { if (ip.IsV4) { if (ipv4 != "") { ipv4 += ","; } ipv4 += ip.ToCIDR(); } else { if (ipv6 != "") { ipv6 += ","; } ipv6 += ip.ToCIDR(); } } // TOFIX: If these list are too big, Shell to netsh throw an error (too long). But must be a list of four hundred ips. if (m_lastestIpsWhiteListOutgoing.Count != 0) { NetShAdvFirewall("firewall set rule name=\"Eddie - Out - Allow IPv4 IPs\" dir=out new action=allow remoteip=\"" + ipv4 + "\""); NetShAdvFirewall("firewall set rule name=\"Eddie - Out - Allow IPv6 IPs\" dir=out new action=allow remoteip=\"" + ipv6 + "\""); } else { NetShAdvFirewall("firewall add rule name=\"Eddie - Out - Allow IPv4 IPs\" dir=out action=allow remoteip=\"" + ipv4 + "\""); NetShAdvFirewall("firewall add rule name=\"Eddie - Out - Allow IPv6 IPs\" dir=out action=allow remoteip=\"" + ipv6 + "\""); } m_lastestIpsWhiteListOutgoing = ipsWhiteListOutgoing; } }
public override IpAddresses GetNetworkLockAllowedIps() { IpAddresses result = base.GetNetworkLockAllowedIps(); // Hosts XmlNodeList nodesUrls = Storage.DocumentElement.SelectNodes("//urls/url"); foreach (XmlNode nodeUrl in nodesUrls) { string url = nodeUrl.Attributes["address"].Value; string host = Utils.HostFromUrl(url); result.Add(host); } return(result); }
public bool DoVote(int voteId, string ipAddr) { bool alreadyVoted = alreadyVoted = CheckIfAlreadyVotedToday(ipAddr); if (!alreadyVoted) { Answers[voteId].Votes++; IpAddresses.Add(new IpAddressItem(ipAddr, DateTime.Now)); Save(); } else { SaveIfModified(); } return(!alreadyVoted); }
public async Task AddAsync() { // Arrange var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Post, Utils.GetSendGridApiUri(ENDPOINT)).Respond(HttpStatusCode.OK); var client = Utils.GetFluentClient(mockHttp); var ipAddresses = new IpAddresses(client); // Act await ipAddresses.AddAsync(2, new[] { "user", "subuser1" }, true, CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); }
public override IpAddresses GetNetworkLockAllowedIps() { IpAddresses result = base.GetNetworkLockAllowedIps(); List <string> urls = GetBootstrapUrls(); foreach (string url in urls) { string host = UtilsCore.HostFromUrl(url); if (host != "") { result.Add(host); } } return(result); }