Skip to content

Commit

Permalink
Added architecture field.
Browse files Browse the repository at this point in the history
  • Loading branch information
dchapyshev committed Nov 24, 2023
1 parent c21c206 commit cc43e01
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 13 deletions.
6 changes: 6 additions & 0 deletions source/base/peer/authenticator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ void Authenticator::setPeerComputerName(const std::string& name)
peer_computer_name_ = name;
}

//--------------------------------------------------------------------------------------------------
void Authenticator::setPeerArch(const std::string &arch)
{
peer_arch_ = arch;
}

//--------------------------------------------------------------------------------------------------
void Authenticator::onTcpConnected()
{
Expand Down
3 changes: 3 additions & 0 deletions source/base/peer/authenticator.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Authenticator : public TcpChannel::Listener
[[nodiscard]] const Version& peerVersion() const { return peer_version_; }
[[nodiscard]] const std::string& peerOsName() const { return peer_os_name_; }
[[nodiscard]] const std::string& peerComputerName() const { return peer_computer_name_; }
[[nodiscard]] const std::string& peerArch() const { return peer_arch_; }
[[nodiscard]] uint32_t sessionType() const { return session_type_; }
[[nodiscard]] const std::string& userName() const { return user_name_; }

Expand All @@ -84,6 +85,7 @@ class Authenticator : public TcpChannel::Listener
void setPeerVersion(const proto::Version& version);
void setPeerOsName(const std::string& name);
void setPeerComputerName(const std::string& name);
void setPeerArch(const std::string& arch);

// base::TcpChannel::Listener implementation.
void onTcpConnected() final;
Expand All @@ -110,6 +112,7 @@ class Authenticator : public TcpChannel::Listener
Version peer_version_; // Remote peer version.
std::string peer_os_name_;
std::string peer_computer_name_;
std::string peer_arch_;
};

} // namespace base
Expand Down
1 change: 1 addition & 0 deletions source/base/peer/client_authenticator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ bool ClientAuthenticator::readSessionChallenge(const ByteArray& buffer)
setPeerVersion(challenge->version());
setPeerOsName(challenge->os_name());
setPeerComputerName(challenge->computer_name());
setPeerArch(challenge->arch());

LOG(LS_INFO) << "Server Version: " << peerVersion();
LOG(LS_INFO) << "Server Name: " << challenge->computer_name();
Expand Down
1 change: 1 addition & 0 deletions source/base/peer/server_authenticator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ void ServerAuthenticator::onSessionResponse(const ByteArray& buffer)
setPeerVersion(session_response->version());
setPeerOsName(session_response->os_name());
setPeerComputerName(session_response->computer_name());
setPeerArch(session_response->arch());

LOG(LS_INFO) << "Client Session Type: " << session_response->session_type();
LOG(LS_INFO) << "Client Version: " << peerVersion();
Expand Down
1 change: 1 addition & 0 deletions source/base/peer/server_authenticator_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void ServerAuthenticatorManager::onComplete()
session_info.version = current->peerVersion();
session_info.os_name = current->peerOsName();
session_info.computer_name = current->peerComputerName();
session_info.architecture = current->peerArch();
session_info.user_name = current->userName();
session_info.session_type = current->sessionType();

Expand Down
1 change: 1 addition & 0 deletions source/base/peer/server_authenticator_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ServerAuthenticatorManager
Version version;
std::string os_name;
std::string computer_name;
std::string architecture;
std::string user_name;
uint32_t session_type = 0;
};
Expand Down
3 changes: 3 additions & 0 deletions source/client/resources/client.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
<file>monitor-7.png</file>
<file>monitor-8.png</file>
<file>monitor-9.png</file>
<file>pencil.png</file>
<file>plus.png</file>
<file>minus.png</file>
<file>main.ico</file>
</qresource>
</RCC>
Binary file added source/client/resources/minus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/client/resources/pencil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/client/resources/plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions source/client/ui/router_manager/router_manager_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class HostTreeItem : public QTreeWidgetItem
proto::Version version = session.version();
setText(4, QString("%1.%2.%3.%4")
.arg(version.major()).arg(version.minor()).arg(version.patch()).arg(version.revision()));
setText(5, QString::fromStdString(session.os_name()));
setText(5, QString::fromStdString(session.architecture()));
setText(6, QString::fromStdString(session.os_name()));
}

