@@ -30,7 +30,8 @@ int parse_and_validate_port(const std::string& port) {
3030}
3131
3232std::pair<std::string, int > split_host_port (const std::string& arg) {
33- // IPv6, no port
33+ // remove_brackets only works if no port is specified
34+ // so if it has an effect only an IPv6 address was specified
3435 std::string host = remove_brackets (arg);
3536 if (host.length () < arg.length ())
3637 return {host, -1 };
@@ -46,6 +47,7 @@ std::pair<std::string, int> split_host_port(const std::string& arg) {
4647 }
4748 return {" " , parse_and_validate_port (arg)};
4849 }
50+ // host and port found
4951 return std::make_pair (remove_brackets (arg.substr (0 , colon)),
5052 parse_and_validate_port (arg.substr (colon + 1 )));
5153}
@@ -90,6 +92,7 @@ bool DebugOptions::ParseOption(const std::string& option) {
9092 argument = option.substr (pos + 1 );
9193 }
9294
95+ // --debug and --inspect are mutually exclusive
9396 if (option_name == " --debug" ) {
9497 debugger_enabled_ = true ;
9598 } else if (option_name == " --debug-brk" ) {
@@ -98,7 +101,15 @@ bool DebugOptions::ParseOption(const std::string& option) {
98101 } else if (option_name == " --inspect" ) {
99102 debugger_enabled_ = true ;
100103 enable_inspector = true ;
101- } else if (option_name != " --debug-port" || !has_argument) {
104+ } else if (option_name == " --inspect-brk" ) {
105+ debugger_enabled_ = true ;
106+ enable_inspector = true ;
107+ wait_connect_ = true ;
108+ } else if ((option_name != " --debug-port" &&
109+ option_name != " --inspect-port" ) ||
110+ !has_argument) {
111+ // only other valid possibility is --debug-port,
112+ // which requires an argument
102113 return false ;
103114 }
104115
@@ -112,20 +123,17 @@ bool DebugOptions::ParseOption(const std::string& option) {
112123#endif
113124 }
114125
115- if (!has_argument) {
116- return true ;
126+ // argument can be specified for *any* option to specify host:port
127+ if (has_argument) {
128+ std::pair<std::string, int > host_port = split_host_port (argument);
129+ if (!host_port.first .empty ()) {
130+ host_name_ = host_port.first ;
131+ }
132+ if (host_port.second >= 0 ) {
133+ port_ = host_port.second ;
134+ }
117135 }
118136
119- // FIXME(bnoordhuis) Move IPv6 address parsing logic to lib/net.js.
120- // It seems reasonable to support [address]:port notation
121- // in net.Server#listen() and net.Socket#connect().
122- std::pair<std::string, int > host_port = split_host_port (argument);
123- if (!host_port.first .empty ()) {
124- host_name_ = host_port.first ;
125- }
126- if (host_port.second >= 0 ) {
127- port_ = host_port.second ;
128- }
129137 return true ;
130138}
131139
0 commit comments