Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 69e3d95

Browse files
authored
Updated local_server_start.go to display the correct listening IP in print statement
When 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.
1 parent 6925d21 commit 69e3d95

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

commands/local_server_start.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,16 @@ var localServerStartCmd = &console.Command{
287287
scheme = "http"
288288
}
289289

290+
address := config.ListenIp
291+
if c.Bool("allow-all-ip") {
292+
address = "0.0.0.0"
293+
}
294+
290295
msg := "Web server listening\n"
291296
if p.PHPServer != nil {
292297
msg += fmt.Sprintf(" The Web server is using %s %s\n", p.PHPServer.Version.ServerTypeName(), p.PHPServer.Version.Version)
293298
}
294-
msg += fmt.Sprintf("\n <href=%s://127.0.0.1:%d>%s://127.0.0.1:%d</>", scheme, port, scheme, port)
299+
msg += fmt.Sprintf("\n <href=%s://%s:%d>%s://%s:%d</>", scheme, address, port, scheme, address, port)
295300
if proxyConf, err := proxy.Load(homeDir); err == nil {
296301
for _, domain := range proxyConf.GetDomains(projectDir) {
297302
msg += fmt.Sprintf("\n <href=%s://%s>%s://%s</>", scheme, domain, scheme, domain)

0 commit comments

Comments
 (0)