3using System.Security.Cryptography.X509Certificates;
5using System.Threading.Tasks;
26 private bool tls =
false;
35 return Task.FromResult(
false);
52 [Header(4,
"Port Number:", 60)]
53 [ToolTip(5,
"Port number to use when communicating with device.")]
60 set => this.port = value;
67 [Header(11,
"Encrypted (TLS)", 70)]
68 [ToolTip(12,
"Check if Transport Layer Encryption (TLS) should be used.")]
72 set => this.tls = value;
87 await Client.ConnectAsync(this.
Host, this.port, this.tls);
107 public async Task<TextTcpClient>
ConnectTcp(Encoding Encoding,
bool DecoupledEvents, params
ISniffer[] Sniffers)
111 await Client.ConnectAsync(this.
Host, this.port, this.tls);
130 LinkedList<Parameter> Result = await base.GetDisplayableParametersAsync(
Language, Caller) as LinkedList<Parameter>;
145 DateTime
Now = DateTime.UtcNow;
146 string Module = typeof(
IpHost).Namespace;
150 List<Field> Fields =
new List<Field>()
159 Client.RemoteCertificateValid,
this,
Now, Fields);
169 await base.StartReadout(Request);
183 if (!(Certificate is
null))
185 string Module = typeof(
IpHost).Namespace;
189 Fields.Add(
new StringField(Node, Timestamp,
"Subject", Certificate.Subject,
FieldType.Identity,
FieldQoS.AutomaticReadout, Module, 15));
191 Fields.Add(
new StringField(Node, Timestamp,
"S/N", Certificate.GetSerialNumberString(),
FieldType.Identity,
FieldQoS.AutomaticReadout, Module, 17));
192 Fields.Add(
new StringField(Node, Timestamp,
"Digest", Certificate.GetCertHashString(),
FieldType.Identity,
FieldQoS.AutomaticReadout, Module, 20));
193 Fields.Add(
new StringField(Node, Timestamp,
"Algorithm", Certificate.GetKeyAlgorithm(),
FieldType.Identity,
FieldQoS.AutomaticReadout, Module, 21));
194 Fields.Add(
new StringField(Node, Timestamp,
"Public Key", Certificate.GetPublicKeyString(),
FieldType.Identity,
FieldQoS.AutomaticReadout, Module, 22));
Helps with parsing of commong data types.
static bool TryParseRfc822(string s, out DateTimeOffset Value)
Parses a date and time value encoded according to RFC 822, §5.
Implements a binary TCP Client, by encapsulating a TcpClient. It also makes the use of TcpClient safe...
Implements a text-based TCP Client, by using the thread-safe full-duplex BinaryTcpClient.
Static class that dynamically manages types and interfaces available in the runtime environment.
static bool TryGetModuleParameter(string Name, out object Value)
Tries to get a module parameter value.
Contains information about a language.
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Helper methods for encrypting and decrypting streams of data.
const SslProtocols SecureTls
TLS 1.2 & 1.3
Node representing an IP Host machine.
string Host
Host name or IP address.
Node representing a port on an IP Host machine.
async Task< BinaryTcpClient > ConnectTcp(bool DecoupledEvents, params ISniffer[] Sniffers)
Connect to the remote host and port using a binary protocol over TCP.
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
static void AddCertificateFields(X509Certificate Certificate, bool IsValid, ThingReference Node, DateTime Timestamp, List< Field > Fields)
Adds information from a certificate as fields to a collection of fields.
async override Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
override Task< bool > AcceptsChildAsync(INode Child)
If the node accepts a presumptive child, i.e. can receive as a child (if that child accepts the node ...
bool Tls
If connection is encrypted using TLS or not.
async Task< TextTcpClient > ConnectTcp(Encoding Encoding, bool DecoupledEvents, params ISniffer[] Sniffers)
Connect to the remote host and port using a text-based protocol over TCP.
async override Task StartReadout(ISensorReadout Request)
Starts the readout of the sensor.
Tokens available in request.
Represents a boolean value that can be either true or false.
Represents a date and optional time value.
Represents a physical quantity value.
Represents a string value.
Contains information about an error on a thing
Contains a reference to a thing
Interface for sniffers. Sniffers can be added to ICommunicationLayer classes to eavesdrop on communic...
Interface for nodes that are published through the concentrator interface.
Interface for classes managing sensor data readouts.
bool IsIncluded(string FieldName)
Checks if a field with the given parameters is included in the readout.
Task ReportErrors(bool Done, params ThingError[] Errors)
Report error states to the client.
Task ReportFields(bool Done, params Field[] Fields)
Report read fields to the client.
FieldQoS
Field Quality of Service flags
FieldType
Field Type flags