Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DnsLookupTor: Close socket after usage #7279

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions p2p/src/main/java/bisq/network/DnsLookupTor.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@ private static Map<Byte, String> createMap() {
* Performs DNS lookup and returns a single InetAddress
*/
public static InetAddress lookup(Socks5Proxy proxy, String host) throws DnsLookupException {
try {
// note: This is creating a new connection to our proxy, without any authentication.
// This works fine when connecting to bisq's internal Tor proxy, but
// would fail if user has configured an external proxy that requires auth.
// It would be much better to use the already connected proxy socket, but when I
// tried that I get weird errors and the lookup fails.
//
// So this is an area for future improvement.
Socket proxySocket = new Socket(proxy.getInetAddress(), proxy.getPort());

// note: This is creating a new connection to our proxy, without any authentication.
// This works fine when connecting to bisq's internal Tor proxy, but
// would fail if user has configured an external proxy that requires auth.
// It would be much better to use the already connected proxy socket, but when I
// tried that I get weird errors and the lookup fails.
//
// So this is an area for future improvement.
try (Socket proxySocket = new Socket(proxy.getInetAddress(), proxy.getPort())) {
proxySocket.getOutputStream().write(new byte[]{b('\u0005'), b('\u0001'), b('\u0000')});
byte[] buf = new byte[2];
//noinspection ResultOfMethodCallIgnored
Expand Down
Loading