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 Aug 20, 2024
2 parents eea9ace + 5c1c860 commit 96d0a82
Show file tree
Hide file tree
Showing 2,481 changed files with 285,970 additions and 83,561 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ "ubuntu" ]
go: [ "1.21.9" ]
go: [ "1.22.4" ]
test-type: [ "detector", "coverage", "memory", "custom-build-tags" ]

runs-on: ${{ matrix.os }}-latest
Expand Down Expand Up @@ -80,6 +80,7 @@ jobs:
go test -v -race ./psiphon/common/accesscontrol
go test -v -race ./psiphon/common/crypto/ssh
go test -v -race ./psiphon/common/fragmentor
go test -v -timeout 20m -race -tags "PSIPHON_ENABLE_INPROXY" ./psiphon/common/inproxy
go test -v -race ./psiphon/common/regen
go test -v -race ./psiphon/common/monotime
go test -v -race ./psiphon/common/obfuscator
Expand All @@ -94,7 +95,7 @@ jobs:
go test -v -race ./psiphon/common/values
go test -v -race ./psiphon/common/wildcard
go test -v -race ./psiphon/transferstats
sudo -E env "PATH=$PATH" go test -v -timeout 20m -race -tags "PSIPHON_RUN_PACKET_MANIPULATOR_TEST" ./psiphon/server
sudo -E env "PATH=$PATH" go test -v -timeout 20m -race -tags "PSIPHON_ENABLE_INPROXY PSIPHON_RUN_PACKET_MANIPULATOR_TEST" ./psiphon/server
go test -v -race ./psiphon/server/psinet
go test -v -timeout 20m -race ./psiphon
go test -v -race ./ClientLibrary/clientlib
Expand All @@ -112,6 +113,7 @@ jobs:
go test -v -covermode=count -coverprofile=accesscontrol.coverprofile ./psiphon/common/accesscontrol
go test -v -covermode=count -coverprofile=ssh.coverprofile ./psiphon/common/crypto/ssh
go test -v -covermode=count -coverprofile=fragmentor.coverprofile ./psiphon/common/fragmentor
go test -v -timeout 20m -covermode=count -tags "PSIPHON_ENABLE_INPROXY" -coverprofile=inproxy.coverprofile ./psiphon/common/inproxy
go test -v -covermode=count -coverprofile=regen.coverprofile ./psiphon/common/regen
go test -v -covermode=count -coverprofile=monotime.coverprofile ./psiphon/common/monotime
go test -v -covermode=count -coverprofile=obfuscator.coverprofile ./psiphon/common/obfuscator
Expand All @@ -126,9 +128,9 @@ jobs:
go test -v -covermode=count -coverprofile=values.coverprofile ./psiphon/common/values
go test -v -covermode=count -coverprofile=wildcard.coverprofile ./psiphon/common/wildcard
go test -v -covermode=count -coverprofile=transferstats.coverprofile ./psiphon/transferstats
sudo -E env "PATH=$PATH" go test -v -timeout 20m -covermode=count -coverprofile=server.coverprofile -tags "PSIPHON_RUN_PACKET_MANIPULATOR_TEST" ./psiphon/server
sudo -E env "PATH=$PATH" go test -v -timeout 20m -covermode=count -coverprofile=server.coverprofile -tags "PSIPHON_ENABLE_INPROXY PSIPHON_RUN_PACKET_MANIPULATOR_TEST" ./psiphon/server
go test -v -covermode=count -coverprofile=psinet.coverprofile ./psiphon/server/psinet
go test -v -timeout 20m -covermode=count -coverprofile=psiphon.coverprofile ./psiphon
go test -v -timeout 20m -covermode=count -coverprofile=psiphon.coverprofile ./psiphon
go test -v -covermode=count -coverprofile=clientlib.coverprofile ./ClientLibrary/clientlib
go test -v -covermode=count -coverprofile=analysis.coverprofile ./Server/logging/analysis
$GOPATH/bin/gover
Expand All @@ -145,6 +147,8 @@ jobs:
if: ${{ matrix.test-type == 'custom-build-tags' }}
run: |
cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient
go build -a -v -tags ""
go build -a -v -tags "PSIPHON_ENABLE_INPROXY"
go build -a -v -tags "PSIPHON_DISABLE_QUIC"
go build -a -v -tags "PSIPHON_DISABLE_GQUIC"
go build -a -v -tags "PSIPHON_ENABLE_REFRACTION_NETWORKING"
2 changes: 1 addition & 1 deletion ClientLibrary/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \

