private async Task Block(RemoteEndpoint EP, string Reason) { if (!EP.Blocked) { EP.Blocked = true; EP.Reason = Reason; KeyValuePair <string, object>[] Tags = await EP.Annotate(new KeyValuePair <string, object>("Reason", Reason)); StringBuilder sb = new StringBuilder(); sb.Append("Remote endpoint blocked."); EP.WhoIs = await AppendWhoIsInfo(sb, EP.Endpoint); Log.Alert(sb.ToString(), EP.Endpoint, this.ObjectID, "RemoteEndpointBlocked", EventLevel.Major, Tags); await Database.Update(EP); } }
/// <summary> /// Gets an annotated Remote endpoint state object, if one is available. /// </summary> /// <param name="RemoteEndpoint">Remote Endpoint.</param> /// <returns>Annotated state object, if available. Null otherwise.</returns> public async Task <RemoteEndpoint> GetAnnotatedStateObject(string RemoteEndpoint) { string s = this.RemovePort(RemoteEndpoint); RemoteEndpoint EP = await this.GetStateObject(s, string.Empty, false); if (EP is null) { return(null); } if (string.IsNullOrEmpty(EP.WhoIs)) { if (IPAddress.TryParse(s, out IPAddress Address) && !IPAddress.IsLoopback(Address)) { EP.WhoIs = await WhoIsClient.Query(Address); } await EP.Annotate(); await Database.Update(EP); } return(EP); }