mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Fix some bad implementations
Optimize codes.
This commit is contained in:
parent
d767036b2a
commit
008c5795c0
@ -5,7 +5,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <numeric>
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
@ -800,7 +800,7 @@ public:
|
|||||||
template <typename T> int SetArray(const std::string §ion, std::string itemName, const std::string &separator, T &Array)
|
template <typename T> int SetArray(const std::string §ion, std::string itemName, const std::string &separator, T &Array)
|
||||||
{
|
{
|
||||||
std::string data;
|
std::string data;
|
||||||
std::transform(std::begin(Array), std::end(Array), std::back_inserter(data), [&](auto x) { return std::to_string(x) + separator; });
|
data = std::accumulate(std::begin(Array), std::end(Array), std::string(), [&](auto a, auto b) { return std::move(a) + std::to_string(b) + separator; });
|
||||||
data.erase(data.size() - 1);
|
data.erase(data.size() - 1);
|
||||||
return Set(section, std::move(itemName), data);
|
return Set(section, std::move(itemName), data);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -163,7 +163,7 @@ public:
|
|||||||
|
|
||||||
template <typename T> tribool(const T &value) { set(value); }
|
template <typename T> tribool(const T &value) { set(value); }
|
||||||
|
|
||||||
explicit tribool(const tribool &value) { *this = value; }
|
tribool(const tribool &value) { *this = value; }
|
||||||
|
|
||||||
~tribool() = default;
|
~tribool() = default;
|
||||||
|
|
||||||
|
|||||||
@ -175,6 +175,7 @@ void explodeVmessConf(std::string content, const std::string &custom_port, bool
|
|||||||
node.port = to_int(port, 1);
|
node.port = to_int(port, 1);
|
||||||
node.proxyStr = vmessConstruct(node.group, node.remarks, add, port, type, id, aid, net, cipher, path, host, edge, tls, udp, tfo, scv);
|
node.proxyStr = vmessConstruct(node.group, node.remarks, add, port, type, id, aid, net, cipher, path, host, edge, tls, udp, tfo, scv);
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -250,6 +251,7 @@ void explodeVmessConf(std::string content, const std::string &custom_port, bool
|
|||||||
node.server = add;
|
node.server = add;
|
||||||
node.port = to_int(port, 1);
|
node.port = to_int(port, 1);
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -381,6 +383,7 @@ void explodeSSD(std::string link, bool libev, const std::string &custom_port, st
|
|||||||
node.proxyStr = ssConstruct(group, remarks, server, port, password, method, plugin, pluginopts, libev);
|
node.proxyStr = ssConstruct(group, remarks, server, port, password, method, plugin, pluginopts, libev);
|
||||||
node.id = index;
|
node.id = index;
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -424,6 +427,7 @@ void explodeSSAndroid(std::string ss, bool libev, const std::string &custom_port
|
|||||||
node.port = to_int(port, 1);
|
node.port = to_int(port, 1);
|
||||||
node.proxyStr = ssConstruct(group, ps, server, port, password, method, plugin, pluginopts, libev);
|
node.proxyStr = ssConstruct(group, ps, server, port, password, method, plugin, pluginopts, libev);
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -466,6 +470,7 @@ void explodeSSConf(std::string content, const std::string &custom_port, bool lib
|
|||||||
node.port = to_int(port, 1);
|
node.port = to_int(port, 1);
|
||||||
node.proxyStr = ssConstruct(group, ps, server, port, password, method, plugin, pluginopts, libev);
|
node.proxyStr = ssConstruct(group, ps, server, port, password, method, plugin, pluginopts, libev);
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -558,6 +563,7 @@ void explodeSSRConf(std::string content, const std::string &custom_port, bool ss
|
|||||||
node.proxyStr = ssrConstruct(node.group, node.remarks, base64_encode(node.remarks), server, port, protocol, method, obfs, password, obfsparam, protoparam, ssr_libev);
|
node.proxyStr = ssrConstruct(node.group, node.remarks, base64_encode(node.remarks), server, port, protocol, method, obfs, password, obfsparam, protoparam, ssr_libev);
|
||||||
}
|
}
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,6 +597,7 @@ void explodeSSRConf(std::string content, const std::string &custom_port, bool ss
|
|||||||
node.port = to_int(port, 1);
|
node.port = to_int(port, 1);
|
||||||
node.proxyStr = ssrConstruct(group, remarks, remarks_base64, server, port, protocol, method, obfs, password, obfsparam, protoparam, ssr_libev);
|
node.proxyStr = ssrConstruct(group, remarks, remarks_base64, server, port, protocol, method, obfs, password, obfsparam, protoparam, ssr_libev);
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1111,6 +1118,7 @@ void explodeClash(Node yamlnode, const std::string &custom_port, std::vector<nod
|
|||||||
node.port = to_int(port, 1);
|
node.port = to_int(port, 1);
|
||||||
node.id = index;
|
node.id = index;
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1742,6 +1750,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector
|
|||||||
node.port = to_int(port);
|
node.port = to_int(port);
|
||||||
node.id = index;
|
node.id = index;
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
@ -1808,6 +1817,7 @@ void explodeSSTap(std::string sstap, const std::string &custom_port, std::vector
|
|||||||
node.server = server;
|
node.server = server;
|
||||||
node.port = to_int(port, 1);
|
node.port = to_int(port, 1);
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1830,6 +1840,7 @@ void explodeNetchConf(std::string netch, bool ss_libev, bool ssr_libev, const st
|
|||||||
|
|
||||||
node.id = index;
|
node.id = index;
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2004,6 +2015,7 @@ void explodeSub(std::string sub, bool sslibev, bool ssrlibev, const std::string
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nodes.emplace_back(std::move(node));
|
nodes.emplace_back(std::move(node));
|
||||||
|
node = nodeInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user