# Install Go.
# NOTE: Go 1.10+ is required to build c-shared for windows (https://github.com/golang/go/commit/bb0bfd002ada7e3eb9198d4287b32c2fed6e8da6)
ENV GOVERSION=go1.21.9 GOROOT=/usr/local/go GOPATH=/go PATH=$PATH:/usr/local/go/bin:/go/bin CGO_ENABLED=1
ENV GOVERSION=go1.22.4 GOROOT=/usr/local/go GOPATH=/go PATH=$PATH:/usr/local/go/bin:/go/bin CGO_ENABLED=1

RUN curl -L https://storage.googleapis.com/golang/$GOVERSION.linux-amd64.tar.gz -o /tmp/go.tar.gz \
&& tar -C /usr/local -xzf /tmp/go.tar.gz \
Expand Down
4 changes: 2 additions & 2 deletions ClientLibrary/build-darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ if [ -z ${2+x} ]; then BUILD_TAGS=""; else BUILD_TAGS="$2"; fi
# Note:
# clangwrap.sh needs to be updated when the Go version changes.
# The last version was:
# https://github.com/golang/go/blob/go1.21.9/misc/ios/clangwrap.sh
GO_VERSION_REQUIRED="1.21.9"
# https://github.com/golang/go/blob/go1.22.4/misc/ios/clangwrap.sh
GO_VERSION_REQUIRED="1.22.4"

BASE_DIR=$(cd "$(dirname "$0")" ; pwd -P)
cd ${BASE_DIR}
Expand Down
2 changes: 1 addition & 1 deletion ConsoleClient/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

# Install Go.
ENV GOVERSION=go1.21.9 GOROOT=/usr/local/go GOPATH=/go PATH=$PATH:/usr/local/go/bin:/go/bin CGO_ENABLED=1
ENV GOVERSION=go1.22.4 GOROOT=/usr/local/go GOPATH=/go PATH=$PATH:/usr/local/go/bin:/go/bin CGO_ENABLED=1

