📄 networkconfigurator.java
字号:
* * @param mode the new configuration mode * @see #getMode */ public void setMode(int mode) { this.mode = mode; if ((mode & PROXY_SERVER) == PROXY_SERVER && ((mode & RELAY_SERVER) != RELAY_SERVER)) { mode = mode | RELAY_SERVER; } // RELAY config relayConfig.setClientEnabled((mode & RELAY_CLIENT) == RELAY_CLIENT); relayConfig.setServerEnabled((mode & RELAY_SERVER) == RELAY_SERVER); // RDV_SERVER if ((mode & RDV_SERVER) == RDV_SERVER) { rdvConfig.setConfiguration(RendezVousConfiguration.RENDEZVOUS); } else if ((mode & RDV_CLIENT) == RDV_CLIENT) { rdvConfig.setConfiguration(RendezVousConfiguration.EDGE); } else if ((mode & RDV_AD_HOC) == RDV_AD_HOC) { rdvConfig.setConfiguration(RendezVousConfiguration.AD_HOC); } // TCP tcpConfig.setClientEnabled((mode & TCP_CLIENT) == TCP_CLIENT); tcpConfig.setServerEnabled((mode & TCP_SERVER) == TCP_SERVER); // HTTP httpConfig.setClientEnabled((mode & HTTP_CLIENT) == HTTP_CLIENT); httpConfig.setServerEnabled((mode & HTTP_SERVER) == HTTP_SERVER); // Multicast tcpConfig.setMulticastState((mode & IP_MULTICAST) == IP_MULTICAST); // EDGE if (mode == EDGE_NODE) { rdvConfig.setConfiguration(RendezVousConfiguration.EDGE); } } /** * Returns the current configuration mode * <p/>The default mode is EDGE, unless modified at construction time or through * Method {@link NetworkConfigurator#setMode}. A node configuration mode defined a preset configuration * parameters based on a operating mode. i.e. an EDGE mode, enable * client/server side tcp, multicast, client side http, RelayService * client mode. * * @return mode the current mode value * @see #setMode */ public int getMode() { return mode; } /** * Sets the IP group multicast packet size * * @param size the new multicast packet */ public void setMulticastSize(int size) { tcpConfig.setMulticastSize(size); } /** * Gets the IP group multicast packet size * * @return the multicast packet */ public int getMulticastSize() { return tcpConfig.getMulticastSize(); } /** * Sets the IP group multicast address (default 224.0.1.85) * * @param mcastAddress the new multicast group address * @see #setMulticastPort */ public void setMulticastAddress(String mcastAddress) { tcpConfig.setMulticastAddr(mcastAddress); } /** * Sets the IP group multicast port (default 1234) * * @param port the new IP group multicast port * @see #setMulticastAddress */ public void setMulticastPort(int port) { tcpConfig.setMulticastPort(port); } /** * Sets the node name * * @param name node name */ public void setName(String name) { this.name = name; } /** * Gets the node name * * @return node name */ public String getName() { return this.name; } /** * Sets the Principal for the peer root certificate * * @param principal the new principal value * @see #setPassword * @see #getPrincipal * @see #setPrincipal */ public void setPrincipal(String principal) { this.principal = principal; } /** * Gets the Principal for the peer root certificate * * @return principal if a principal is set, null otherwise * @see #setPassword * @see #getPrincipal * @see #setPrincipal */ public String getPrincipal() { return principal; } /** * Sets the public Certificate for this configuration. * * @param cert the new cert value */ public void setCertificate(X509Certificate cert) { this.cert = new X509Certificate[] { cert }; } /** * Returns the public Certificate for this configuration. * * @return X509Certificate */ public X509Certificate getCertificate() { return (cert == null || cert.length == 0 ? null : cert[0]); } /** * Sets the public Certificate chain for this configuration. * * @param certificateChain the new Certificate chain value */ public void setCertificateChain(X509Certificate[] certificateChain) { this.cert = certificateChain; } /** * Gets the public Certificate chain for this configuration. * * @return X509Certificate chain */ public X509Certificate[] getCertificateChain() { return cert; } /** * Sets the Subject private key * * @param subjectPkey the subject private key */ public void setPrivateKey(PrivateKey subjectPkey) { this.subjectPkey = subjectPkey; } /** * Gets the Subject private key * * @return the subject private key */ public PrivateKey getPrivateKey() { return this.subjectPkey; } /** * Sets freestanding keystore location * * @param keyStoreLocation the absolute location of the freestanding keystore */ public void setKeyStoreLocation(URI keyStoreLocation) { this.keyStoreLocation = keyStoreLocation; } /** * Gets the freestanding keystore location * * @return the location of the freestanding keystore */ public URI getKeyStoreLocation() { return keyStoreLocation; } /** * Sets the password used to sign the private key of the root certificate * * @param password the new password value * @see #setPassword * @see #getPrincipal * @see #setPrincipal */ public void setPassword(String password) { this.password = password; } /** * Gets the password used to sign the private key of the root certificate * * @return password if a password is set, null otherwise * @see #setPassword * @see #getPrincipal * @see #setPrincipal */ public String getPassword() { return password; } /** * Sets 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 <code>net.jxta.peer.PeerID</code> */ public void setPeerID(PeerID peerid) { this.peerid = peerid; } /** * Gets the PeerID * * @return peerid the <code>net.jxta.peer.PeerID</code> value */ public PeerID getPeerID() { return this.peerid; } /** * Sets Rendezvous Seeding URI * <p/>e.g. http://rdv.jxtahosts.net/cgi-bin/rendezvous.cgi?3 * * @param seedURI Rendezvous service seeding URI */ public void addRdvSeedingURI(URI seedURI) { rdvConfig.addSeedingURI(seedURI); } /** * Sets Rendezvous Access Control URI * <p/>e.g. http://rdv.jxtahosts.net/cgi-bin/rendezvousACL.cgi?3 * * @param aclURI Rendezvous Access Control URI */ public void setRdvACLURI(URI aclURI) { rdvConfig.setAclUri(aclURI); } /** * Gets Rendezvous Access Control URI if set * <p/>e.g. http://rdv.jxtahosts.net/cgi-bin/rendezvousACL.cgi?3 * * @return aclURI Rendezvous Access Control URI */ public URI getRdvACLURI() { return rdvConfig.getAclUri(); } /** * Sets Relay Access Control URI * <p/>e.g. http://rdv.jxtahosts.net/cgi-bin/relayACL.cgi?3 * * @param aclURI Relay Access Control URI */ public void setRelayACLURI(URI aclURI) { relayConfig.setAclUri(aclURI); } /** * Gets Relay Access Control URI if set * <p/>e.g. http://rdv.jxtahosts.net/cgi-bin/relayACL.cgi?3 * * @return aclURI Relay Access Control URI */ public URI getRelayACLURI() { return relayConfig.getAclUri(); } /** * 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?3 * <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; if (!tcpEnabled) { tcpConfig.setClientEnabled(false); tcpConfig.setServerEnabled(false); } } /** * 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); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -