Skip to content

Commit

Permalink
Patch ReadDebugInfo issue in inproxy/portmapper dependency check
Browse files Browse the repository at this point in the history
  • Loading branch information
rod-hynes committed Dec 10, 2024
1 parent 88c1b99 commit 24d28f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
16 changes: 14 additions & 2 deletions psiphon/common/inproxy/portmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,24 @@ func newPortMapper(
var portmapperDependencyVersionCheck bool

func init() {
expectedDependencyVersion := "v1.58.2"

// portmapper.Version is a temporary vendor patch, in the dependency, to
// accomodate GOPATH builds which cannot use debug.ReadBuildInfo, and go
// tests, before Go 1.24, which don't get dependency info in the returned
// BuildInfo.
//
// TODO: replace temporary patch with full fork of portmapper, and remove
// this temporary case, if not the entire dependency version check
// (see "TODO: fork" in cloneProbe).
portmapperDependencyVersionCheck = portmapper.Version == expectedDependencyVersion

buildInfo, ok := debug.ReadBuildInfo()
if !ok {
return
}
for _, dep := range buildInfo.Deps {
if dep.Path == "tailscale.com" && dep.Version == "v1.58.2" {
if dep.Path == "tailscale.com" && dep.Version == expectedDependencyVersion {
portmapperDependencyVersionCheck = true
return
}
Expand All @@ -166,7 +178,7 @@ func (p *portMapper) cloneProbe(probe *PortMappingProbe) error {
// The required portmapper.Client fields are not exported by
// tailscale/net/portmapper, so unsafe reflection is used to copy the
// values. A simple portmapper.Client struct copy can't be performed as
// the struct contain a sync.Mutex field.
// the struct contains a sync.Mutex field.
//
// The following is assumed, based on the pinned dependency version:
//
Expand Down
8 changes: 8 additions & 0 deletions vendor/tailscale.com/net/portmapper/portmapper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 24d28f1

Please sign in to comment.