📄 networkconfigurator.java
字号:
} /** * Sets the Subject private key * @param subjectPkey the subject private key */ public void setPrivateKey(PrivateKey subjectPkey) { this.subjectPkey = subjectPkey; } /** * Gets the Subject private key * @returns the subject private key */ public PrivateKey getPrivateKey() { return this.subjectPkey; } /** * Sets the password used to sign the private key of the root certificate * @see #setPassword * @see #getPrincipal * @see #setPrincipal * @param password the new password value */ public void setPassword(String password) { this.password = password; } /** * Gets the password used to sign the private key of the root certificate * @see #setPassword * @see #getPrincipal * @see #setPrincipal * @return password if a password is set, null otherwise */ public String getPassword() { return password; } /** * Set the PeerID (by default, a new PeerID is generated). * <p/>Note: Persist the PeerID generated, or use load() * to avoid overridding a node's PeerID between restarts. * * @param peerid the new peerid value */ public void setPeerID(PeerID peerid) { this.peerid = peerid; } /** * Get the Peer ID * * @return peerid the Peer ID value */ public PeerID getPeerID(PeerID peerid) { return this.peerid; } /** * Sets Rendezvous Seeding URI * <p/>e.g. http://rdv.jxtahosts.net/cgi-bin/rendezvous.cgi?2 * * @param seedURI Rendezvous service seeding URI */ public void addRdvSeedingURI(URI seedURI) { rdvConfig.addSeedingURI(seedURI); } /** * Sets the RelayService maximum number of simultaneous relay clients * * @param relayMaxClients the new relayMaxClients value */ public void setRelayMaxClients(int relayMaxClients) { if ((relayMaxClients != -1) && (relayMaxClients <= 0)) { throw new IllegalArgumentException("Relay Max Clients : " + relayMaxClients + " must be > 0"); } relayConfig.setMaxClients(relayMaxClients); } /** * Sets the RelayService Seeding URI * <p/>e.g. http://rdv.jxtahosts.net/cgi-bin/relays.cgi?2 * <p/>A seeding URI (when read) is expected to provide a list of * physical endpoint addresse(s) to relay peers * * @param seedURI RelayService seeding URI */ public void addRelaySeedingURI(URI seedURI) { relayConfig.addSeedingURI(seedURI); } /** * Sets the RendezVousService maximum number of simultaneous rendezvous clients * * @param rdvMaxClients the new rendezvousMaxClients value */ public void setRendezvousMaxClients(int rdvMaxClients) { if ((rdvMaxClients != -1) && (rdvMaxClients <= 0)) { throw new IllegalArgumentException("Rendezvous Max Clients : " + rdvMaxClients + " must be > 0"); } rdvConfig.setMaxClients(rdvMaxClients); } /** * Toggles TCP transport state * * @param enabled if true, enables TCP transport */ public void setTcpEnabled(boolean enabled) { this.tcpEnabled = enabled; } /** * Sets the TCP transport listening port (default 9701) * * @param port the new tcpPort value */ public void setTcpPort(int port) { tcpConfig.setPort(port); } /** * Sets the lowest port on which the TCP Transport will listen if configured * to do so. Valid values are <code>-1</code>, <code>0</code> and * <code>1-65535</code>. The <code>-1</code> value is used to signify that * the port range feature should be disabled. The <code>0</code> specifies * that the Socket API dynamic port allocation should be used. For values * <code>1-65535</code> the value must be equal to or less than the value * used for end port. * * @param start the lowest port on which to listen. */ public void setTcpStartPort(int start) { tcpConfig.setStartPort(start); } /** * Return the highest port on which the TCP Transport will listen if * configured to do so. Valid values are <code>-1</code>, <code>0</code> and * <code>1-65535</code>. The <code>-1</code> value is used to signify that * the port range feature should be disabled. The <code>0</code> specifies * that the Socket API dynamic port allocation should be used. For values * <code>1-65535</code> the value must be equal to or greater than the value * used for start port. * * @param end the new TCP end port */ public void setTcpEndPort(int end) { tcpConfig.setEndPort(end); } /** * Toggles TCP transport server (incoming) mode (default is on) * * @param incoming the new TCP server mode */ public void setTcpIncoming(boolean incoming) { tcpConfig.setServerEnabled(incoming); } /** * Toggles TCP transport client (outgoing) mode (default is true) * * @param outgoing the new tcpOutgoing value */ public void setTcpOutgoing(boolean outgoing) { tcpConfig.setClientEnabled(outgoing); } /** * Sets the TCP transport interface address * <p/>e.g. "192.168.1.1" * * @param address the TCP transport interface address */ public void setTcpInterfaceAddress(String address) { tcpConfig.setInterfaceAddress(address); } /** * Sets the node public address * <p/>e.g. "192.168.1.1:9701" * <p/>This address is the physical address defined in a node's * AccessPointAdvertisement. This often required for NAT'd/FW nodes * * @param address the TCP transport public address * @param exclusive public address advertised exclusively */ public void setTcpPublicAddress(String address, boolean exclusive) { tcpConfig.setServer(address); tcpConfig.setPublicAddressOnly(exclusive); } /** * Toggles whether to use IP group multicast (default is true) * * @param mutlicastOn the new useMulticast value */ public void setUseMulticast(boolean mutlicastOn) { tcpConfig.setMulticastState(mutlicastOn); } /** * Determines whether to restrict RelayService leases to those defined in * the seed list * * @param useOnlyRelaySeeds restrict RelayService lease to seed list */ public void setUseOnlyRelaySeeds(boolean useOnlyRelaySeeds) { relayConfig.setUseOnlySeeds(useOnlyRelaySeeds); } /** * Determines whether to restrict RendezvousService leases to those defined in * the seed list * * @param useOnlyRendezvouSeeds restrict RendezvousService lease to seed list */ public void setUseOnlyRendezvousSeeds(boolean useOnlyRendezvouSeeds) { rdvConfig.setUseOnlySeeds(useOnlyRendezvouSeeds); } /** * Adds RelayService peer seed address * <p/>A RelayService seed is defined as a physical endpoint address * <p/>e.g. http://192.168.1.1:9700, or tcp://192.168.1.1:9701 * * @param seedURI the relay seed URI */ public void addSeedRelay(URI seedURI) { relayConfig.addSeedRelay(seedURI.toString()); } /** * Adds Rendezvous peer seed, physical endpoint address * <p/>A RendezVousService seed is defined as a physical endpoint address * <p/>e.g. http://192.168.1.1:9700, or tcp://192.168.1.1:9701 * * @param seedURI the rendezvous seed URI */ public void addSeedRendezvous(URI seedURI) { rdvConfig.addSeedRendezvous(seedURI); } /** * Returns true if a PlatformConfig file exist under store home * * @return true if a PlatformConfig file exist under store home */ public boolean exists() { return configFile.exists(); } /** * Sets the PeerID for this Configuration * * @param peerIdStr the new PeerID as a string */ public void setPeerId(String peerIdStr) { this.peerid = (PeerID) ID.create(URI.create(peerIdStr)); } /** * Sets the new RendezvousService seeding URI as a string. * <p/>A seeding URI (when read) is expected to provide a list of * physical endpoint address to rendezvous peers * * @param seedURIStr the new rendezvous seed URI as a string */ public void addRdvSeedingURI(String seedURIStr) { rdvConfig.addSeedingURI(URI.create(seedURIStr)); } /** * Sets the new RelayService seeding URI as a string. * <p/>A seeding URI (when read) is expected to provide a list of * physical endpoint address to relay peers * * @param seedURIStr the new RelayService seed URI as a string */ public void addRelaySeedingURI(String seedURIStr) { relayConfig.addSeedingURI(URI.create(seedURIStr)); } /** * Sets the List relaySeeds represented as Strings * <p/>A RelayService seed is defined as a physical endpoint address * <p/>e.g. http://192.168.1.1:9700, or tcp://192.168.1.1:9701 * @param seedURIs the List relaySeeds represented as Strings */ public void setRelaySeedURIs(List<String> seedURIs) { relayConfig.clearSeedingURIs(); for (String seedStr: seedURIs) { relayConfig.addSeedingURI(URI.create(seedStr)); } } /** * Sets the List of RendezVousService seeds represented as Strings * <p/>A RendezvousService seed is defined as a physical endpoint address * <p/>e.g. http://192.168.1.1:9700, or tcp://192.168.1.1:9701 * * @param seedURIs the List rendezvousSeeds represented as Strings */ public void setRendezvousSeedURIs(List<String> seedURIs) { rdvConfig.clearSeedingURIs(); for (String seedStr: seedURIs) { rdvConfig.addSeedingURI(URI.create(seedStr)); } } /** * Load a configuration from the specified store home uri * <p/> * e.g. file:/export/dist/EdgeConfig.xml, e.g. http://configserver.net/configservice?Edge * * @exception IOException if an i/o error occurs * @exception CertificateException if the MemebershipService is invalid */ public void load() throws IOException, CertificateException { load(storeHome.resolve("PlatformConfig")); } /** * Load a configuration from a specified uri * <p/> * e.g. file:/export/dist/EdgeConfig.xml, e.g. http://configserver.net/configservice?Edge * * @param uri the URI to PlatformConfig * @exception IOException if an i/o error occurs * @exception CertificateException if the MemebershipService is invalid */ public void load(URI uri) throws IOException, CertificateException { if (uri == null) { throw new IllegalArgumentException("URI can not be null"); } if (LOG.isEnabledFor(Level.DEBUG)) { LOG.debug("Loading configuration : " + uri.toString()); } URL url = null; try { url = uri.toURL(); } catch (MalformedURLException mue) { IllegalArgumentException failure = new IllegalArgumentException("Failed to convert URI to URL"); failure.initCause(mue); throw failure; } XMLElement param; InputStream input = url.openStream(); XMLDocument document = (XMLDocument) StructuredDocumentFactory.newStructuredDocument(MimeMediaType.XMLUTF8, input); PlatformConfig platformConfig = (PlatformConfig) AdvertisementFactory.newAdvertisement(document); input.close(); name = platformConfig.getName(); peerid = platformConfig.getPeerID(); description = platformConfig.getDescription(); //TCP param = (XMLElement) platformConfig.getServiceParam(PeerGroup.tcpProtoClassID); tcpEnabled = param.getChildren("isOff").hasMoreElements() ? false : true; Enumeration tcpChilds = param.getChildren(TransportAdvertisement.getAdvertisementType()); // get the TransportAdv from either TransportAdv or tcpConfig if (tcpChilds.hasMoreElements()) { param = (XMLElement) tcpChilds.nextElement(); } else { throw new IllegalStateException("Missing TCP Advertisment"); } tcpConfig = (TCPAdv) AdvertisementFactory.newAdvertisement(param); /* if (tcpConfig.isClientEnabled()) { mode = mode | TCP_CLIENT; } if (tcpConfig.isServerEnabled()) { mode = mode | TCP_SERVER; }*/ //HTTP try { param = (XMLElement) platformConfig.getServiceParam(PeerGroup.httpProtoClassID); httpEnabled = param.getChildren("isOff").hasMoreElements() ? false : true; Enumeration httpChilds = param.getChildren(TransportAdvertisement.getAdvertisementType()); // get the TransportAdv from either TransportAdv
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -