UPNP SSDP IOPA Middleware for Device Discovery Publishing

@class DiscoveryServerSSDP
@this app.properties  the IOPA AppBuilder Properties Dictionary, used to add server.capabilities
@constructor
@public
771706
function DiscoveryServerSSDP(app) {
  app.properties[SERVER.Capabilities][THISMIDDLEWARE.CAPABILITY] = {};
  app.properties[SERVER.Capabilities][THISMIDDLEWARE.CAPABILITY][SERVER.Version] = packageVersion;

  //Also register as standard IOPA DISCOVERY SERVER MIDDLEWARE
  app.properties[SERVER.Capabilities][IOPA.CAPABILITIES.DiscoveryServer] = {};
  app.properties[SERVER.Capabilities][IOPA.CAPABILITIES.DiscoveryServer][SERVER.Version] = app.properties[SERVER.Capabilities][IOPA.CAPABILITIES.App][SERVER.Version];

  this._devices = {};
  this._factory = new iopa.Factory();
  this._SSDPserver = null;
  this._HTTPserver = null;
 
  this._SSDPclient = null;

  app.device = app.device || {};
  app.device.register = this.register.bind(this, app.device.register || function (device) { return Promise.resolve(device); });
  app.device.unregister = this.register.bind(this, app.device.unregister || function (id) { return Promise.resolve(id); });
  
  this.ssdpApp = new iopa.App();
  this.ssdpApp.use(IopaUDP);
  this.ssdpApp.use(IopaSSDP);
  this.ssdpApp.use(IopaMessageLogger);

  this.ssdpApp.use(this.invoke.bind(this));
  
  this.httpApp = new iopa.App();
  this.httpApp.use(IopaTCP);
  this.httpApp.use(IopaMessageLogger);
  this.httpApp.use(IopaHTTP);
  this.httpApp.use(this.invoke.bind(this));
}
576852
protected void addAppServerProcess(AspImpl aspImpl) throws Exception {
        aspImpl.setAs(this);
        appServerProcs.add(aspImpl);

        this.resetSlsVsAspTable();
    }
51691
function UPNPService(options) {
  if (!(this instanceof UPNPService))
    return new UPNPService(options);

  this.serviceType = options.serviceType;
  this.serviceId = options.serviceId;
  this.controlURL = options.controlURL;
  this.eventSubURL = options.eventSubURL;
  this.SCPDURL = options.SCPDURL;
}
239168
private static EndpointReferenceType createEPR(String address, SLProperties props) {
        EndpointReferenceType epr = WSAEndpointReferenceUtils.getEndpointReference(address);
        if (props != null) {
            addProperties(epr, props);
        }
        return epr;
    }
1339085
function Embdr(key) {
    if (!(this instanceof Embdr)) {
        return new Embdr(key);
    }

    this._api = {
        'auth': null,
        'host': Embdr.DEFAULT_HOST,
        'port': Embdr.DEFAULT_PORT,
        'basePath': Embdr.DEFAULT_BASE_PATH,
        'protocol': Embdr.DEFAULT_PROTOCOL
    };

    this.setApiKey(key);
    this._exposeApis();
}
45447
private Dictionary<String, Object> buildServicePropsAndFilterTargets(String pid, Dictionary<String, Object> config) throws IOException, InvalidSyntaxException {
        Dictionary<String, Object> result = new Hashtable<String, Object>();

        // we will use this later to discover the properties configured in this classloader element in config
        result.put("classloader.config.pid", pid);

        // Add the application so other DS components can key from this new classloader sevice
        String appFilter = "(classloader=" + pid + ")";
        Configuration[] appConfigs = configAdmin.listConfigurations(appFilter);

        if (appConfigs.length == 1) {
            Configuration appConfig = appConfigs[0];
            Dictionary<String, Object> properties = appConfig.getProperties();
            String appName = (String) properties.get("name");
            if (appName != null) {
                result.put("application.name", appName);
            }
            String appConfigPid = (String) properties.get("service.pid");
            try {
                result.put("application.pid", appConfigPid);
            } catch (NullPointerException swallowed) {
                /* this will be FFDC'd */
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "service.pid is null", swallowed);
            }
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Creating ApplicationClassloadingService for application" + appName);
        }

        List<String> allLibraries = new ArrayList<String>();

        String[] privateLibraryRefs = (String[]) config.get(LIBRARY_REF_ATT);
        if (privateLibraryRefs != null) {
            allLibraries.addAll(Arrays.asList(privateLibraryRefs));
        }

        String[] commonLibraryRefs = (String[]) config.get(COMMON_LIBRARY_REF_ATT);
        if (commonLibraryRefs != null) {
            allLibraries.addAll(Arrays.asList(commonLibraryRefs));
        }

        if (allLibraries.size() > 0) {
            String filter = buildTargetString(allLibraries);
            result.put("libraryStatus.target", filter);
            if (tc.isDebugEnabled())
                Tr.debug(tc, "This application will wait for the following libraries ", filter);
        } else {
            // we need to clear the blocking target and make sure we 
            // do get activated by setting a target we know will happen
            result.put("libraryStatus.target", "(id=global)");
        }

        return result;
    }
