Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webExt] Let the client communicate the connectionTime #9776

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,30 @@ void Controller::handshakeTimeout() {
serverUnavailable();
}

qint64 Controller::connectionTimestamp() const {
switch (m_state) {
case Controller::State::StateConfirming:
[[fallthrough]];
case Controller::State::StateConnecting:
[[fallthrough]];
case Controller::State::StateDisconnecting:
[[fallthrough]];
case Controller::State::StateInitializing:
[[fallthrough]];
case Controller::State::StateOff:
return 0;
case Controller::State::StateOn:
[[fallthrough]];
case Controller::State::StateOnPartial:
[[fallthrough]];
case Controller::State::StateSilentSwitching:
[[fallthrough]];
case Controller::State::StateSwitching:
return m_connectedTimeInUTC.toMSecsSinceEpoch();
}
Q_UNREACHABLE();
}

void Controller::serverUnavailable() {
logger.info() << "Server Unavailable - Ping succeeded: " << m_pingReceived;

Expand Down
1 change: 1 addition & 0 deletions src/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Controller : public QObject, public LogSerializer {

public:
qint64 time() const;
qint64 connectionTimestamp() const;
void serverUnavailable();
void captivePortalPresent();
void captivePortalGone();
Expand Down
3 changes: 2 additions & 1 deletion src/webextensionadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ QJsonObject WebExtensionAdapter::serializeStatus() {
QJsonObject obj;
obj["authenticated"] = App::isUserAuthenticated();
obj["location"] = locationObj;

obj["connectedSince"] =
QString::number(vpn->controller()->connectionTimestamp());
{
int stateValue = vpn->state();
if (stateValue > App::StateCustom) {
Expand Down
Loading