com.runjva.sourceforge.jsocks.protocol.SocksSocket Java Examples

The following examples show how to use com.runjva.sourceforge.jsocks.protocol.SocksSocket. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SeedPeersSocks5Dns.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Resolves a hostname via remote DNS over socks5 proxy.
 */
@Nullable
public static InetSocketAddress lookup(Socks5Proxy proxy, InetSocketAddress addr) {
    if (!addr.isUnresolved()) {
        return addr;
    }
    try {
        SocksSocket proxySocket = new SocksSocket(proxy, addr.getHostString(), addr.getPort());
        InetAddress addrResolved = proxySocket.getInetAddress();
        proxySocket.close();
        if (addrResolved != null) {
            log.debug("Resolved " + addr.getHostString() + " to " + addrResolved.getHostAddress());
            return new InetSocketAddress(addrResolved, addr.getPort());
        } else {
            // note: .onion nodes fall in here when proxy is Tor. But they have no IP address.
            // Unfortunately bitcoinj crashes in PeerAddress if it finds an unresolved address.
            log.error("Connected to " + addr.getHostString() + ".  But did not resolve to address.");
        }
    } catch (Exception e) {
        log.warn("Error resolving " + addr.getHostString() + ". Exception:\n" + e.toString());
    }
    return null;
}
 
Example #2
Source File: SeedPeersSocks5Dns.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Resolves a hostname via remote DNS over socks5 proxy.
 */
@Nullable
public static InetSocketAddress lookup(Socks5Proxy proxy, InetSocketAddress addr) {
    if (!addr.isUnresolved()) {
        return addr;
    }
    try {
        SocksSocket proxySocket = new SocksSocket(proxy, addr.getHostString(), addr.getPort());
        InetAddress addrResolved = proxySocket.getInetAddress();
        proxySocket.close();
        if (addrResolved != null) {
            //log.debug("Resolved " + addr.getHostString() + " to " + addrResolved.getHostAddress());
            return new InetSocketAddress(addrResolved, addr.getPort());
        } else {
            // note: .onion nodes fall in here when proxy is Tor. But they have no IP address.
            // Unfortunately bitcoinj crashes in PeerAddress if it finds an unresolved address.
            log.error("Connected to " + addr.getHostString() + ".  But did not resolve to address.");
        }
    } catch (Exception e) {
        log.warn("Error resolving " + addr.getHostString() + ". Exception:\n" + e.toString());
    }
    return null;
}
 
Example #3
Source File: Utilities.java    From T0rlib4j with Apache License 2.0 4 votes vote down vote up
public static Socket Socks5connection(Socks5Proxy proxy, String onionUrl, int HiddenServicePort) throws IOException {
    Socket ssock = new SocksSocket(proxy, onionUrl, HiddenServicePort);
    ssock.setTcpNoDelay(true);
    return ssock;

}