Skip to content

Commit

Permalink
Merge branch 'main' into VPN-2452-sub-expire
Browse files Browse the repository at this point in the history
  • Loading branch information
birdsarah committed Dec 21, 2022
2 parents d68600c + 8b7811b commit 0dc47c5
Show file tree
Hide file tree
Showing 43 changed files with 138 additions and 154 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/wasm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v7

- name: Set up gecko driver
uses: browser-actions/setup-geckodriver@latest

- name: Compiling
shell: bash
run: |
Expand Down Expand Up @@ -122,10 +125,8 @@ jobs:
with:
name: WebAssembly Build Qt6
# Destination path
path: wasm

- uses: browser-actions/setup-geckodriver@latest

path: wasm

- name: Build addons
shell: bash
run: ./scripts/addon/generate_all_tests.py -q /opt/$QTVERSION/gcc_64/bin
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ if(NOT DEFINED BUILD_ID)
endif()

## Toolchain Setup
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.17)
cmake_policy(SET CMP0099 OLD)
Expand Down
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,19 @@ cd mozilla-vpn-client
git submodule update --init
```

## How to build from the source code
## Minimum build requirements

In order to build this application, you need to install a few dependencies.
This list is not comprehensive. Different platforms may require other tools to be installed.
Check out the platform section for more information on your specific platform.

#### Install Qt6
- [C++20](https://en.cppreference.com/w/cpp/20)
- [Qt6](https://www.qt.io/product/qt6)
- [Python 3](https://www.python.org/downloads/)
- [Cmake > 3.16](https://cmake.org/install/)
- [Rust](https://www.rust-lang.org/tools/install)
- [Go](https://go.dev/)

### Installing Qt6

Qt6 can be installed in a number of ways:

Expand Down Expand Up @@ -80,7 +88,7 @@ Qt6 can be installed in a number of ways:
./scripts/utils/qt6_compile.sh </qt6/source/code/path> </destination/path>
```

#### Install Python 3
### Installing Python 3

