Skip to content

Commit

Permalink
Merge branch 'master' into staging-client
Browse files Browse the repository at this point in the history
  • Loading branch information
rod-hynes committed Dec 10, 2024
2 parents ea33624 + dcf3d70 commit 83ab957
Show file tree
Hide file tree
Showing 3 changed files with 44 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
22 changes: 22 additions & 0 deletions psiphon/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ import (
// The return value is a payload that may be exchanged with another client;
// when "", the export failed and a diagnostic notice has been logged.
func ExportExchangePayload(config *Config) string {

// Handle in-proxy limitations. The outer client should not call exchange
// in these cases in the first place, but these checks ensure we don't
// export invalid payloads.
//
// If running in proxy-only mode, no payload is exported, since there is
// not necessarily any recently successful server entry.
//
// If running in personal pairing tunnel, no payload is exported, since
// the receiving outer client needs to be aware of and configure personal
// pairing mode, but the payload is currently opaque to the outer client.
if config.DisableTunnels {
NoticeWarning(
"ExportExchangePayload skipped due to DisableTunnels")
return ""
}
if config.networkIDGetter.config.IsInproxyClientPersonalPairingMode() {
NoticeWarning(
"ExportExchangePayload skipped due to IsInproxyClientPersonalPairingMode")
return ""
}

payload, err := exportExchangePayload(config)
if err != nil {
NoticeWarning("ExportExchangePayload failed: %s", errors.Trace(err))
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 83ab957

Please sign in to comment.