Skip to content

Commit

Permalink
Merge branch 'Psiphon-Labs:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
artenax authored Mar 21, 2023
2 parents cb38d60 + e098572 commit 0957d35
Show file tree
Hide file tree
Showing 387 changed files with 26,880 additions and 3,810 deletions.
2 changes: 1 addition & 1 deletion .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.19.2" ]
go: [ "1.19.6" ]
test-type: [ "detector", "coverage", "memory" ]

runs-on: ${{ matrix.os }}-latest
Expand Down
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.19.2 GOROOT=/usr/local/go GOPATH=/go PATH=$PATH:/usr/local/go/bin:/go/bin CGO_ENABLED=1
ENV GOVERSION=go1.19.6 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.19.2/misc/ios/clangwrap.sh
GO_VERSION_REQUIRED="1.19.2"
# https://github.com/golang/go/blob/go1.19.6/misc/ios/clangwrap.sh
GO_VERSION_REQUIRED="1.19.6"

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.19.2 GOROOT=/usr/local/go GOPATH=/go PATH=$PATH:/usr/local/go/bin:/go/bin CGO_ENABLED=1
ENV GOVERSION=go1.19.6 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 MobileLibrary/Android/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.19.2 GOROOT=/usr/local/go GOPATH=/go PATH=$PATH:/usr/local/go/bin:/go/bin CGO_ENABLED=1
ENV GOVERSION=go1.19.6 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
262 changes: 182 additions & 80 deletions MobileLibrary/Android/PsiphonTunnel/PsiphonTunnel.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion MobileLibrary/Android/make.bash
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export GOCACHE=/tmp

BUILDINFOFILE="psiphon-tunnel-core_buildinfo.txt"
BUILDDATE=$(date --iso-8601=seconds)
BUILDREPO=$(git config --get remote.origin.url)
BUILDREPO="https://github.com/Psiphon-Labs/psiphon-tunnel-core.git"
BUILDREV=$(git rev-parse --short HEAD)
GOVERSION=$(go version | perl -ne '/go version (.*?) / && print $1')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ NS_ASSUME_NONNULL_BEGIN
/// currentNetworkStatus is NetworkReachabilityReachableViaWired.
/// @param currentNetworkStatus Used to determine network ID and, on iOS <12, to determine the active interface when
/// currentNetworkStatus is NetworkReachabilityReachableViaWired.
/// @param tunnelWholeDevice False if library is used in non-VPN mode, true otherwise.
/// @param outWarn If non-nil, then a non-fatal error occurred while determining the network ID and a valid network ID will still be returned.
+ (NSString *)getNetworkIDWithReachability:(id<ReachabilityProtocol>)reachability
andCurrentNetworkStatus:(NetworkReachability)currentNetworkStatus
tunnelWholeDevice:(BOOL)tunnelWholeDevice
warning:(NSError *_Nullable *_Nonnull)outWarn;