~HostTreeItem() override = default;
Expand Down Expand Up @@ -112,15 +113,15 @@ class HostTreeItem : public QTreeWidgetItem
bool operator<(const QTreeWidgetItem& other) const override
{
int column = treeWidget()->sortColumn();
if (column == 0)
if (column == 0) // Name
{
QCollator collator;
collator.setCaseSensitivity(Qt::CaseInsensitive);
collator.setNumericMode(true);

return collator.compare(text(0), other.text(0)) <= 0;
}
else if (column == 2)
else if (column == 2) // Time
{
const HostTreeItem* other_item = static_cast<const HostTreeItem*>(&other);
return session.timepoint() < other_item->session.timepoint();
Expand Down Expand Up @@ -156,7 +157,8 @@ class RelayTreeItem : public QTreeWidgetItem
setText(3, QString("%1.%2.%3.%4")
.arg(version.major()).arg(version.minor()).arg(version.patch()).arg(version.revision()));
setText(4, QString::fromStdString(session.computer_name()));
setText(5, QString::fromStdString(session.os_name()));
setText(5, QString::fromStdString(session.architecture()));
setText(6, QString::fromStdString(session.os_name()));
}

void updateItem(const proto::Session& updated_session)
Expand Down
27 changes: 18 additions & 9 deletions source/client/ui/router_manager/router_manager_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</property>
<widget class="QWidget" name="tab_hosts">
<attribute name="icon">
<iconset resource="../resources/client.qrc">
<iconset resource="../../resources/client.qrc">
<normaloff>:/img/host.png</normaloff>:/img/host.png</iconset>
</attribute>
<attribute name="title">
Expand Down Expand Up @@ -92,6 +92,11 @@
<string>Version</string>
</property>
</column>
<column>
<property name="text">
<string>Architecture</string>
</property>
</column>
<column>
<property name="text">
<string>Operating System</string>
Expand Down Expand Up @@ -148,7 +153,7 @@
</widget>
<widget class="QWidget" name="tab_relay">
<attribute name="icon">
<iconset resource="../resources/client.qrc">
<iconset resource="../../resources/client.qrc">
<normaloff>:/img/computer.png</normaloff>:/img/computer.png</iconset>
</attribute>
<attribute name="title">
Expand Down Expand Up @@ -210,6 +215,11 @@
<string>Computer Name</string>
</property>
</column>
<column>
<property name="text">
<string>Architecture</string>
</property>
</column>
<column>
<property name="text">
<string>Operating System</string>
Expand Down Expand Up @@ -315,7 +325,7 @@
</widget>
<widget class="QWidget" name="tab_users">
<attribute name="icon">
<iconset resource="../resources/client.qrc">
<iconset resource="../../resources/client.qrc">
<normaloff>:/img/user.png</normaloff>:/img/user.png</iconset>
</attribute>
<attribute name="title">
Expand All @@ -333,7 +343,7 @@
<string/>
</property>
<property name="icon">
<iconset resource="../../console/resources/console.qrc">
<iconset resource="../../resources/client.qrc">
<normaloff>:/img/plus.png</normaloff>:/img/plus.png</iconset>
</property>
</widget>
Expand All @@ -350,7 +360,7 @@
<string/>
</property>
<property name="icon">
<iconset resource="../../console/resources/console.qrc">
<iconset resource="../../resources/client.qrc">
<normaloff>:/img/pencil.png</normaloff>:/img/pencil.png</iconset>
</property>
</widget>
Expand All @@ -367,7 +377,7 @@
<string/>
</property>
<property name="icon">
<iconset resource="../../console/resources/console.qrc">
<iconset resource="../../resources/client.qrc">
<normaloff>:/img/minus.png</normaloff>:/img/minus.png</iconset>
</property>
</widget>
Expand All @@ -381,7 +391,7 @@
<string/>
</property>
<property name="icon">
<iconset resource="../resources/client.qrc">
<iconset resource="../../resources/client.qrc">
<normaloff>:/img/arrow-circle-double.png</normaloff>:/img/arrow-circle-double.png</iconset>
</property>
</widget>
Expand Down Expand Up @@ -422,8 +432,7 @@
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources>
<include location="../resources/client.qrc"/>
<include location="../../console/resources/console.qrc"/>
<include location="../../resources/client.qrc"/>
</resources>
<connections/>
</ui>
1 change: 1 addition & 0 deletions source/proto/router_admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ message Session
Version version = 6;
string os_name = 7;
string computer_name = 8;
string architecture = 9;
}

enum SessionRequestType
Expand Down
2 changes: 2 additions & 0 deletions source/router/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ std::unique_ptr<proto::SessionList> Server::sessionList() const
item->mutable_version()->CopyFrom(session->version().toProto());
item->set_os_name(session->osName());
item->set_computer_name(session->computerName());
item->set_architecture(session->architecture());

switch (session->sessionType())
{
Expand Down Expand Up @@ -427,6 +428,7 @@ void Server::onNewSession(base::ServerAuthenticatorManager::SessionInfo&& sessio
session->setVersion(session_info.version);
session->setOsName(session_info.os_name);
session->setComputerName(session_info.computer_name);
session->setArchitecture(session_info.architecture);
session->setUserName(session_info.user_name);

sessions_.emplace_back(std::move(session));
Expand Down
6 changes: 6 additions & 0 deletions source/router/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ void Session::setComputerName(const std::string& computer_name)
computer_name_ = computer_name;
}

//--------------------------------------------------------------------------------------------------
void Session::setArchitecture(const std::string& architecture)
{
architecture_ = architecture;
}

//--------------------------------------------------------------------------------------------------
void Session::setUserName(const std::string& username)
{
Expand Down
3 changes: 3 additions & 0 deletions source/router/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class Session : public base::TcpChannel::Listener
const std::string& osName() const { return os_name_; }
void setComputerName(const std::string& computer_name);
const std::string& computerName() const { return computer_name_; }
void setArchitecture(const std::string& architecture);
const std::string& architecture() const { return architecture_; }
void setUserName(const std::string& username);
const std::string& userName() const { return username_; }

Expand Down Expand Up @@ -105,6 +107,7 @@ class Session : public base::TcpChannel::Listener
base::Version version_;
std::string os_name_;
std::string computer_name_;
std::string architecture_;

Delegate* delegate_ = nullptr;
};
Expand Down

0 comments on commit cc43e01

Please sign in to comment.