RUN curl -L https://storage.googleapis.com/golang/$GOVERSION.linux-amd64.tar.gz -o /tmp/go.tar.gz \
&& tar -C /usr/local -xzf /tmp/go.tar.gz \
Expand Down
2 changes: 1 addition & 1 deletion ConsoleClient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func main() {
psiphon.NoticeInfo("write profiles")
profileSampleDurationSeconds := 5
common.WriteRuntimeProfiles(
psiphon.NoticeCommonLogger(),
psiphon.NoticeCommonLogger(false),
config.DataRootDirectory,
"",
profileSampleDurationSeconds,
Expand Down
2 changes: 1 addition & 1 deletion MobileLibrary/Android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

# Install Go.
ENV GOVERSION=go1.21.9 GOROOT=/usr/local/go GOPATH=/go PATH=$PATH:/usr/local/go/bin:/go/bin CGO_ENABLED=1
ENV GOVERSION=go1.22.4 GOROOT=/usr/local/go GOPATH=/go PATH=$PATH:/usr/local/go/bin:/go/bin CGO_ENABLED=1

RUN curl -L https://storage.googleapis.com/golang/$GOVERSION.linux-amd64.tar.gz -o /tmp/go.tar.gz \
&& tar -C /usr/local -xzf /tmp/go.tar.gz \
Expand Down
30 changes: 28 additions & 2 deletions MobileLibrary/Android/PsiphonTunnel/PsiphonTunnel.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ default public void onActiveAuthorizationIDs(List<String> authorizations) {}
default public void onTrafficRateLimits(long upstreamBytesPerSecond, long downstreamBytesPerSecond) {}
default public void onApplicationParameters(Object parameters) {}
default public void onServerAlert(String reason, String subject, List<String> actionURLs) {}
/**
* Called when tunnel-core emits a message to be displayed to the in-proxy operator.
* @param message The operator message received.
*/
default void onInproxyOperatorMessage(String message) {}
/**
* Called when tunnel-core reports proxy usage statistics.
* By default onInproxyProxyActivity is disabled. Enable it by setting
* EmitInproxyProxyActivity to true in the Psiphon config.
* @param connectingClients Number of clients connecting to the proxy.
* @param connectedClients Number of clients currently connected to the proxy.
* @param bytesUp Bytes uploaded through the proxy since the last report.
* @param bytesDown Bytes downloaded through the proxy since the last report.
*/
default void onInproxyProxyActivity(int connectingClients, int connectedClients,long bytesUp, long bytesDown) {}
/**
* Called when tunnel-core reports connected server region information.
* @param region The server region received.
Expand Down Expand Up @@ -1100,6 +1115,15 @@ private void handlePsiphonNotice(String noticeJSON) {
notice.getJSONObject("data").getString("reason"),
notice.getJSONObject("data").getString("subject"),
actionURLsList);
} else if (noticeType.equals("InproxyOperatorMessage")) {
mHostService.onInproxyOperatorMessage( notice.getJSONObject("data").getString("message"));
} else if (noticeType.equals("InproxyProxyActivity")) {
JSONObject data = notice.getJSONObject("data");
mHostService.onInproxyProxyActivity(
data.getInt("connectingClients"),
data.getInt("connectedClients"),
data.getLong("bytesUp"),
data.getLong("bytesDown"));
}

if (diagnostic) {
Expand Down Expand Up @@ -1520,10 +1544,12 @@ private static boolean hasIPv6Route(Context context) throws Exception {
// 40569). hasIPv6Route provides the same functionality via a
// callback into Java code.

// Note: don't exclude interfaces with the isPointToPoint
// property, which is true for certain mobile networks.

for (NetworkInterface netInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
if (netInterface.isUp() &&
!netInterface.isLoopback() &&
!netInterface.isPointToPoint()) {
!netInterface.isLoopback()) {
for (InetAddress address : Collections.list(netInterface.getInetAddresses())) {

// Per https://developer.android.com/reference/java/net/Inet6Address#textual-representation-of-ip-addresses,
Expand Down
3 changes: 1 addition & 2 deletions MobileLibrary/go-mobile/app/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build android
// +build android

/*
Android Apps are built with -buildmode=c-shared. They are loaded by a
Expand Down Expand Up @@ -366,7 +365,7 @@ func runInputQueue(vm, jniEnv, ctx uintptr) error {

var q *C.AInputQueue
for {
if C.ALooper_pollAll(-1, nil, nil, nil) == C.ALOOPER_POLL_WAKE {
if C.ALooper_pollOnce(-1, nil, nil, nil) == C.ALOOPER_POLL_WAKE {
select {
default:
case p := <-pending:
Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build linux || darwin || windows
// +build linux darwin windows

package app

Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/app/darwin_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build darwin && !ios
// +build darwin,!ios

package app

Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/app/darwin_ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build darwin && ios
// +build darwin,ios

package app

Expand Down
2 changes: 0 additions & 2 deletions MobileLibrary/go-mobile/app/internal/callfn/callfn.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// license that can be found in the LICENSE file.

//go:build android && (arm || 386 || amd64 || arm64)
// +build android
// +build arm 386 amd64 arm64

// Package callfn provides an android entry point.
//
Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/app/internal/testapp/testapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build darwin || linux
// +build darwin linux

// Small test app used by app/app_test.go.
package main
Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/app/shiny.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build windows
// +build windows

package app

Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/app/x11.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build linux && !android
// +build linux,!android

package app

Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build darwin || linux || windows
// +build darwin linux windows

package asset

Expand Down
2 changes: 0 additions & 2 deletions MobileLibrary/go-mobile/asset/asset_darwin_armx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// license that can be found in the LICENSE file.

//go:build darwin && (arm || arm64)
// +build darwin
// +build arm arm64

package asset

Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/asset/asset_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build (linux && !android) || (darwin && !arm && !arm64) || windows
// +build linux,!android darwin,!arm,!arm64 windows

package asset

Expand Down
2 changes: 1 addition & 1 deletion MobileLibrary/go-mobile/bind/genobjc.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ func (g *ObjcGen) genInterfaceMethodProxy(obj *types.TypeName, m *types.Func) {

if isErrorType(obj.Type()) && m.Name() == "Error" {
// As a special case, ObjC NSErrors are passed to Go pretending to implement the Go error interface.
// They don't actually have an Error method, so calls to to it needs to be rerouted.
// They don't actually have an Error method, so calls to it needs to be rerouted.
g.Printf("%s = [o localizedDescription];\n", s.retParams[0].name)
} else {
if s.ret == "void" {
Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/bind/implicit.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// This file imports implicit dependencies required by generated code.

//go:build mobile_implicit
// +build mobile_implicit

package bind

Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/bind/testdata/testpkg/tagged.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build aaa && bbb
// +build aaa,bbb

// This file tests that tags work with gomobile.
package testpkg
Expand Down
2 changes: 1 addition & 1 deletion MobileLibrary/go-mobile/cmd/gobind/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ to create an Android Activity subclass MainActivity:
Gobind also recognizes Java interfaces as well as Objective C classes and
protocols the same way.
For more details on binding the the native API, see the design proposals,
For more details on binding the native API, see the design proposals,
https://golang.org/issues/16876 (Java) and https://golang.org/issues/17102
(Objective C).
Expand Down
1 change: 0 additions & 1 deletion MobileLibrary/go-mobile/cmd/gobind/implicit.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// This file imports implicit dependencies required by generated code.

//go:build mobile_implicit
// +build mobile_implicit

package main

Expand Down
31 changes: 26 additions & 5 deletions MobileLibrary/go-mobile/cmd/gomobile/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ example, in Android Studio (1.2+), an AAR file can be imported using
the module import wizard (File > New > New Module > Import .JAR or
.AAR package), and setting it as a new dependency
(File > Project Structure > Dependencies). This requires 'javac'
(version 1.7+) and Android SDK (API level 16 or newer) to build the
(version 1.8+) and Android SDK (API level 16 or newer) to build the
library for Android. The ANDROID_HOME and ANDROID_NDK_HOME environment
variables can be used to specify the Android SDK and NDK if they are
not in the default locations. Use the -javapkg flag to specify the Java
Expand Down Expand Up @@ -251,7 +251,9 @@ func getModuleVersions(targetPlatform string, targetArch string, src string) (*m
}

f := &modfile.File{}
f.AddModuleStmt("gobind")
if err := f.AddModuleStmt("gobind"); err != nil {
return nil, err
}
e := json.NewDecoder(bytes.NewReader(output))
for {
var mod *Module
Expand All @@ -266,20 +268,39 @@ func getModuleVersions(targetPlatform string, targetArch string, src string) (*m
// replaced by a local directory
p = mod.Replace.Dir
}
f.AddReplace(mod.Path, mod.Version, p, v)
if err := f.AddReplace(mod.Path, mod.Version, p, v); err != nil {
return nil, err
}
} else {
// When the version part is empty, the module is local and mod.Dir represents the location.
if v := mod.Version; v == "" {
f.AddReplace(mod.Path, mod.Version, mod.Dir, "")
if err := f.AddReplace(mod.Path, mod.Version, mod.Dir, ""); err != nil {
return nil, err
}
} else {
f.AddRequire(mod.Path, v)
if err := f.AddRequire(mod.Path, v); err != nil {
return nil, err
}
}
}
}
if err == io.EOF {
break
}
}

v, err := ensureGoVersion()
if err != nil {
return nil, err
}
// ensureGoVersion can return an empty string for a devel version. In this case, use the minimum version.
if v == "" {
v = fmt.Sprintf("go1.%d", minimumGoMinorVersion)
}
if err := f.AddGoStmt(strings.TrimPrefix(v, "go")); err != nil {
return nil, err
}

return f, nil
}

Expand Down
2 changes: 1 addition & 1 deletion MobileLibrary/go-mobile/cmd/gomobile/bind_androidapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func buildAAR(srcDir, androidDir string, pkgs []*packages.Package, targets []tar
}

const (
javacTargetVer = "1.7"
javacTargetVer = "1.8"
minAndroidAPI = 16
)

Expand Down
Loading

0 comments on commit 96d0a82

Please sign in to comment.