@end
Expand Down
14 changes: 14 additions & 0 deletions MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/Network/NetworkID.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,24 @@ @implementation NetworkID
// See comment in header.
+ (NSString *)getNetworkIDWithReachability:(id<ReachabilityProtocol>)reachability
andCurrentNetworkStatus:(NetworkReachability)currentNetworkStatus
tunnelWholeDevice:(BOOL)tunnelWholeDevice
warning:(NSError *_Nullable *_Nonnull)outWarn {

*outWarn = nil;

// NetworkID is "VPN" if the library is used in non-VPN mode,
// and an active VPN is found on the system.
// This method is not exact and relies on CFNetworkCopySystemProxySettings,
// specifically it may not return tun interfaces for some VPNs on macOS.
if (!tunnelWholeDevice) {
NSDictionary *_Nullable proxies = (__bridge NSDictionary *) CFNetworkCopySystemProxySettings();
for (NSString *interface in [proxies[@"__SCOPED__"] allKeys]) {
if ([interface containsString:@"tun"] || [interface containsString:@"tap"] || [interface containsString:@"ppp"] || [interface containsString:@"ipsec"]) {
return @"VPN";
}
}
}

NSMutableString *networkID = [NSMutableString stringWithString:@"UNKNOWN"];
if (currentNetworkStatus == NetworkReachabilityReachableViaWiFi) {
[networkID setString:@"WIFI"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ NS_ASSUME_NONNULL_BEGIN

@interface PsiphonProviderNetwork : NSObject <GoPsiPsiphonProviderNetwork>

- (instancetype)initWithLogger:(void (^__nonnull)(NSString *_Nonnull))logger;
- (instancetype)init NS_UNAVAILABLE;

- (instancetype)initWithTunnelWholeDevice:(BOOL)tunnelWholeDevice
logger:(void (^__nonnull)(NSString *_Nonnull))logger NS_DESIGNATED_INITIALIZER;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,20 @@

@implementation PsiphonProviderNetwork {
id<ReachabilityProtocol> reachability;
BOOL tunnelWholeDevice;
void (^logger) (NSString *_Nonnull);
}

- (void)initialize {
if (@available(iOS 12.0, *)) {
self->reachability = [[DefaultRouteMonitor alloc] init];
} else {
self->reachability = [Reachability reachabilityForInternetConnection];
}
}

- (id)init {
self = [super init];
if (self) {
[self initialize];
}
return self;
}

- (instancetype)initWithLogger:(void (^__nonnull)(NSString *_Nonnull))logger {
- (instancetype)initWithTunnelWholeDevice:(BOOL)tunnelWholeDevice
logger:(void (^__nonnull)(NSString *_Nonnull))logger {
self = [super init];
if (self) {
[self initialize];
if (@available(iOS 12.0, *)) {
self->reachability = [[DefaultRouteMonitor alloc] init];
} else {
self->reachability = [Reachability reachabilityForInternetConnection];
}
self->tunnelWholeDevice = tunnelWholeDevice;
self->logger = logger;
}
return self;
Expand All @@ -74,6 +65,7 @@ - (NSString *)getNetworkID {
NSError *warn;
NSString *networkID = [NetworkID getNetworkIDWithReachability:self->reachability
andCurrentNetworkStatus:self->reachability.reachabilityStatus
tunnelWholeDevice:self->tunnelWholeDevice
warning:&warn];
if (warn != nil) {
[self logMessage:[NSString stringWithFormat:@"error getting network ID: %@", warn.localizedDescription]];
Expand Down
12 changes: 0 additions & 12 deletions MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,18 +408,6 @@ Returns the path where the rotated notices file will be created.
*/
- (long)getPacketTunnelMTU;

/*!
Only valid in whole device mode. Provides the DNS resolver IP address that is provided by the packet tunnel to the device.
@return The IP address of the DNS resolver as a string.
*/
- (NSString * _Nonnull)getPacketTunnelDNSResolverIPv4Address;

/*!
Only valid in whole device mode. Provides the DNS resolver IP address that is provided by the packet tunnel to the device.
@return The IP address of the DNS resolver as a string.
*/
- (NSString * _Nonnull)getPacketTunnelDNSResolverIPv6Address;

/*!
Provides the tunnel-core build info json as a string. See the tunnel-core build info code for details https://github.com/Psiphon-Labs/psiphon-tunnel-core/blob/master/psiphon/common/buildinfo.go.
@return The build info json as a string.
Expand Down
15 changes: 4 additions & 11 deletions MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,6 @@ - (long)getPacketTunnelMTU {
return GoPsiGetPacketTunnelMTU();
}

// See comment in header.
- (NSString * _Nonnull)getPacketTunnelDNSResolverIPv4Address {
return GoPsiGetPacketTunnelDNSResolverIPv4Address();
}

// See comment in header.
- (NSString * _Nonnull)getPacketTunnelDNSResolverIPv6Address {
return GoPsiGetPacketTunnelDNSResolverIPv6Address();
}

// See comment in header.
+ (NSString * _Nonnull)getBuildInfo {
return GoPsiGetBuildInfo();
Expand Down Expand Up @@ -1294,6 +1284,7 @@ - (NSString *)getNetworkID {
NSError *warn;
NSString *networkID = [NetworkID getNetworkIDWithReachability:self->reachability
andCurrentNetworkStatus:atomic_load(&self->currentNetworkStatus)
tunnelWholeDevice:self->tunnelWholeDevice
warning:&warn];
if (warn != nil) {
[self logMessage:[NSString stringWithFormat:@"error getting network ID: %@", warn.localizedDescription]];
Expand Down Expand Up @@ -1797,7 +1788,9 @@ - (void)startSendFeedback:(NSString * _Nonnull)feedbackJson
PsiphonProviderNoticeHandlerShim *noticeHandler =
[[PsiphonProviderNoticeHandlerShim alloc] initWithLogger:logNotice];

PsiphonProviderNetwork *networkInfoProvider = [[PsiphonProviderNetwork alloc] initWithLogger:logger];
PsiphonProviderNetwork *networkInfoProvider = [[PsiphonProviderNetwork alloc]
initWithTunnelWholeDevice:tunnelWholeDevice
logger:logger];

GoPsiStartSendFeedback(
psiphonConfig,
Expand Down
2 changes: 1 addition & 1 deletion MobileLibrary/iOS/build-psiphon-framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set -e -u -x
if [ -z ${1+x} ]; then BUILD_TAGS=""; else BUILD_TAGS="$1"; fi

# Modify this value as we use newer Go versions.
GO_VERSION_REQUIRED="1.19.2"
GO_VERSION_REQUIRED="1.19.6"

# At this time, psiphon-tunnel-core doesn't support modules
export GO111MODULE=off
Expand Down
8 changes: 0 additions & 8 deletions MobileLibrary/psi/psi.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,6 @@ func GetPacketTunnelMTU() int {
return tun.DEFAULT_MTU
}

func GetPacketTunnelDNSResolverIPv4Address() string {
return tun.GetTransparentDNSResolverIPv4Address().String()
}

func GetPacketTunnelDNSResolverIPv6Address() string {
return tun.GetTransparentDNSResolverIPv6Address().String()
}

// WriteRuntimeProfiles writes Go runtime profile information to a set of
// files in the specified output directory. See common.WriteRuntimeProfiles
// for more details.
Expand Down
2 changes: 1 addition & 1 deletion Server/Dockerfile-binary-builder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:3.10.2

ENV GOLANG_VERSION 1.19.2
ENV GOLANG_VERSION 1.19.6
ENV GOLANG_SRC_URL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz

RUN set -ex \
Expand Down
17 changes: 10 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/Psiphon-Inc/rotate-safe-writer v0.0.0-20210303140923-464a7a37606e
github.com/Psiphon-Labs/bolt v0.0.0-20200624191537-23cedaef7ad7
github.com/Psiphon-Labs/goptlib v0.0.0-20200406165125-c0e32a7a3464
github.com/Psiphon-Labs/quic-go v0.0.0-20221014165902-1b7c3975fcf3
github.com/Psiphon-Labs/quic-go v0.0.0-20230215230806-9b1ddbf778cc
github.com/Psiphon-Labs/tls-tris v0.0.0-20210713133851-676a693d51ad
github.com/armon/go-proxyproto v0.0.0-20180202201750-5b7edb60ff5f
github.com/bifurcation/mint v0.0.0-20180306135233-198357931e61
Expand Down Expand Up @@ -49,10 +49,10 @@ require (
github.com/wader/filtertransport v0.0.0-20200316221534-bdd9e61eee78
github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b
golang.org/x/net v0.7.0
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
golang.org/x/sys v0.5.0
golang.org/x/term v0.5.0
)

require (
Expand All @@ -66,27 +66,30 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dchest/siphash v1.2.3-0.20201109081723-a21c2e7914a8 // indirect
github.com/dgryski/go-farm v0.0.0-20180109070241-2de33835d102 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.3-0.20210916003710-5d5e8c018a13 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/gxui v0.0.0-20151028112939-f85e0a97b3a4 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/josharian/native v1.0.0 // indirect
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect
github.com/klauspost/compress v1.15.10-0.20220729101446-5a3a4a965cc6 // indirect
github.com/marten-seemann/qpack v0.2.1 // indirect
github.com/mdlayher/netlink v1.4.2-0.20210930205308-a81a8c23d40a // indirect
github.com/mdlayher/socket v0.0.0-20210624160740-9dbe287ded84 // indirect
github.com/mroth/weightedrand v0.4.1 // indirect
github.com/onsi/ginkgo/v2 v2.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/sergeyfrolov/bsbuffer v0.0.0-20180903213811-94e85abb8507 // indirect
github.com/smartystreets/goconvey v1.7.2 // indirect
gitlab.com/yawning/obfs4.git v0.0.0-20190120164510-816cff15f425 // indirect
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/tools v0.1.12 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.2.1 // indirect
)
Loading

0 comments on commit 0957d35

Please sign in to comment.