Add suppor for manual connections to remote proxy
This commit is contained in:
parent
8f015aeee3
commit
b7ccd5c923
@ -445,6 +445,7 @@ void JsonRpcClient::processAuthenticate(int /*commandId*/, const QVariantMap &da
|
|||||||
} else {
|
} else {
|
||||||
m_permissionScopes = UserInfo::PermissionScopeAdmin;
|
m_permissionScopes = UserInfo::PermissionScopeAdmin;
|
||||||
}
|
}
|
||||||
|
emit permissionsChanged();
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.beginGroup("jsonTokens");
|
settings.beginGroup("jsonTokens");
|
||||||
settings.setValue(m_serverUuid, m_token);
|
settings.setValue(m_serverUuid, m_token);
|
||||||
@ -720,6 +721,11 @@ void JsonRpcClient::helloReply(int /*commandId*/, const QVariantMap ¶ms)
|
|||||||
|
|
||||||
qCInfo(dcJsonRpc()) << "Handshake reply:" << "Protocol version:" << protoVersionString << "InitRequired:" << m_initialSetupRequired << "AuthRequired:" << m_authenticationRequired << "PushButtonAvailable:" << m_pushButtonAuthAvailable;
|
qCInfo(dcJsonRpc()) << "Handshake reply:" << "Protocol version:" << protoVersionString << "InitRequired:" << m_initialSetupRequired << "AuthRequired:" << m_authenticationRequired << "PushButtonAvailable:" << m_pushButtonAuthAvailable;
|
||||||
|
|
||||||
|
if (m_connection->currentHost()->uuid().isNull()) {
|
||||||
|
qCDebug(dcJsonRpc()) << "Updating Server UUID in connection:" << m_connection->currentHost()->uuid().toString() << "->" << m_serverUuid;
|
||||||
|
m_connection->currentHost()->setUuid(m_serverUuid);
|
||||||
|
}
|
||||||
|
|
||||||
QVersionNumber minimumRequiredVersion = QVersionNumber(5, 0);
|
QVersionNumber minimumRequiredVersion = QVersionNumber(5, 0);
|
||||||
QVersionNumber maximumMajorVersion = QVersionNumber(6);
|
QVersionNumber maximumMajorVersion = QVersionNumber(6);
|
||||||
if (m_jsonRpcVersion < minimumRequiredVersion) {
|
if (m_jsonRpcVersion < minimumRequiredVersion) {
|
||||||
@ -795,11 +801,6 @@ void JsonRpcClient::helloReply(int /*commandId*/, const QVariantMap ¶ms)
|
|||||||
|
|
||||||
emit handshakeReceived();
|
emit handshakeReceived();
|
||||||
|
|
||||||
if (m_connection->currentHost()->uuid().isNull()) {
|
|
||||||
qCDebug(dcJsonRpc()) << "Updating Server UUID in connection:" << m_connection->currentHost()->uuid().toString() << "->" << m_serverUuid;
|
|
||||||
m_connection->currentHost()->setUuid(m_serverUuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_initialSetupRequired) {
|
if (m_initialSetupRequired) {
|
||||||
qCInfo(dcJsonRpc()) << "Initial setup is required for this nymea instance!";
|
qCInfo(dcJsonRpc()) << "Initial setup is required for this nymea instance!";
|
||||||
emit initialSetupRequiredChanged();
|
emit initialSetupRequiredChanged();
|
||||||
|
|||||||
@ -279,6 +279,10 @@ QVariant Users::data(const QModelIndex &index, int role) const
|
|||||||
switch (role) {
|
switch (role) {
|
||||||
case RoleUsername:
|
case RoleUsername:
|
||||||
return m_users.at(index.row())->username();
|
return m_users.at(index.row())->username();
|
||||||
|
case RoleDisplayName:
|
||||||
|
return m_users.at(index.row())->displayName();
|
||||||
|
case RoleEmail:
|
||||||
|
return m_users.at(index.row())->email();
|
||||||
case RoleScopes:
|
case RoleScopes:
|
||||||
return static_cast<int>(m_users.at(index.row())->scopes());
|
return static_cast<int>(m_users.at(index.row())->scopes());
|
||||||
}
|
}
|
||||||
@ -289,6 +293,8 @@ QHash<int, QByteArray> Users::roleNames() const
|
|||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles.insert(RoleUsername, "username");
|
roles.insert(RoleUsername, "username");
|
||||||
|
roles.insert(RoleDisplayName, "displayName");
|
||||||
|
roles.insert(RoleEmail, "email");
|
||||||
roles.insert(RoleScopes, "scopes");
|
roles.insert(RoleScopes, "scopes");
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
@ -296,6 +302,18 @@ QHash<int, QByteArray> Users::roleNames() const
|
|||||||
void Users::insertUser(UserInfo *userInfo)
|
void Users::insertUser(UserInfo *userInfo)
|
||||||
{
|
{
|
||||||
userInfo->setParent(this);
|
userInfo->setParent(this);
|
||||||
|
connect(userInfo, &UserInfo::displayNameChanged, this, [=](){
|
||||||
|
int idx = m_users.indexOf(userInfo);
|
||||||
|
if (idx >= 0) {
|
||||||
|
emit dataChanged(index(idx), index(idx), {RoleDisplayName});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(userInfo, &UserInfo::emailChanged, this, [=](){
|
||||||
|
int idx = m_users.indexOf(userInfo);
|
||||||
|
if (idx >= 0) {
|
||||||
|
emit dataChanged(index(idx), index(idx), {RoleEmail});
|
||||||
|
}
|
||||||
|
});
|
||||||
connect(userInfo, &UserInfo::scopesChanged, this, [=](){
|
connect(userInfo, &UserInfo::scopesChanged, this, [=](){
|
||||||
int idx = m_users.indexOf(userInfo);
|
int idx = m_users.indexOf(userInfo);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
|
|||||||
@ -97,6 +97,8 @@ class Users: public QAbstractListModel {
|
|||||||
public:
|
public:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
RoleUsername,
|
RoleUsername,
|
||||||
|
RoleDisplayName,
|
||||||
|
RoleEmail,
|
||||||
RoleScopes
|
RoleScopes
|
||||||
};
|
};
|
||||||
Q_ENUM(Roles)
|
Q_ENUM(Roles)
|
||||||
|
|||||||
@ -21,23 +21,6 @@ ConfiguredHostsModel::ConfiguredHostsModel(QObject *parent) : QAbstractListModel
|
|||||||
m_currentIndex = settings.value("currentIndex", 0).toInt();
|
m_currentIndex = settings.value("currentIndex", 0).toInt();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
// If there aren't any in the config, try migrating settings from old tab model
|
|
||||||
if (m_list.isEmpty() && settings.contains("tabCount")) {
|
|
||||||
qCInfo(dcApplication()) << "Migrating tab settings to mainmenumodel";
|
|
||||||
int tabCount = settings.value("tabCount", 0).toInt();
|
|
||||||
qCDebug(dcApplication()) << "Tab count:" << tabCount;
|
|
||||||
|
|
||||||
for (int i = 0; i < tabCount; i++) {
|
|
||||||
settings.beginGroup(QString("tabSettings%1").arg(i));
|
|
||||||
QUuid uuid = settings.value("lastConnectedHost").toUuid();
|
|
||||||
ConfiguredHost *host = new ConfiguredHost(uuid, this);
|
|
||||||
addHost(host);
|
|
||||||
settings.endGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.remove("tabCount");
|
|
||||||
}
|
|
||||||
|
|
||||||
// There must be always 1 at least
|
// There must be always 1 at least
|
||||||
if (m_list.isEmpty()) {
|
if (m_list.isEmpty()) {
|
||||||
createHost();
|
createHost();
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
<file>ui/mainviews/FavoritesView.qml</file>
|
<file>ui/mainviews/FavoritesView.qml</file>
|
||||||
<file>ui/mainviews/ThingsView.qml</file>
|
<file>ui/mainviews/ThingsView.qml</file>
|
||||||
<file>ui/connection/ConnectPage.qml</file>
|
<file>ui/connection/ConnectPage.qml</file>
|
||||||
<file>ui/connection/ManualConnectPage.qml</file>
|
|
||||||
<file>ui/connection/ConnectingPage.qml</file>
|
<file>ui/connection/ConnectingPage.qml</file>
|
||||||
<file>ui/connection/wifisetup/BluetoothDiscoveryPage.qml</file>
|
<file>ui/connection/wifisetup/BluetoothDiscoveryPage.qml</file>
|
||||||
<file>ui/connection/wifisetup/WirelessSetupPage.qml</file>
|
<file>ui/connection/wifisetup/WirelessSetupPage.qml</file>
|
||||||
|
|||||||
@ -721,7 +721,6 @@ Page {
|
|||||||
text: qsTr("Disconnect")
|
text: qsTr("Disconnect")
|
||||||
Layout.preferredWidth: Math.max(cancelButton.implicitWidth, disconnectButton.implicitWidth)
|
Layout.preferredWidth: Math.max(cancelButton.implicitWidth, disconnectButton.implicitWidth)
|
||||||
onClicked: {
|
onClicked: {
|
||||||
tabSettings.lastConnectedHost = "";
|
|
||||||
engine.jsonRpcClient.disconnectFromHost();
|
engine.jsonRpcClient.disconnectFromHost();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -173,7 +173,6 @@ Item {
|
|||||||
print("opening push button auth")
|
print("opening push button auth")
|
||||||
var page = pageStack.push(Qt.resolvedUrl("PushButtonAuthPage.qml"))
|
var page = pageStack.push(Qt.resolvedUrl("PushButtonAuthPage.qml"))
|
||||||
page.backPressed.connect(function() {
|
page.backPressed.connect(function() {
|
||||||
// tabSettings.lastConnectedHost = "";
|
|
||||||
engine.jsonRpcClient.disconnectFromHost();
|
engine.jsonRpcClient.disconnectFromHost();
|
||||||
init();
|
init();
|
||||||
})
|
})
|
||||||
@ -182,7 +181,6 @@ Item {
|
|||||||
if (engine.jsonRpcClient.initialSetupRequired) {
|
if (engine.jsonRpcClient.initialSetupRequired) {
|
||||||
var page = pageStack.push(Qt.resolvedUrl("connection/SetupWizard.qml"));
|
var page = pageStack.push(Qt.resolvedUrl("connection/SetupWizard.qml"));
|
||||||
page.backPressed.connect(function() {
|
page.backPressed.connect(function() {
|
||||||
// tabSettings.lastConnectedHost = "";
|
|
||||||
engine.jsonRpcClient.disconnectFromHost()
|
engine.jsonRpcClient.disconnectFromHost()
|
||||||
init();
|
init();
|
||||||
})
|
})
|
||||||
@ -191,7 +189,6 @@ Item {
|
|||||||
|
|
||||||
var page = pageStack.push(Qt.resolvedUrl("connection/LoginPage.qml"));
|
var page = pageStack.push(Qt.resolvedUrl("connection/LoginPage.qml"));
|
||||||
page.backPressed.connect(function() {
|
page.backPressed.connect(function() {
|
||||||
// tabSettings.lastConnectedHost = "";
|
|
||||||
engine.jsonRpcClient.disconnectFromHost()
|
engine.jsonRpcClient.disconnectFromHost()
|
||||||
init();
|
init();
|
||||||
})
|
})
|
||||||
@ -314,7 +311,6 @@ Item {
|
|||||||
if (engine.jsonRpcClient.connected) {
|
if (engine.jsonRpcClient.connected) {
|
||||||
nymeaDiscovery.cacheHost(engine.jsonRpcClient.currentHost)
|
nymeaDiscovery.cacheHost(engine.jsonRpcClient.currentHost)
|
||||||
configuredHost.uuid = engine.jsonRpcClient.serverUuid
|
configuredHost.uuid = engine.jsonRpcClient.serverUuid
|
||||||
// tabSettings.lastConnectedHost = engine.jsonRpcClient.serverUuid
|
|
||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -333,14 +329,12 @@ Item {
|
|||||||
popup.actualVersion = actualVersion;
|
popup.actualVersion = actualVersion;
|
||||||
popup.minVersion = minVersion;
|
popup.minVersion = minVersion;
|
||||||
popup.open()
|
popup.open()
|
||||||
// tabSettings.lastConnectedHost = ""
|
|
||||||
}
|
}
|
||||||
onInvalidMaximumVersion: {
|
onInvalidMaximumVersion: {
|
||||||
var popup = invalidVersionComponent.createObject(app.contentItem);
|
var popup = invalidVersionComponent.createObject(app.contentItem);
|
||||||
popup.actualVersion = actualVersion;
|
popup.actualVersion = actualVersion;
|
||||||
popup.maxVersion = maxVersion;
|
popup.maxVersion = maxVersion;
|
||||||
popup.open()
|
popup.open()
|
||||||
// tabSettings.lastConnectedHost = ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +347,7 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Connections {
|
Connections {
|
||||||
target: engien.nymeaConfiguration.tunnelProxyServerConfigurations
|
target: engine.nymeaConfiguration.tunnelProxyServerConfigurations
|
||||||
onCountChanged: syncRemoteConnection();
|
onCountChanged: syncRemoteConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -308,6 +308,12 @@ WizardPageBase {
|
|||||||
} else {
|
} else {
|
||||||
rpcUrl = "ws://" + hostAddress + ":" + port
|
rpcUrl = "ws://" + hostAddress + ":" + port
|
||||||
}
|
}
|
||||||
|
} else if (connectionTypeComboBox.currentIndex == 2) {
|
||||||
|
if (secureCheckBox.checked) {
|
||||||
|
rpcUrl = "tunnels://" + hostAddress + ":" + port + "?uuid=" + serverUuidTextInput.text
|
||||||
|
} else {
|
||||||
|
rpcUrl = "tunnel://" + hostAddress + ":" + port + "?uuid=" + serverUuidTextInput.text
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Try to connect ", rpcUrl)
|
print("Try to connect ", rpcUrl)
|
||||||
@ -331,28 +337,43 @@ WizardPageBase {
|
|||||||
ComboBox {
|
ComboBox {
|
||||||
id: connectionTypeComboBox
|
id: connectionTypeComboBox
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
model: [ qsTr("TCP"), qsTr("Websocket") ]
|
model: [ qsTr("TCP"), qsTr("Websocket"), qsTr("Remote proxy") ]
|
||||||
}
|
}
|
||||||
|
|
||||||
Label { text: qsTr("Address:") }
|
Label {
|
||||||
|
text: connectionTypeComboBox.currentIndex < 2 ? qsTr("Address:") : qsTr("Proxy address:")
|
||||||
|
}
|
||||||
TextField {
|
TextField {
|
||||||
id: addressTextInput
|
id: addressTextInput
|
||||||
objectName: "addressTextInput"
|
objectName: "addressTextInput"
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
placeholderText: "127.0.0.1"
|
placeholderText: connectionTypeComboBox.currentIndex < 2 ? "127.0.0.1" : "dev-remoteproxy.nymea.io"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("%1 UUID:").arg(Configuration.systemName)
|
||||||
|
visible: connectionTypeComboBox.currentIndex == 2
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
id: serverUuidTextInput
|
||||||
|
Layout.fillWidth: true
|
||||||
|
visible: connectionTypeComboBox.currentIndex == 2
|
||||||
|
}
|
||||||
Label { text: qsTr("Port:") }
|
Label { text: qsTr("Port:") }
|
||||||
TextField {
|
TextField {
|
||||||
id: portTextInput
|
id: portTextInput
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
placeholderText: connectionTypeComboBox.currentIndex === 0 ? "2222" : "4444"
|
placeholderText: connectionTypeComboBox.currentIndex === 0
|
||||||
|
? "2222"
|
||||||
|
: connectionTypeComboBox.currentIndex == 1
|
||||||
|
? "4444"
|
||||||
|
: "2213"
|
||||||
validator: IntValidator{bottom: 1; top: 65535;}
|
validator: IntValidator{bottom: 1; top: 65535;}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: qsTr("Encrypted connection:")
|
text: qsTr("SSL:")
|
||||||
}
|
}
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: secureCheckBox
|
id: secureCheckBox
|
||||||
|
|||||||
@ -138,6 +138,7 @@ SettingsPageBase {
|
|||||||
}
|
}
|
||||||
SettingsPageSectionHeader {
|
SettingsPageSectionHeader {
|
||||||
text: qsTr("Remote connection server interfaces")
|
text: qsTr("Remote connection server interfaces")
|
||||||
|
visible: engine.jsonRpcClient.ensureServerVersion("6.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
@ -171,6 +172,7 @@ SettingsPageBase {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: app.margins
|
Layout.margins: app.margins
|
||||||
text: qsTr("Add")
|
text: qsTr("Add")
|
||||||
|
visible: engine.jsonRpcClient.ensureServerVersion("6.0")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var config = engine.nymeaConfiguration.createTunnelProxyServerConfiguration("dev-remoteproxy.nymea.io", 2213, true, true, false);
|
var config = engine.nymeaConfiguration.createTunnelProxyServerConfiguration("dev-remoteproxy.nymea.io", 2213, true, true, false);
|
||||||
var component = Qt.createComponent(Qt.resolvedUrl("TunnelProxyServerConfigurationDialog.qml"));
|
var component = Qt.createComponent(Qt.resolvedUrl("TunnelProxyServerConfigurationDialog.qml"));
|
||||||
|
|||||||
@ -278,7 +278,7 @@ SettingsPageBase {
|
|||||||
model: userManager.users
|
model: userManager.users
|
||||||
delegate: NymeaItemDelegate {
|
delegate: NymeaItemDelegate {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: engine.jsonRpcClient.ensureServerVersion("6.0") && model.displayName ? model.displayName : model.username
|
text: engine.jsonRpcClient.ensureServerVersion("6.0") && model.displayName !== "" ? model.displayName : model.username
|
||||||
subText: engine.jsonRpcClient.ensureServerVersion("6.0") && model.displayName ? model.username : ""
|
subText: engine.jsonRpcClient.ensureServerVersion("6.0") && model.displayName ? model.username : ""
|
||||||
iconName: "/ui/images/account.svg"
|
iconName: "/ui/images/account.svg"
|
||||||
iconColor: userManager.userInfo.scopes & UserInfo.PermissionScopeAdmin ? Style.accentColor : Style.iconColor
|
iconColor: userManager.userInfo.scopes & UserInfo.PermissionScopeAdmin ? Style.accentColor : Style.iconColor
|
||||||
|
|||||||
Reference in New Issue
Block a user