mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-26 03:11:21 +08:00
commit
5b9022cc38
@ -63,7 +63,6 @@ namespace Configs
|
|||||||
class BuildPrerequisities
|
class BuildPrerequisities
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<ExtraCoreData> extraCoreData = std::make_shared<ExtraCoreData>();
|
|
||||||
std::shared_ptr<DNSDeps> dnsDeps = std::make_shared<DNSDeps>();
|
std::shared_ptr<DNSDeps> dnsDeps = std::make_shared<DNSDeps>();
|
||||||
std::shared_ptr<HijackDeps> hijackDeps = std::make_shared<HijackDeps>();
|
std::shared_ptr<HijackDeps> hijackDeps = std::make_shared<HijackDeps>();
|
||||||
std::shared_ptr<TunDeps> tunDeps = std::make_shared<TunDeps>();
|
std::shared_ptr<TunDeps> tunDeps = std::make_shared<TunDeps>();
|
||||||
@ -74,7 +73,7 @@ namespace Configs
|
|||||||
public:
|
public:
|
||||||
QString error;
|
QString error;
|
||||||
QJsonObject coreConfig;
|
QJsonObject coreConfig;
|
||||||
std::shared_ptr<ExtraCoreData> extraCoreData;
|
std::shared_ptr<ExtraCoreData> extraCoreData = std::make_shared<ExtraCoreData>();
|
||||||
|
|
||||||
QList<std::shared_ptr<Stats::TrafficData>> outboundStats;
|
QList<std::shared_ptr<Stats::TrafficData>> outboundStats;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -38,6 +38,7 @@ namespace Configs
|
|||||||
// baseConfig overrides
|
// baseConfig overrides
|
||||||
bool ParseFromLink(const QString& link) override;
|
bool ParseFromLink(const QString& link) override;
|
||||||
bool ParseFromJson(const QJsonObject& object) override;
|
bool ParseFromJson(const QJsonObject& object) override;
|
||||||
|
bool ParseFromSIP008(const QJsonObject& object);
|
||||||
QString ExportToLink() override;
|
QString ExportToLink() override;
|
||||||
QJsonObject ExportToJson() override;
|
QJsonObject ExportToJson() override;
|
||||||
BuildResult Build() override;
|
BuildResult Build() override;
|
||||||
|
|||||||
@ -11,6 +11,8 @@ namespace Subscription {
|
|||||||
|
|
||||||
void updateWireguardFileConfig(const QString &str);
|
void updateWireguardFileConfig(const QString &str);
|
||||||
|
|
||||||
|
void updateSIP008(const QString &str);
|
||||||
|
|
||||||
int gid_add_to = -1;
|
int gid_add_to = -1;
|
||||||
|
|
||||||
QList<std::shared_ptr<Configs::ProxyEntity>> updated_order;
|
QList<std::shared_ptr<Configs::ProxyEntity>> updated_order;
|
||||||
|
|||||||
@ -46,7 +46,7 @@ namespace Configs {
|
|||||||
obj["enabled"] = true;
|
obj["enabled"] = true;
|
||||||
obj["fingerprint"] = dataStore->utlsFingerprint;
|
obj["fingerprint"] = dataStore->utlsFingerprint;
|
||||||
}
|
}
|
||||||
return {ExportToJson(), ""};
|
return {obj, ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ECH::ParseFromLink(const QString& link)
|
bool ECH::ParseFromLink(const QString& link)
|
||||||
@ -334,9 +334,9 @@ namespace Configs {
|
|||||||
if (fragment) object["fragment"] = fragment;
|
if (fragment) object["fragment"] = fragment;
|
||||||
if (!fragment_fallback_delay.isEmpty()) object["fragment_fallback_delay"] = fragment_fallback_delay;
|
if (!fragment_fallback_delay.isEmpty()) object["fragment_fallback_delay"] = fragment_fallback_delay;
|
||||||
if (record_fragment) object["record_fragment"] = record_fragment;
|
if (record_fragment) object["record_fragment"] = record_fragment;
|
||||||
if (ech->enabled) object["ech"] = ech->Build().object;
|
if (auto obj = ech->Build().object;!obj.isEmpty()) object["ech"] = obj;
|
||||||
if (utls->enabled) object["utls"] = utls->Build().object;
|
if (auto obj = utls->Build().object;!obj.isEmpty()) object["utls"] = obj;
|
||||||
if (reality->enabled) object["reality"] = reality->Build().object;
|
if (auto obj = reality->Build().object;!obj.isEmpty()) object["reality"] = obj;
|
||||||
return {object, ""};
|
return {object, ""};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -224,11 +224,11 @@ namespace Configs {
|
|||||||
ctx->error = "failed to cast to extracore, type is: " + ctx->ent->type;
|
ctx->error = "failed to cast to extracore, type is: " + ctx->ent->type;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
preReqs->extraCoreData->path = QFileInfo(outbound->extraCorePath).canonicalFilePath();
|
ctx->buildConfigResult->extraCoreData->path = QFileInfo(outbound->extraCorePath).canonicalFilePath();
|
||||||
preReqs->extraCoreData->args = outbound->extraCoreArgs;
|
ctx->buildConfigResult->extraCoreData->args = outbound->extraCoreArgs;
|
||||||
preReqs->extraCoreData->config = outbound->extraCoreConf;
|
ctx->buildConfigResult->extraCoreData->config = outbound->extraCoreConf;
|
||||||
preReqs->extraCoreData->configDir = GetBasePath();
|
ctx->buildConfigResult->extraCoreData->configDir = GetBasePath();
|
||||||
preReqs->extraCoreData->noLog = outbound->noLogs;
|
ctx->buildConfigResult->extraCoreData->noLog = outbound->noLogs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,6 +789,7 @@ namespace Configs {
|
|||||||
|
|
||||||
auto ctx = std::make_shared<BuildSingBoxConfigContext>();
|
auto ctx = std::make_shared<BuildSingBoxConfigContext>();
|
||||||
ctx->ent = ent;
|
ctx->ent = ent;
|
||||||
|
ctx->buildConfigResult->outboundStats << std::make_shared<Stats::TrafficData>("direct");
|
||||||
|
|
||||||
CalculatePrerequisities(ctx);
|
CalculatePrerequisities(ctx);
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,24 @@ namespace Configs {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool shadowsocks::ParseFromSIP008(const QJsonObject& object)
|
||||||
|
{
|
||||||
|
if (object.isEmpty()) return false;
|
||||||
|
outbound::ParseFromJson(object);
|
||||||
|
if (object.contains("remarks")) name = object["remarks"].toString();
|
||||||
|
if (object.contains("method")) method = object["method"].toString();
|
||||||
|
if (object.contains("password")) password = object["password"].toString();
|
||||||
|
if (object.contains("plugin")) plugin = object["plugin"].toString().replace("simple-obfs", "obfs-local");
|
||||||
|
if (object.contains("plugin_opts")) plugin_opts = object["plugin_opts"].toString();
|
||||||
|
if (object.contains("uot"))
|
||||||
|
{
|
||||||
|
if (object["uot"].isBool()) uot = object["uot"].toBool();
|
||||||
|
if (object["uot"].isObject()) uot = object["uot"].toObject()["enabled"].toBool();
|
||||||
|
}
|
||||||
|
if (object.contains("multiplex")) multiplex->ParseFromJson(object["multiplex"].toObject());
|
||||||
|
return !(server.isEmpty() || method.isEmpty() || password.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
QString shadowsocks::ExportToLink()
|
QString shadowsocks::ExportToLink()
|
||||||
{
|
{
|
||||||
QUrl url;
|
QUrl url;
|
||||||
@ -109,6 +127,10 @@ namespace Configs {
|
|||||||
|
|
||||||
BuildResult shadowsocks::Build()
|
BuildResult shadowsocks::Build()
|
||||||
{
|
{
|
||||||
|
if (plugin.contains(";")) {
|
||||||
|
plugin_opts = SubStrAfter(plugin, ";");
|
||||||
|
plugin = SubStrBefore(plugin, ";");
|
||||||
|
}
|
||||||
QJsonObject object;
|
QJsonObject object;
|
||||||
object["type"] = "shadowsocks";
|
object["type"] = "shadowsocks";
|
||||||
mergeJsonObjects(object, outbound::Build().object);
|
mergeJsonObjects(object, outbound::Build().object);
|
||||||
|
|||||||
@ -80,6 +80,13 @@ namespace Subscription {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SIP008
|
||||||
|
if (str.contains("version") && str.contains("servers"))
|
||||||
|
{
|
||||||
|
updateSIP008(str);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Multi line
|
// Multi line
|
||||||
if (str.count("\n") > 0 && needParse) {
|
if (str.count("\n") > 0 && needParse) {
|
||||||
auto list = Disect(str);
|
auto list = Disect(str);
|
||||||
@ -327,6 +334,26 @@ namespace Subscription {
|
|||||||
updated_order += ent;
|
updated_order += ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RawUpdater::updateSIP008(const QString& str)
|
||||||
|
{
|
||||||
|
auto json = QString2QJsonObject(str);
|
||||||
|
|
||||||
|
for (auto o : json["servers"].toArray())
|
||||||
|
{
|
||||||
|
auto out = o.toObject();
|
||||||
|
if (out.isEmpty())
|
||||||
|
{
|
||||||
|
MW_show_log("invalid server object");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ent = Configs::ProfileManager::NewProxyEntity("shadowsocks");
|
||||||
|
auto ok = ent->ShadowSocks()->ParseFromSIP008(out);
|
||||||
|
if (!ok) continue;
|
||||||
|
updated_order += ent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 在新的 thread 运行
|
// 在新的 thread 运行
|
||||||
void GroupUpdater::AsyncUpdate(const QString &str, int _sub_gid, const std::function<void()> &finish) {
|
void GroupUpdater::AsyncUpdate(const QString &str, int _sub_gid, const std::function<void()> &finish) {
|
||||||
auto content = str.trimmed();
|
auto content = str.trimmed();
|
||||||
|
|||||||
@ -653,7 +653,7 @@ namespace Configs {
|
|||||||
{
|
{
|
||||||
auto res = QStringList();
|
auto res = QStringList();
|
||||||
for (const auto& item: Rules) {
|
for (const auto& item: Rules) {
|
||||||
if (item->outboundID == -2) {
|
if (item->outboundID == directID && item->action == "route") {
|
||||||
for (const auto& rset: item->rule_set) {
|
for (const auto& rset: item->rule_set) {
|
||||||
if (rset.startsWith("geoip-")) res << QString("ruleset:" + rset);
|
if (rset.startsWith("geoip-")) res << QString("ruleset:" + rset);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -452,6 +452,7 @@ bool DialogEditProfile::onEnd() {
|
|||||||
transport->xhttp_extra = ui->xhttp_extra->text();
|
transport->xhttp_extra = ui->xhttp_extra->text();
|
||||||
tls->reality->public_key = ui->reality_pbk->text();
|
tls->reality->public_key = ui->reality_pbk->text();
|
||||||
tls->reality->short_id = ui->reality_sid->text();
|
tls->reality->short_id = ui->reality_sid->text();
|
||||||
|
tls->reality->enabled = !tls->reality->public_key.isEmpty();
|
||||||
tls->certificate = CACHE.certificate;
|
tls->certificate = CACHE.certificate;
|
||||||
}
|
}
|
||||||
if (ent->outbound->HasMux()) {
|
if (ent->outbound->HasMux()) {
|
||||||
|
|||||||
@ -16,6 +16,10 @@ void EditShadowSocks::onStart(std::shared_ptr<Configs::ProxyEntity> _ent) {
|
|||||||
this->ent = _ent;
|
this->ent = _ent;
|
||||||
auto outbound = this->ent->ShadowSocks();
|
auto outbound = this->ent->ShadowSocks();
|
||||||
|
|
||||||
|
if (outbound->plugin.contains(";")) {
|
||||||
|
outbound->plugin_opts = SubStrAfter(outbound->plugin, ";");
|
||||||
|
outbound->plugin = SubStrBefore(outbound->plugin, ";");
|
||||||
|
}
|
||||||
ui->method->setCurrentText(outbound->method);
|
ui->method->setCurrentText(outbound->method);
|
||||||
ui->uot->setCurrentIndex(outbound->uot);
|
ui->uot->setCurrentIndex(outbound->uot);
|
||||||
ui->password->setText(outbound->password);
|
ui->password->setText(outbound->password);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user