Package net.tomp2p.connection

Examples of net.tomp2p.connection.Ports


        client2Port = getNewRandomPort();
    }

    private int getNewRandomPort() {
        // new Ports().tcpPort() returns a random port
        int newPort = new Ports().tcpPort();
        while (newPort == client1Port || newPort == client2Port)
            newPort = new Ports().tcpPort();

        return newPort;
    }
View Full Code Here


   
  }

  private Peer createPeer(int port) throws IOException {
    ChannelServerConfiguration csc = PeerBuilder.createDefaultChannelServerConfiguration();
    csc.ports(new Ports(port, port));
    csc.portsForwarding(new Ports(port, port));
    csc.connectionTimeoutTCPMillis(10 * 1000);
    csc.idleTCPSeconds(10);
    csc.idleUDPSeconds(10);
   
    return new PeerBuilder(new Number160(port)).ports(port).channelServerConfiguration(csc).start();
View Full Code Here

                                peer.peerBean().serverPeerAddress(serverAddress);
                                LOG.info("we were having the wrong interface, change it to: {}", serverAddress);
                            } else {
                                // now we know our internal IP, where we receive
                                // packets
                                final Ports ports = peer.connectionBean().channelServer().channelServerConfiguration().portsForwarding();
                                if (ports.isManualPort()) {
                                  final PeerAddress serverAddressOrig = serverAddress;
                                    serverAddress = serverAddress.changePorts(ports.tcpPort(),
                                            ports.udpPort());
                                    serverAddress = serverAddress.changeAddress(seenAs.inetAddress());
                                    //manual port forwarding detected, set flag
                                    serverAddress = serverAddress.changePortForwarding(true);
                                    peer.peerBean().serverPeerAddress(serverAddress);
                                    peer.peerBean().serverPeerAddress().internalPeerSocketAddress(serverAddressOrig.peerSocketAddress());
View Full Code Here

    //post config
    if(isBehindFirewallSet) {
      channelServerConfiguration.behindFirewall(behindFirewall);
    }
    if(isTcpPortSet || isUdpPortSet) {
      channelServerConfiguration.ports(new Ports(tcpPort, udpPort));
    }
   
    channelServerConfiguration.portsForwarding(new Ports(tcpPortForwarding, udpPortForwarding));
   
    if (channelClientConfiguration == null) {
      channelClientConfiguration = createDefaultChannelClientConfiguration();
    }
    if (keyPair == null) {
View Full Code Here

  public static ChannelServerConfiguration createDefaultChannelServerConfiguration() {
    ChannelServerConfiguration channelServerConfiguration = new ChannelServerConfiguration();
    channelServerConfiguration.bindings(new Bindings());
    //these two values may be overwritten in the peer builder
    channelServerConfiguration.ports(new Ports(Ports.DEFAULT_PORT, Ports.DEFAULT_PORT));
    channelServerConfiguration.portsForwarding(new Ports(Ports.DEFAULT_PORT, Ports.DEFAULT_PORT));
    channelServerConfiguration.behindFirewall(false);
    channelServerConfiguration.pipelineFilter(new DefaultPipelineFilter());
    channelServerConfiguration.signatureFactory(new DSASignatureFactory());
    return channelServerConfiguration;
  }
View Full Code Here

        if (future.reporter() != null) {
          futureNAT.reporter(future.reporter());
        }

        if (future.isFailed() && future.isNat() && !isManualPorts()) {
          Ports externalPorts = setupPortforwarding(future.internalAddress().getHostAddress(), peer
              .connectionBean().channelServer().channelServerConfiguration().portsForwarding());
          if (externalPorts != null) {
            final PeerAddress serverAddressOrig = peer.peerBean().serverPeerAddress();
            final PeerAddress serverAddress = serverAddressOrig
                .changePorts(externalPorts.tcpPort(), externalPorts.udpPort())
                .changeAddress(future.externalAddress());
           
            //set the new address regardless wheter it will succeed or not.
            // The discover will eventually check wheter the announced ip matches the one that it sees.
            peer.peerBean().serverPeerAddress(serverAddress);
View Full Code Here

TOP

Related Classes of net.tomp2p.connection.Ports

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.