1275599
async function buildBastion(keyPairName, numZones = 0) {
  if (numZones < 1) {
    return {};
  }
  let publicIp = '0.0.0.0/0';
  try {
    publicIp = await getPublicIp();
    publicIp = `${publicIp}/32`;
  } catch (err) {
    console.error('Unable to discover public IP address:', err);
  }

  return Object.assign(
    {},
    buildBastionEIP(),
    buildBastionIamRole(),
    buildBastionInstanceProfile(),
    buildBastionSecurityGroup(publicIp),
    buildBastionLaunchConfiguration(keyPairName),
    buildBastionAutoScalingGroup(numZones),
  );
}
1026809
private void readProjectProperties(Settings phoenixSettings, Storepoint storepoint)
   {
      ProjectProperties mpxjProperties = m_projectFile.getProjectProperties();
      mpxjProperties.setName(phoenixSettings.getTitle());
      mpxjProperties.setDefaultDurationUnits(phoenixSettings.getBaseunit());
      mpxjProperties.setStatusDate(storepoint.getDataDate());
   }
931917
function (details) {
    this.id = details.id;
    this.address = details.address;
    this.type = details.type;
    this.ipVersion = details.ipVersion;
  }
957649
function DemoDevice(){
  var _device = {};
  _device[DEVICE.ModelManufacturer] = "Internet of Protocols Alliance";
  _device[DEVICE.ModelManufacturerUrl] = "http://iopa.io";
  _device[DEVICE.ModelName] = "npm install iopa-devices";
  _device[DEVICE.ModelNumber] = "iopa-devices";
  _device[DEVICE.ModelUrl] = "http://github.com/iopa-io/iopa-devices";

  _device[DEVICE.PlatformId] = "LOCALHOST";
  _device[DEVICE.PlatformName] = "Iopa Device Stick";
  _device[DEVICE.PlatformFirmware] = packageVersion;
  _device[DEVICE.PlatformOS] = require('os').type() + "/" + require('os').release();

  _device[DEVICE.Id] = "12345-67890";
  _device[DEVICE.Type] = "urn:io.iopa:demo:devices";
  _device[DEVICE.Version] = packageVersion;
  _device[DEVICE.Location] = [37.7833, 122.4167];
  _device[DEVICE.LocationName] = "San Francisco, USA";
  _device[DEVICE.Currency] = "USD";
  _device[DEVICE.Region] = "Home";
  _device[DEVICE.Policy] = null;
  _device[DEVICE.Url] = "coap://localhost";
  
  _device[DEVICE.Resources] = [];
  var _res = {};
  _res[RESOURCE.TypeName] = "IOPA Demo Projector";
  _res[RESOURCE.Type] = "urn:io.iopa:resource:projector";
  _res[RESOURCE.Interface] = "if.switch.binary";
  _res[RESOURCE.Path] = "/media/projector";
  _res[RESOURCE.Name] = "Projector 1";
  _res[RESOURCE.Value] = false;
  _device[DEVICE.Resources].push(_res);
  
  this._device = _device;
}
357135
function Peer(internalPeer){
  Emitter.Target.call(this,emitter);
  
  this[rooms] = {};
  this[pids] = {};
  this[ip] = internalPeer;
  
  plugins.give('peer',this);
}
1317727
def publish_properties(self):
        """"""
        publish = self.publish

        # device properties
        publish(b"$homie", b"3.0.1")
        publish(b"$name", self.settings.DEVICE_NAME)
        publish(b"$state", b"init")
        publish(b"$fw/name", b"Microhomie")
        publish(b"$fw/version", __version__)
        publish(b"$implementation", bytes(sys.platform, "utf-8"))
        publish(b"$localip", utils.get_local_ip())
        publish(b"$mac", utils.get_local_mac())
        publish(b"$stats", b"interval,uptime,freeheap")
        publish(b"$stats/interval", self.stats_interval)
        publish(b"$nodes", b",".join(self.node_ids))

        # node properties
        for node in self.nodes:
            try:
                for propertie in node.get_properties():
                    if propertie:
                        publish(*propertie)
            except NotImplementedError:
                raise
            except Exception as error:
                self.node_error(node, error)