[Python](https://www.python.org/) >= 3.6 is required. You also need to install
a few python modules using [pip](https://pypi.org/):
Expand All @@ -91,7 +99,7 @@ pip install -r requirements.txt --user

(`pip3` may need to be substituted for `pip` in the above line.)

#### Install CMake
### Installing CMake

There are many ways to install [CMake](https://cmake.org).

Expand All @@ -101,17 +109,17 @@ On macOS, it is easy to do with [Homebrew](https://brew.sh/). After
brew install cmake
```

#### Install rust
### Installing Rust

[Rust](https://www.rust-lang.org/) is required for desktop builds (macOS, Linux
and Windows). See the official rust documentation to know how to install it.

#### What's next?
### What's next?

We support the following platforms: Linux, Windows, macOS, iOS, Android and
WASM. Each one is unique and it has a different section in this document.

### How to build from source code for Desktop
## How to build from source code for Desktop

On deskop platforms, such as Windows, Linux and macOS, we build the Mozilla VPN
using CMake, and as long as the required dependencies can be located in your
Expand Down Expand Up @@ -306,6 +314,9 @@ This step needs to be executed each time Xcode updates.
There are two ways to build the project on iOS, using the legacy Qt build system `qmake`
and we have also added experimental support for `cmake`.

> **Note**: Due to lack of low level networking support, it is not possible to turn on
> the VPN from the iOS simulator in XCode.
#### Building with QMake

1. On iOS, we compile the app using
Expand Down Expand Up @@ -546,11 +557,11 @@ https://mozilla-mobile.github.io/mozilla-vpn-client/inspector/) to interact
with the app. Connect the inspector to the app using the web-socket interface.
On desktop, use `ws://localhost:8765`.
The inspector offers a number of tools to help debug and navigate through the VPN client:
The inspector offers a number of tools to help debug and navigate through the VPN client:
* **Shell:** By default the inspector link will take you to the Shell. From there type `help` to see the list of available commands.
* **Logs:** Will constantly output all the app activities happening in real time. This information includes the timesamp, component and message. From the left column you can select which component(s) you'd like to monitor.
* **Network Inspector:** Includes a list of all incoming and outgoing network requests. This is especially helpful when debugging network related issues or monitoring how the app communicates with external components such as the Guardian.
* **QML Inspector:** Allows you to identify and inspect all QML components in the app by mirroring the local VPN client running on your machine and highlighting components by clicking on the QML instance on the right.
* **QML Inspector:** Allows you to identify and inspect all QML components in the app by mirroring the local VPN client running on your machine and highlighting components by clicking on the QML instance on the right.
![inspector_snapshot](https://user-images.githubusercontent.com/3746552/204422879-0799cbd8-91cd-4601-8df8-0d0e9f7cd887.png)
Expand Down
5 changes: 2 additions & 3 deletions linux/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Maintainer: mozilla <[email protected]>
Build-Depends: debhelper (>= 9.20160709),
cdbs,
cmake (>= 3.16~) | cmake-mozilla (>= 3.16~),
quilt,
flex,
gcc (>=4:8.0.0~) | gcc-8,
g++ (>=4:8.0.0~) | g++-8,
golang (>=2:1.13~) | golang-1.13,
cargo,
python3-yaml,
Expand Down Expand Up @@ -63,5 +64,3 @@ Depends: libpolkit-gobject-1-0 (>=0.105),
qt6-qpa-plugins (>=6.2.0~)
Description: A fast, secure and easy to use VPN. Built by the makers of Firefox.
Read more on https://vpn.mozilla.org


6 changes: 6 additions & 0 deletions linux/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ ifneq (ok,$(dpkg --compare-versions $(GOLANG_NATIVE_VERSION) ge 2:1.13 && echo o
export PATH := $(GODIR)/bin:$(PATH)
endif

GCC_NATIVE_VERSION = $(shell gcc -dumpversion 2>/dev/null || echo 0)
ifneq (ok,$(shell dpkg --compare-versions $(GCC_NATIVE_VERSION) ge 8 && echo ok))
export CC := gcc-8
export CXX := g++-8
endif

%:
dh $@ --with=systemd --warn-missing

Expand Down
1 change: 1 addition & 0 deletions nebula/ui/components/VPNBoldInterLabel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Text {
lineHeight: VPNTheme.theme.controllerInterLineHeight
color: VPNTheme.theme.fontColorDark
wrapMode: Text.Wrap
horizontalAlignment: Qt.AlignLeft

Accessible.role: Accessible.StaticText
Accessible.name: text
Expand Down
2 changes: 2 additions & 0 deletions nebula/ui/components/VPNSubtitle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ Text {
color: VPNTheme.theme.fontColor
lineHeightMode: Text.FixedHeight
lineHeight: VPNTheme.theme.labelLineHeight
Accessible.role: Accessible.StaticText
Accessible.name: text
}
23 changes: 8 additions & 15 deletions nebula/ui/components/forms/VPNPasswordInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import components.forms 0.1
VPNTextField {
property bool charactersMasked: true
property bool isValid: true
property alias button: toggleButton
property alias placeholder: passwordInput._placeholderText
property alias button: showHidePasswordButton

id: passwordInput

Expand All @@ -25,12 +24,10 @@ VPNTextField {

echoMode: charactersMasked ? TextInput.Password : TextInput.Normal
hasError: !isValid
height: VPNTheme.theme.rowHeight
rightPadding: VPNTheme.theme.windowMargin * 0.5 + toggleButton.width
width: parent.width
rightPadding: VPNTheme.theme.windowMargin * 0.5 + showHidePasswordButton.width

VPNIconButton {
id: toggleButton
id: showHidePasswordButton

accessibleName: passwordInput.charactersMasked
? VPNl18n.InAppAuthShowPassword
Expand All @@ -42,9 +39,10 @@ VPNTextField {
}
height: parent.height - VPNTheme.theme.listSpacing
width: parent.height - VPNTheme.theme.listSpacing
onClicked: passwordInput.charactersMasked = !passwordInput.charactersMasked

Image {
anchors.centerIn: toggleButton
anchors.centerIn: showHidePasswordButton
fillMode: Image.PreserveAspectFit
source: passwordInput.charactersMasked
? "qrc:/nebula/resources/eye-hidden.svg"
Expand All @@ -53,18 +51,13 @@ VPNTextField {
sourceSize.width: VPNTheme.theme.iconSize * 1.5
}

function toggleVisibility() {
passwordInput.charactersMasked = !passwordInput.charactersMasked;
}

// Temporary workaround for QTBUG-78813: TextInput prevents touch events
// workaround for QTBUG-78813: TextInput prevents touch events
// from reaching other MouseAreas.
// https://bugreports.qt.io/browse/QTBUG-78813
MouseArea {
onPressed: showHidePasswordButton.clicked()
anchors.fill: parent
onPressed: {
toggleButton.toggleVisibility();
}
enabled: ["android", "ios"].includes(Qt.platform.os)
}
}
}
1 change: 0 additions & 1 deletion nebula/ui/components/forms/VPNSearchBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ ColumnLayout {
Accessible.searchEdit: true
Layout.fillWidth: true

_accessibleName: _placeholderText
background: VPNInputBackground {}
leftInset: VPNTheme.theme.windowMargin * 3
leftPadding: VPNTheme.theme.windowMargin * 3
Expand Down
6 changes: 2 additions & 4 deletions nebula/ui/components/forms/VPNTextField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ TextField {
property bool showInteractionStates: true
property bool forceBlurOnOutsidePress: true
property alias _placeholderText: centeredPlaceholderText.text
property string _accessibleName: _placeholderText
property string _accessibleDescription: ""

id: textField

Accessible.name: _accessibleName
Accessible.description: _accessibleDescription
Accessible.name: centeredPlaceholderText.text
Accessible.description: centeredPlaceholderText.text
Accessible.focused: textField.focus
Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: VPNTheme.theme.rowHeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ColumnLayout {
ToolTip {
property bool _isSignUp: VPNAuthInApp.state === VPNAuthInApp.StateSignUp
id: toolTip
visible: _isSignUp && passwordInput.activeFocus
visible: _isSignUp && passwordInput.text.length > 0 && passwordInput.activeFocus
padding: VPNTheme.theme.windowMargin
x: VPNTheme.theme.vSpacing
y: passwordInput.y - height - 4
Expand Down
3 changes: 3 additions & 0 deletions src/apps/vpn/appconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ constexpr const char* ADDON_SETTINGS_GROUP = "addons";
#define PRODBETAEXPR(type, functionName, prod, beta) \
inline type functionName() { return Constants::inProduction() ? prod : beta; }

constexpr const char* MOZILLA_VPN_SUMO_URL =
"https://support.mozilla.org/en-US/products/firefox-private-network-vpn";

PRODBETAEXPR(
const char*, benchmarkUploadUrl, "https://benchmark.vpn.mozilla.org/upload",
"https://dev.vpn-network-benchmark.nonprod.webservices.mozgcp.net/upload");
Expand Down
32 changes: 16 additions & 16 deletions src/apps/vpn/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ constexpr const int MULLVAD_PROXY_RANGE_LENGTH = 20;
namespace {
Logger logger("Controller");

ControllerImpl::Reason stateToReason(Controller::State state) {
Controller::Reason stateToReason(Controller::State state) {
if (state == Controller::StateSwitching) {
return ControllerImpl::ReasonSwitching;
return Controller::ReasonSwitching;
}

if (state == Controller::StateConfirming) {
return ControllerImpl::ReasonConfirming;
return Controller::ReasonConfirming;
}

return ControllerImpl::ReasonNone;
return Controller::ReasonNone;
}

} // namespace
Expand Down Expand Up @@ -191,11 +191,11 @@ bool Controller::activate() {

clearRetryCounter();

activateInternal();
activateInternal(stateToReason(m_state));
return true;
}

void Controller::activateInternal(bool forcePort53) {
void Controller::activateInternal(Reason reason, bool forcePort53) {
logger.debug() << "Activation internal";
Q_ASSERT(m_impl);

Expand Down Expand Up @@ -239,7 +239,7 @@ void Controller::activateInternal(bool forcePort53) {
exitHop.m_excludedAddresses.append(exitHop.m_server.ipv6AddrIn());

// If requested, force the use of port 53/DNS.
if (settingsHolder->tunnelPort53() || forcePort53) {
if (forcePort53) {
exitHop.m_server.forcePort(53);
}
// For single-hop, they are the same
Expand All @@ -257,7 +257,7 @@ void Controller::activateInternal(bool forcePort53) {
return;
}
// If requested, force the use of port 53/DNS.
if (settingsHolder->tunnelPort53() || forcePort53) {
if (forcePort53) {
hop.m_server.forcePort(53);
}

Expand Down Expand Up @@ -292,10 +292,10 @@ void Controller::activateInternal(bool forcePort53) {
m_ping_canary.start(m_activationQueue.first().m_server.ipv4AddrIn(),
"0.0.0.0/0");
logger.info() << "Canary Ping Started";
activateNext();
activateNext(reason);
}

void Controller::activateNext() {
void Controller::activateNext(Reason reason) {
MozillaVPN* vpn = MozillaVPN::instance();
const Device* device = vpn->deviceModel()->currentDevice(vpn->keys());
if (device == nullptr) {
Expand All @@ -307,7 +307,7 @@ void Controller::activateNext() {

logger.debug() << "Activating peer" << logger.keys(hop.m_server.publicKey());
m_handshakeTimer.start(HANDSHAKE_TIMEOUT_SEC * 1000);
m_impl->activate(hop, device, vpn->keys(), stateToReason(m_state));
m_impl->activate(hop, device, vpn->keys(), reason);

// Move to the confirming state if we are awaiting any connection handshakes.
setState(StateConfirming);
Expand Down Expand Up @@ -336,7 +336,7 @@ bool Controller::silentSwitchServers() {
vpn->currentServer()->exitServerPublicKey());

// Activate the first connection to kick off the server switch.
activateInternal();
activateInternal(ReasonSwitching);
return true;
}

Expand Down Expand Up @@ -382,7 +382,7 @@ void Controller::connected(const QString& pubkey) {
// Start the next connection if there is more work to do.
m_activationQueue.removeFirst();
if (!m_activationQueue.isEmpty()) {
activateNext();
activateNext(stateToReason(m_state));
return;
}
}
Expand Down Expand Up @@ -424,14 +424,14 @@ void Controller::handshakeTimeout() {
// Try again, again if there are sufficient retries left.
++m_connectionRetry;
emit connectionRetryChanged();
if (m_connectionRetry == 1 && !SettingsHolder::instance()->tunnelPort53()) {
if (m_connectionRetry == 1) {
logger.info() << "Connection Attempt: Using Port 53 Option this time.";
// On the first retry, opportunisticly try again using the port 53
// option enabled, if that feature is disabled.
activateInternal(true);
activateInternal(stateToReason(m_state), true);
return;
} else if (m_connectionRetry < CONNECTION_MAX_RETRY) {
activateInternal();
activateInternal(stateToReason(m_state));
return;
}

Expand Down
10 changes: 8 additions & 2 deletions src/apps/vpn/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class Controller final : public QObject {
};
Q_ENUM(State)

enum Reason {
ReasonNone = 0,
ReasonSwitching,
ReasonConfirming,
};

private:
Q_PROPERTY(State state READ state NOTIFY stateChanged)
Q_PROPERTY(qint64 time READ time NOTIFY timeChanged)
Expand Down Expand Up @@ -134,8 +140,8 @@ class Controller final : public QObject {
QList<IPAddress> getAllowedIPAddressRanges(const Server& server);
QStringList getExcludedAddresses(const Server& server);

void activateInternal(bool forceDNSPort = false);
void activateNext();
void activateInternal(Reason reason, bool forceDNSPort = false);
void activateNext(Reason reason);

void clearRetryCounter();
void clearConnectedTime();
Expand Down
Loading

0 comments on commit 0dc47c5

Please sign in to comment.