This example demonstrates how to integrate an external DNS service with an OPC UA method using FlowSync. The configuration connects dns.google on the north side with a custom OPC UA method on the south side. The OPC UA server uses a getIpForDomain method that accepts a domain name (e.g., cybus.io) as input and returns the corresponding IP address as output.
You can access the OPC UA server via opc.tcp://127.0.0.1:4841/UA/CybusOpcuaServer.
If the domain is successfully resolved, the method returns the IP address.
If no DNS record is found, it returns a BadNotFound error.
For more information on the FlowSync configuration properties, see Cybus:Node.
description:FlowSync - Example 6metadata:name:example 6version:1.0.0resources:# ------------------------------------------------# Our Endpoints for dns.google (north side)# ------------------------------------------------googleDnsConnection:type:Cybus::Connectionproperties:protocol:Httpconnection:scheme:httpshost:dns.googlednsEndpoint:type:Cybus::Endpointproperties:topic:dnsprotocol:Httpconnection:!refgoogleDnsConnectionpublishError:trueread:path:/resolve# ---------------------------------------# Our OPCUA Server and Nodes (south side)# ---------------------------------------opcuaServer:type:Cybus::Server::Opcuaproperties:hostname:127.0.0.1allowAnonymous:truesecurityPolicies: ['None']securityModes: ['None']rootNode:type:Cybus::Node::Opcuaproperties:browseName:CybusnodeId:ns=1;s=Cybusparent:!refopcuaServernodeType:ObjectgetIpForDomainNode:type:Cybus::Node::Opcuaproperties:topic:getIpForDomainbrowseName:getIpForDomainnodeId:ns=1;s=getIpForDomainparent:!refrootNodenodeType:Method# mark node as methodoperation:transactioninputArguments: - name:domaindataType:Stringdescription:the domain to resolveoutputArguments: - name:ipdataType:Stringdescription:the IP address of the domain# ------------------------------------------------# The mappings forwarding requests and responses# ------------------------------------------------Mapping:type:Cybus::Mappingproperties:mappings: - subscribe:endpoint:!refgetIpForDomainNodepublish:endpoint:!refdnsEndpointrules: - transform:expression:>- ( { "id": $.id, "query": { "name": $.value.inputArguments[0].value } } ) - subscribe:endpoint:!refdnsEndpointpublish:endpoint:!refgetIpForDomainNoderules: - transform:expression:>- ( { "id": $.id, "timestamp": $.timestamp, "value" : $.value.Status = 0 ? { "outputArguments": [ { "value": $.value.Answer[0].data } ] } : undefined, "error" : $.value.Status != 0 ? { "code": "BadNotFound", "message": "Domain not found" } : undefined } )