Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork125
Updated local_server_start.go to display the correct listening IP in …#589
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…print statementWhen starting the local server using the `server:start` or `local:server:start` commands, a console success message is printed that displays the PHP version, port, and listening IP address.The address that is printed is hard-coded to display 127.0.0.1. The `--listen-ip` option allows the listening IP to be set to any IP the interface has, and the `--allow-all-ip` option effectively sets the listening IP to the "all IPs" address (0.0.0.0 for IPv4 and [::] for IPv6).This change creates an `address` variable that is equal to the `--listen-ip` option value (which defaults to 127.0.0.1 if not set) or 0.0.0.0 if `--allow-all-ip` is passed.The corrected debug statement makes it clear that these options were correctly applied by the user and eliminates the situation (that I experienced) where I believed the server was only listening on localhost and I was somehow not specifying the `--listen-ip` option correctly (until I called `netstat` to check what IP it was actually listening on.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| msg+=fmt.Sprintf(" The Web server is using %s %s\n",p.PHPServer.Version.ServerTypeName(),p.PHPServer.Version.Version) | ||
| } | ||
| msg+=fmt.Sprintf("\n <href=%s://127.0.0.1:%d>%s://127.0.0.1:%d</>",scheme,port,scheme,port) | ||
| msg+=fmt.Sprintf("\n <href=%s://%s:%d>%s://%s:%d</>",scheme,address,port,scheme,address,port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this implementation will show an unreachable address when the address is 0.0.0.0 so I’m wondering if we should not display a completely different message in such case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ah, true, this link would be broken, didn't even think of that.
Perhaps leave the href= set to localhost but display the 0.0.0.0 link text in such situations?
Alternatively, but a bit more complicated, use the host name/domain of the machine for the href= ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Using the hostname or domain seems fragile as they might not resolve to the IP selected by the user (and adds the complexity of discovering them for an edge case).
I believe it's best to use a different message or remove the link when we listen on all available IP.
(To be noted, we already show the domain names attached to the proxy)
(my bad)Co-authored-by: Tugdual Saunier <tucksaun@users.noreply.github.com>
Co-authored-by: Tugdual Saunier <tucksaun@users.noreply.github.com>
…print statement
When starting the local server using the
server:startorlocal:server:startcommands, a console success message is printed that displays the PHP version, port, and listening IP address.The address that is printed is hard-coded to display 127.0.0.1. The
--listen-ipoption allows the listening IP to be set to any IP the interface has, and the--allow-all-ipoption effectively sets the listening IP to the "all IPs" address (0.0.0.0 for IPv4 and [::] for IPv6).This change creates an
addressvariable that is equal to the--listen-ipoption value (which defaults to 127.0.0.1 if not set) or 0.0.0.0 if--allow-all-ipis passed.The corrected debug statement makes it clear that these options were correctly applied by the user and eliminates the situation (that I experienced) where I believed the server was only listening on localhost and I was somehow not specifying the
--listen-ipoption correctly (until I callednetstatto check what IP it was actually listening on.