1229990
private void addInstancesToVIPMaps(Application app, Map<String, VipIndexSupport> virtualHostNameAppMap,
            Map<String, VipIndexSupport> secureVirtualHostNameAppMap) {
        // Check and add the instances to the their respective virtual host name
        // mappings
        for (InstanceInfo info : app.getInstances()) {
            String vipAddresses = info.getVIPAddress();
            if (vipAddresses != null) {
                addInstanceToMap(info, vipAddresses, virtualHostNameAppMap);
            }

            String secureVipAddresses = info.getSecureVipAddress();
            if (secureVipAddresses != null) {
                addInstanceToMap(info, secureVipAddresses, secureVirtualHostNameAppMap);
            }
        }
    }
615313
private static PropertyHelper init() {
		propertHelper = new PropertyHelper();
		try
		{
		ResourceBundle bundle = ResourceBundle.getBundle("ippdevkit");
		
		propertHelper.setVersion(bundle.getString("version"));
		propertHelper.setRequestSource(bundle.getString("request.source"));
		propertHelper.setRequestSourceHeader(bundle.getString("request.source.header"));
		}
		catch(MissingResourceException e){
			LOG.debug("no value found for key", e);
		}
		return propertHelper;
	}
395241
function buildAppNetworkAcl(numZones = 0) {
  if (numZones < 1) {
    return {};
  }

  const resources = {};

  Object.assign(
    resources,
    buildNetworkAcl(APP_SUBNET),
    buildNetworkAclEntry(`${APP_SUBNET}NetworkAcl`, '0.0.0.0/0'),
    buildNetworkAclEntry(`${APP_SUBNET}NetworkAcl`, '0.0.0.0/0', {
      Egress: true,
    }),
  );

  for (let i = 1; i <= numZones; i += 1) {
    Object.assign(resources, buildNetworkAclAssociation(APP_SUBNET, i));
  }

  return resources;
}
1056025
private void setAttributesFromApiEndpointProperties(Api api, ApimanHttpConnectorOptions options) {
        try {
            Map<String, String> endpointProperties = api.getEndpointProperties();
            if (endpointProperties.containsKey("timeouts.read")) { //$NON-NLS-1$
                int connectTimeoutMs = Integer.parseInt(endpointProperties.get("timeouts.read")); //$NON-NLS-1$
                options.setRequestTimeout(connectTimeoutMs);
            }
            if (endpointProperties.containsKey("timeouts.connect")) { //$NON-NLS-1$
                int connectTimeoutMs = Integer.parseInt(endpointProperties.get("timeouts.connect")); //$NON-NLS-1$
                options.setConnectionTimeout(connectTimeoutMs);
            }
        } catch (NumberFormatException e) {
            throw new RuntimeException(e);
        }
    }
1054802
@Override
    public Map<ServerGroup, EVCacheServerGroupConfig> discoverInstances(String appName) throws IOException {
        final String propertyName = appName + "-NODES";
        final String nodeListString = EVCacheConfig.getInstance().getDynamicStringProperty(propertyName, "").get();
        if (log.isDebugEnabled()) log.debug("List of Nodes = " + nodeListString);
        if(nodeListString != null && nodeListString.length() > 0) return bootstrapFromSystemProperty(nodeListString);
        
        if(env != null && region != null) return bootstrapFromEureka(appName);
        
        return Collections.<ServerGroup, EVCacheServerGroupConfig> emptyMap();
    }