79776450

Date: 2025-09-26 23:28:33
Score: 1
Natty:
Report link
import okhttp3.*;
import javax.net.SocketFactory;

import fucksocks.client.Socks5;
import fucksocks.client.SocksProxy;
import fucksocks.client.SocksSocket;

import java.net.*;
import java.io.IOException;

public class MinimalErrorReproduction {
    
    static class SocksLibSocketFactory extends SocketFactory {
        private final SocksProxy socksProxy;
        
        public SocksLibSocketFactory(String proxyHost, int proxyPort, String username, String password) {
            // Use the constructor that accepts username/password directly
            this.socksProxy = new Socks5(new InetSocketAddress(proxyHost, proxyPort), username, password);
        }
        
        @Override
        public Socket createSocket() throws IOException {
            return new Socket();
        }
        
        @Override
        public Socket createSocket(String host, int port) throws IOException {
            return new SocksSocket(socksProxy, new InetSocketAddress(host, port));
        }
        
        @Override
        public Socket createSocket(InetAddress host, int port) throws IOException {
            return new SocksSocket(socksProxy, new InetSocketAddress(host, port));
        }
        
        @Override
        public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException {
            Socket socket = createSocket(host, port);
            socket.bind(new InetSocketAddress(localHost, localPort));
            return socket;
        }
        
        @Override
        public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException {
            return createSocket(address.getHostAddress(), port, localAddress, localPort);
        }
    }
    
    public static void main(String[] args) {
        try {
            String proxyHost = "proxy.soax.com";
            int proxyPort = 5000;
            String proxyUsername = Settings.PROXY_USERNAME;
            String proxyPassword = Settings.PROXY_PASSWORD;

            OkHttpClient client = new OkHttpClient.Builder()
                .socketFactory(new SocksLibSocketFactory(proxyHost, proxyPort, proxyUsername, proxyPassword))
                .build();

            Request request = new Request.Builder()
                .url("https://httpbin.org/ip")
                .build();

            Response response = client.newCall(request).execute();
            System.out.println("Response code: " + response.code());
            System.out.println("Response body: " + response.body().string());
            response.close();

        } catch (IOException e) {
            System.err.println("ERROR: " + e.getMessage());
            e.printStackTrace();
        }
    }
}

Figured it out!

Reasons:
  • Blacklisted phrase (2): fuck
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Jacob