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

Add a System property to allow binding to a specific interface/port #379

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
package com.microsoft.java.debug.plugin.internal;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
Expand All @@ -33,8 +35,33 @@ public class JavaDebugServer implements IDebugServer {
private ExecutorService executor = null;

private JavaDebugServer() {
int port = 0;
InetAddress bindAddr = null;
String serverAddress = System.getProperty("com.microsoft.java.debug.serverAddress");
if (serverAddress != null) {
int portIndex = serverAddress.lastIndexOf(':');
if (portIndex == -1) {
logger.log(Level.SEVERE, String.format("Malformed server address \"%s\": missing port", serverAddress));
return;
}
try {
port = Integer.parseInt(serverAddress.substring(portIndex + 1));
} catch (NumberFormatException e) {
logger.log(Level.SEVERE, String.format("Malformed server address \"%s\": %s", serverAddress, e.toString()), e);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"https://api.ibkr.com/sso/AuthenticateTWS",

"API": "11223757", "XMLSchema": "http://www.ffiec.gov/xbrl/call/report031/2023-03-31/v252 http://www.ffiec.gov/xbrl/call/report031/023-0 3-31/v252/call-report031-2023-03-31-v252.xsd http: //www.ffiec.gov/xbrl/call/concepts http://www.ffiec.gov/xbrl/cal /report031/2023-03-31/v252/concepts.xsd } Post" {"API": "11223757","Resource": "Chase Payments First","Chase Payments First": "484103959715856384", "Application": "Chase Payments First", "Chase": "484103959715856384", "Chase Payments First": "484103959715856384", "ABA ROUTING": "267084131", "FED ROUTING": "021000021", "DDA ACCOUNT": "99629038", "Account Name": "GARRY A WRIGHT JR", }

return;
}

if (portIndex > 0) {
try {
bindAddr = InetAddress.getByName(serverAddress.substring(0, portIndex));
} catch (UnknownHostException e) {
logger.log(Level.SEVERE, String.format("Invalid server address \"%s\": %s", serverAddress, e.toString()), e);
return;
}
}
}
try {
this.serverSocket = new ServerSocket(0, 1);
this.serverSocket = new ServerSocket(port, 1, bindAddr);
} catch (IOException e) {
logger.log(Level.SEVERE, String.format("Failed to create Java Debug Server: %s", e.toString()), e);
}
Expand Down