| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b25694d commit 3bc0123
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,22 +93,6 @@ const char* MatchPathSegment(const char* path, const char* expected) { | |||
| 93 | 93 | return nullptr; | |
| 94 | 94 | } | |
| 95 | 95 | ||
| 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 | - | ||
| 112 | 96 | void SendHttpResponse(InspectorSocket* socket, const std::string& response) { | |
| 113 | 97 | const char HEADERS[] = "HTTP/1.0 200 OK\r\n" | |
| 114 | 98 | "Content-Type: application/json; charset=UTF-8\r\n" | |
@@ -235,6 +219,25 @@ class ServerSocket { | |||
| 235 | 219 | int port_ = -1; | |
| 236 | 220 | }; | |
| 237 | 221 | ||
| 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 | + | ||
| 238 | 241 | InspectorSocketServer::InspectorSocketServer( | |
| 239 | 242 | std::unique_ptr<SocketServerDelegate> delegate, uv_loop_t* loop, | |
| 240 | 243 | const std::string& host, int port, FILE* out) | |
@@ -276,7 +279,7 @@ void InspectorSocketServer::SessionTerminated(int session_id) { | |||
| 276 | 279 | if (connected_sessions_.empty()) { | |
| 277 | 280 | if (was_attached && state_ == ServerState::kRunning | |
| 278 | 281 | && !server_sockets_.empty()) { | |
| 279 | - PrintDebuggerReadyMessage(host_, server_sockets_[0]->port(), | ||
| 282 | + PrintDebuggerReadyMessage(host_, server_sockets_, | ||
| 280 | 283 | delegate_->GetTargetIds(), out_); | |
| 281 | 284 | } | |
| 282 | 285 | if (state_ == ServerState::kStopped) { | |
@@ -393,8 +396,7 @@ bool InspectorSocketServer::Start() { | |||
| 393 | 396 | } | |
| 394 | 397 | delegate_.swap(delegate_holder); | |
| 395 | 398 | 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_, | ||
| 398 | 400 | delegate_->GetTargetIds(), out_); | |
| 399 | 401 | return true; | |
| 400 | 402 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,10 +73,10 @@ class InspectorSocketServer { | |||
| 73 | 73 | return server_sockets_.empty() && connected_sessions_.empty(); | |
| 74 | 74 | } | |
| 75 | 75 | ||
| 76 | - private: | ||
| 77 | 76 | static void CloseServerSocket(ServerSocket*); | |
| 78 | 77 | using ServerSocketPtr = DeleteFnPtr<ServerSocket, CloseServerSocket>; | |
| 79 | 78 | ||
| 79 | + private: | ||
| 80 | 80 | void SendListResponse(InspectorSocket* socket, const std::string& host, | |
| 81 | 81 | SocketSession* session); | |
| 82 | 82 | std::string GetFrontendURL(bool is_compat, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments