mirror of
https://github.com/golang/go
synced 2024-11-18 16:44:43 -07:00
aa4048aca1
When running gopls as a forwarder it attempts to forward the LSP to a remote daemon. On posix systems, by default this uses a unix domain socket at a predictable filesystem location. As an extra precaution, attempt to verify that the remote socket is in fact owned by the current user. Also, change the default TCP listen address used on windows to bind to localhost. Updates golang/go#34111 Change-Id: Ib24886d290089a773851c5439586c3ddc9eb797d Reviewed-on: https://go-review.googlesource.com/c/tools/+/222246 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
// Copyright 2020 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package lsprpc
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
)
|
|
|
|
var (
|
|
startRemote = startRemoteDefault
|
|
autoNetworkAddress = autoNetworkAddressDefault
|
|
verifyRemoteOwnership = verifyRemoteOwnershipDefault
|
|
)
|
|
|
|
func startRemoteDefault(goplsPath string, args ...string) error {
|
|
cmd := exec.Command(goplsPath, args...)
|
|
if err := cmd.Start(); err != nil {
|
|
return fmt.Errorf("starting remote gopls: %v", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// autoNetworkAddress returns the default network and address for the
|
|
// automatically-started gopls remote. See autostart_posix.go for more
|
|
// information.
|
|
func autoNetworkAddressDefault(goplsPath, id string) (network string, address string) {
|
|
if id != "" {
|
|
panic("identified remotes are not supported on windows")
|
|
}
|
|
return "tcp", "localhost:37374"
|
|
}
|
|
|
|
func verifyRemoteOwnershipDefault(network, address string) (bool, error) {
|
|
return true, nil
|
|
}
|