Examples of Socks5Proxy


Examples of nu.fw.jeti.plugins.filetransfer.socks5.jsocks.Socks5Proxy

          //TODO stringprep
         
          String digest =Plugin.sha(sid,backend.getMyJID(),targetJID);
                 
         
          final SocksSocket s = new SocksSocket(new Socks5Proxy(streamHost.getHost(),streamHost.getPort()),digest,0);
    //      TODO get sid?
          final StreamHost chosenStreamHost = streamHost;
          backend.send(new InfoQuery(streamHostID,"set",backend.getIdentifier(),
          new Socks5Extension(sid,targetJID)),new IQResultListener()
          {
View Full Code Here

Examples of nu.fw.jeti.plugins.filetransfer.socks5.jsocks.Socks5Proxy

               
       
        try{
          //Proxy p = new Socks5Proxy("192.168.10.2",5080);
          //TODO add timeout 
          s = new SocksSocket(new Socks5Proxy(streamHost.getHost(),streamHost.getPort()),digest,0);
  //        check if connection is open
          backend.send(new InfoQuery(iq.getFrom(),"result",iq.getID(),
                new Socks5Extension(streamHost.getJID(),null)));
          break;
        }
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy

     */
    @Test
    public void shouldBeASingleton() {
        SmackConfiguration.setLocalSocks5ProxyEnabled(false);

        Socks5Proxy proxy1 = Socks5Proxy.getSocks5Proxy();
        Socks5Proxy proxy2 = Socks5Proxy.getSocks5Proxy();

        assertNotNull(proxy1);
        assertNotNull(proxy2);
        assertSame(proxy1, proxy2);
    }
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy

     * The SOCKS5 proxy should not be started if disabled by configuration.
     */
    @Test
    public void shouldNotBeRunningIfDisabled() {
        SmackConfiguration.setLocalSocks5ProxyEnabled(false);
        Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
        assertFalse(proxy.isRunning());
    }
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy

     * @throws Exception should not happen
     */
    @Test
    public void shouldUseFreePortOnNegativeValues() throws Exception {
        SmackConfiguration.setLocalSocks5ProxyEnabled(false);
        Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
        assertFalse(proxy.isRunning());

        ServerSocket serverSocket = new ServerSocket(0);
        SmackConfiguration.setLocalSocks5ProxyPort(-serverSocket.getLocalPort());

        proxy.start();

        assertTrue(proxy.isRunning());

        serverSocket.close();

        assertTrue(proxy.getPort() > serverSocket.getLocalPort());

    }
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy

     * When inserting new network addresses to the proxy the order should remain in the order they
     * were inserted.
     */
    @Test
    public void shouldPreserveAddressOrderOnInsertions() {
        Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
        List<String> addresses = new ArrayList<String>(proxy.getLocalAddresses());
        addresses.add("1");
        addresses.add("2");
        addresses.add("3");
        for (String address : addresses) {
            proxy.addLocalAddress(address);
        }

        List<String> localAddresses = proxy.getLocalAddresses();
        for (int i = 0; i < addresses.size(); i++) {
            assertEquals(addresses.get(i), localAddresses.get(i));
        }
    }
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy

     * When replacing network addresses of the proxy the order should remain in the order if the
     * given list.
     */
    @Test
    public void shouldPreserveAddressOrderOnReplace() {
        Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
        List<String> addresses = new ArrayList<String>(proxy.getLocalAddresses());
        addresses.add("1");
        addresses.add("2");
        addresses.add("3");

        proxy.replaceLocalAddresses(addresses);

        List<String> localAddresses = proxy.getLocalAddresses();
        for (int i = 0; i < addresses.size(); i++) {
            assertEquals(addresses.get(i), localAddresses.get(i));
        }
    }
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy

     * Inserting the same address multiple times should not cause the proxy to return this address
     * multiple times.
     */
    @Test
    public void shouldNotReturnMultipleSameAddress() {
        Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();

        proxy.addLocalAddress("same");
        proxy.addLocalAddress("same");
        proxy.addLocalAddress("same");

        assertEquals(2, proxy.getLocalAddresses().size());
    }
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy

    @Test
    public void shouldOnlyStartOneServerThread() {
        int threadCount = Thread.activeCount();

        SmackConfiguration.setLocalSocks5ProxyPort(7890);
        Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
        proxy.start();

        assertTrue(proxy.isRunning());
        assertEquals(threadCount + 1, Thread.activeCount());

        proxy.start();

        assertTrue(proxy.isRunning());
        assertEquals(threadCount + 1, Thread.activeCount());

        proxy.stop();

        assertFalse(proxy.isRunning());
        assertEquals(threadCount, Thread.activeCount());

        proxy.start();

        assertTrue(proxy.isRunning());
        assertEquals(threadCount + 1, Thread.activeCount());

        proxy.stop();

    }
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy

     * @throws Exception should not happen
     */
    @Test
    public void shouldCloseSocketIfNoSocks5Request() throws Exception {
        SmackConfiguration.setLocalSocks5ProxyPort(7890);
        Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
        proxy.start();

        Socket socket = new Socket(proxy.getLocalAddresses().get(0), proxy.getPort());

        OutputStream out = socket.getOutputStream();
        out.write(new byte[] { 1, 2, 3 });

        assertEquals(-1, socket.getInputStream().read());

        proxy.stop();

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.