auto_socket: Windows-скан + список сокетов в Network Settings (add/remove, чистый rewrite конфига)
This commit is contained in:
1 parent
d5119ac7c6
commit
f82dca3185
8 files changed
+545
-160
No files matched your search
@@ -178,10 +178,8 @@ bool NodeConfig::create(const QString& nodeName, quint16 listenPort) {
|
||||
m_controlAddr = "127.0.0.1:9999";
|
||||
m_servers.clear();
|
||||
m_clients.clear();
|
||||
if (listenPort > 0) {
|
||||
m_servers.append({"lan", QString("0.0.0.0:%1").arg(listenPort)});
|
||||
m_servers.append({"lan6", QString("[::]:%1").arg(listenPort)});
|
||||
}
|
||||
(void)listenPort; /* автосокеты сами создают UDP+TCP на случайных портах */
|
||||
m_autoSockets = true;
|
||||
if (m_dbPath.isEmpty())
|
||||
m_dbPath = "chat_data";
|
||||
return save();
|
||||
@@ -277,6 +275,7 @@ bool NodeConfig::load() {
|
||||
else if (key == "my_node_id") m_nodeId = val;
|
||||
else if (key == "my_public_key") m_pubKey = val;
|
||||
else if (key == "my_private_key") m_privKey = val;
|
||||
else if (key == "auto_sockets") m_autoSockets = (val.compare("yes", Qt::CaseInsensitive) == 0 || val == "1");
|
||||
} else if (section.startsWith("server:")) {
|
||||
QString srvName = section.mid(7);
|
||||
if (key == "addr") m_servers.append({srvName, val});
|
||||
@@ -328,6 +327,7 @@ bool NodeConfig::saveFull() {
|
||||
if (!m_nodeId.isEmpty()) out << "my_node_id=" << m_nodeId << "\n";
|
||||
if (!m_privKey.isEmpty()) out << "my_private_key=" << m_privKey << "\n";
|
||||
if (!m_pubKey.isEmpty()) out << "my_public_key=" << m_pubKey << "\n";
|
||||
out << "auto_sockets=" << (m_autoSockets ? "yes" : "no") << "\n";
|
||||
out << "\n";
|
||||
|
||||
for (auto& srv : m_servers) {
|
||||
@@ -403,6 +403,7 @@ bool NodeConfig::save() {
|
||||
config_update_in_lines(lines, "global", "my_node_id", m_nodeId, true);
|
||||
config_update_in_lines(lines, "global", "my_private_key", m_privKey, true);
|
||||
config_update_in_lines(lines, "global", "my_public_key", m_pubKey, true);
|
||||
config_update_in_lines(lines, "global", "auto_sockets", m_autoSockets ? "yes" : "no", true);
|
||||
|
||||
if (!m_controlAddr.isEmpty()) {
|
||||
int sep = m_controlAddr.lastIndexOf(':');
|
||||
|
||||
Reference in new issue
Block a user