Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3bc0123

Browse filesBrowse files
bnoordhuisBridgeAR
authored andcommitted
inspector: print all listening addresses
Some hostnames have multiple interfaces. Before this commit, the inspector only printed the first one. Now, it prints them all. No test. I can't think of a reliable way to test this on the CI matrix. PR-URL: #26008 Fixes: #13772 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent b25694d commit 3bc0123
Copy full SHA for 3bc0123

File tree

Expand file treeCollapse file tree

2 files changed

+22
-20
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-20
lines changed
Open diff view settings
Collapse file

‎src/inspector_socket_server.cc‎

Copy file name to clipboardExpand all lines: src/inspector_socket_server.cc
+21-19Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,6 @@ const char* MatchPathSegment(const char* path, const char* expected) {
9393
return nullptr;
9494
}
9595

96-
void PrintDebuggerReadyMessage(const std::string& host,
97-
int port,
98-
const std::vector<std::string>& ids,
99-
FILE* out) {
100-
if (out == nullptr) {
101-
return;
102-
}
103-
for (const std::string& id : ids) {
104-
fprintf(out, "Debugger listening on %s\n",
105-
FormatWsAddress(host, port, id, true).c_str());
106-
}
107-
fprintf(out, "For help, see: %s\n",
108-
"https://nodejs.org/en/docs/inspector");
109-
fflush(out);
110-
}
111-
11296
void SendHttpResponse(InspectorSocket* socket, const std::string& response) {
11397
const char HEADERS[] = "HTTP/1.0 200 OK\r\n"
11498
"Content-Type: application/json; charset=UTF-8\r\n"
@@ -235,6 +219,25 @@ class ServerSocket {
235219
int port_ = -1;
236220
};
237221

222+
void PrintDebuggerReadyMessage(
223+
const std::string& host,
224+
const std::vector<InspectorSocketServer::ServerSocketPtr>& server_sockets,
225+
const std::vector<std::string>& ids,
226+
FILE* out) {
227+
if (out == nullptr) {
228+
return;
229+
}
230+
for (const auto& server_socket : server_sockets) {
231+
for (const std::string& id : ids) {
232+
fprintf(out, "Debugger listening on %s\n",
233+
FormatWsAddress(host, server_socket->port(), id, true).c_str());
234+
}
235+
}
236+
fprintf(out, "For help, see: %s\n",
237+
"https://nodejs.org/en/docs/inspector");
238+
fflush(out);
239+
}
240+
238241
InspectorSocketServer::InspectorSocketServer(
239242
std::unique_ptr<SocketServerDelegate> delegate, uv_loop_t* loop,
240243
const std::string& host, int port, FILE* out)
@@ -276,7 +279,7 @@ void InspectorSocketServer::SessionTerminated(int session_id) {
276279
if (connected_sessions_.empty()) {
277280
if (was_attached && state_ == ServerState::kRunning
278281
&& !server_sockets_.empty()) {
279-
PrintDebuggerReadyMessage(host_, server_sockets_[0]->port(),
282+
PrintDebuggerReadyMessage(host_, server_sockets_,
280283
delegate_->GetTargetIds(), out_);
281284
}
282285
if (state_ == ServerState::kStopped) {
@@ -393,8 +396,7 @@ bool InspectorSocketServer::Start() {
393396
}
394397
delegate_.swap(delegate_holder);
395398
state_ = ServerState::kRunning;
396-
// getaddrinfo sorts the addresses, so the first port is most relevant.
397-
PrintDebuggerReadyMessage(host_, server_sockets_[0]->port(),
399+
PrintDebuggerReadyMessage(host_, server_sockets_,
398400
delegate_->GetTargetIds(), out_);
399401
return true;
400402
}
Collapse file

‎src/inspector_socket_server.h‎

Copy file name to clipboardExpand all lines: src/inspector_socket_server.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ class InspectorSocketServer {
7373
return server_sockets_.empty() && connected_sessions_.empty();
7474
}
7575

76-
private:
7776
static void CloseServerSocket(ServerSocket*);
7877
using ServerSocketPtr = DeleteFnPtr<ServerSocket, CloseServerSocket>;
7978

79+
private:
8080
void SendListResponse(InspectorSocket* socket, const std::string& host,
8181
SocketSession* session);
8282
std::string GetFrontendURL(bool is_compat,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.