Skip to content

Commit 62c236f

Browse files
committed
chore: re-format code
1 parent deab99a commit 62c236f

File tree

97 files changed

+1130
-1332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1130
-1332
lines changed

.clang-format

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
BasedOnStyle: Google
2+
ColumnLimit: 0
3+
IndentWidth: 4
4+
SortIncludes: Never
5+
SpacesBeforeTrailingComments: 1
6+
NamespaceIndentation: All
7+
AccessModifierOffset: -4
8+
SpaceAfterCStyleCast: true
9+
SpaceAfterTemplateKeyword: false
10+
SpaceBeforeRangeBasedForLoopColon: false

db/ConfigBuilder.cpp

+206-132
Large diffs are not rendered by default.

db/ConfigBuilder.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace NekoRay {
1111
QStringList tryDomains;
1212

1313
QList<QSharedPointer<traffic::TrafficData>> outboundStats; // all, but not including "bypass" "block"
14-
QSharedPointer<traffic::TrafficData> outboundStat; // main
14+
QSharedPointer<traffic::TrafficData> outboundStat; // main
1515

1616
QList<sys::ExternalProcess *> ext;
1717
};
@@ -58,4 +58,4 @@ namespace NekoRay {
5858
QString WriteVPNSingBoxConfig();
5959

6060
QString WriteVPNLinuxScript(const QString &protectPath, const QString &configPath);
61-
}
61+
} // namespace NekoRay

db/Database.cpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ namespace NekoRay {
141141
// Profile
142142

143143
int ProfileManager::NewProfileID() const {
144-
if (profiles.empty()) { return 0; } else { return profiles.lastKey() + 1; }
144+
if (profiles.empty()) {
145+
return 0;
146+
} else {
147+
return profiles.lastKey() + 1;
148+
}
145149
}
146150

147151
bool ProfileManager::AddProfile(const QSharedPointer<ProxyEntity> &ent, int gid) {
@@ -192,7 +196,7 @@ namespace NekoRay {
192196
return nullptr;
193197
}
194198

195-
//Group
199+
// Group
196200

197201
Group::Group() {
198202
_add(new configItem("id", &id, itemType::integer));
@@ -212,7 +216,11 @@ namespace NekoRay {
212216
}
213217

214218
int ProfileManager::NewGroupID() const {
215-
if (groups.empty()) { return 0; } else { return groups.lastKey() + 1; }
219+
if (groups.empty()) {
220+
return 0;
221+
} else {
222+
return groups.lastKey() + 1;
223+
}
216224
}
217225

218226
bool ProfileManager::AddGroup(const QSharedPointer<Group> &ent) {
@@ -277,4 +285,4 @@ namespace NekoRay {
277285
}
278286
}
279287

280-
}
288+
} // namespace NekoRay

db/Database.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ namespace NekoRay {
5151
};
5252

5353
extern ProfileManager *profileManager;
54-
}
54+
} // namespace NekoRay

db/Group.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ namespace NekoRay {
2222
// 按 显示 顺序
2323
[[nodiscard]] QList<QSharedPointer<ProxyEntity>> ProfilesWithOrder() const;
2424
};
25-
}
25+
} // namespace NekoRay

db/ProfileFilter.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ namespace NekoRay {
2222
}
2323
}
2424

25-
void
26-
ProfileFilter::Common(const QList<QSharedPointer<ProxyEntity>> &src,
27-
const QList<QSharedPointer<ProxyEntity>> &dst,
28-
QList<QSharedPointer<ProxyEntity >> &out,
29-
bool by_address, bool keep_last) {
25+
void ProfileFilter::Common(const QList<QSharedPointer<ProxyEntity>> &src,
26+
const QList<QSharedPointer<ProxyEntity>> &dst,
27+
QList<QSharedPointer<ProxyEntity>> &out,
28+
bool by_address, bool keep_last) {
3029
QMap<QString, QSharedPointer<ProxyEntity>> hashMap;
3130

3231
for (const auto &ent: src) {
@@ -65,13 +64,12 @@ namespace NekoRay {
6564
}
6665
}
6766

68-
void
69-
ProfileFilter::OnlyInSrc_ByPointer(const QList<QSharedPointer<ProxyEntity>> &src,
70-
const QList<QSharedPointer<ProxyEntity>> &dst,
71-
QList<QSharedPointer<ProxyEntity>> &out) {
67+
void ProfileFilter::OnlyInSrc_ByPointer(const QList<QSharedPointer<ProxyEntity>> &src,
68+
const QList<QSharedPointer<ProxyEntity>> &dst,
69+
QList<QSharedPointer<ProxyEntity>> &out) {
7270
for (const auto &ent: src) {
7371
if (!dst.contains(ent)) out += ent;
7472
}
7573
}
7674

77-
}
75+
} // namespace NekoRay

db/ProfileFilter.hpp

+17-18
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,30 @@ namespace NekoRay {
66
class ProfileFilter {
77
public:
88
static void Uniq(
9-
const QList<QSharedPointer<ProxyEntity>> &in,
10-
QList<QSharedPointer<ProxyEntity>> &out,
11-
bool by_address = false, //def by bean
12-
bool keep_last = false //def keep first
9+
const QList<QSharedPointer<ProxyEntity>> &in,
10+
QList<QSharedPointer<ProxyEntity>> &out,
11+
bool by_address = false, // def by bean
12+
bool keep_last = false // def keep first
1313
);
1414

1515
static void Common(
16-
const QList<QSharedPointer<ProxyEntity>> &src,
17-
const QList<QSharedPointer<ProxyEntity>> &dst,
18-
QList<QSharedPointer<ProxyEntity>> &out,
19-
bool by_address = false, //def by bean
20-
bool keep_last = false //def keep first
16+
const QList<QSharedPointer<ProxyEntity>> &src,
17+
const QList<QSharedPointer<ProxyEntity>> &dst,
18+
QList<QSharedPointer<ProxyEntity>> &out,
19+
bool by_address = false, // def by bean
20+
bool keep_last = false // def keep first
2121
);
2222

2323
static void OnlyInSrc(
24-
const QList<QSharedPointer<ProxyEntity>> &src,
25-
const QList<QSharedPointer<ProxyEntity>> &dst,
26-
QList<QSharedPointer<NekoRay::ProxyEntity>> &out,
27-
bool by_address = false //def by bean
24+
const QList<QSharedPointer<ProxyEntity>> &src,
25+
const QList<QSharedPointer<ProxyEntity>> &dst,
26+
QList<QSharedPointer<NekoRay::ProxyEntity>> &out,
27+
bool by_address = false // def by bean
2828
);
2929

3030
static void OnlyInSrc_ByPointer(
31-
const QList<QSharedPointer<ProxyEntity>> &src,
32-
const QList<QSharedPointer<ProxyEntity>> &dst,
33-
QList<QSharedPointer<ProxyEntity>> &out
34-
);
31+
const QList<QSharedPointer<ProxyEntity>> &src,
32+
const QList<QSharedPointer<ProxyEntity>> &dst,
33+
QList<QSharedPointer<ProxyEntity>> &out);
3534
};
36-
}
35+
} // namespace NekoRay

db/ProxyEntity.hpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace NekoRay {
1919
class CustomBean;
2020

2121
class ChainBean;
22-
};
22+
}; // namespace fmt
2323

2424
class ProxyEntity : public JsonStore {
2525
public:
@@ -29,8 +29,7 @@ namespace NekoRay {
2929
int gid = 0;
3030
int latency = 0;
3131
QSharedPointer<fmt::AbstractBean> bean;
32-
QSharedPointer<traffic::TrafficData> traffic_data = QSharedPointer<traffic::TrafficData>(
33-
new traffic::TrafficData(""));
32+
QSharedPointer<traffic::TrafficData> traffic_data = QSharedPointer<traffic::TrafficData>(new traffic::TrafficData(""));
3433

3534
// Cache
3635
QString full_test_report;
@@ -68,6 +67,5 @@ namespace NekoRay {
6867
[[nodiscard]] fmt::CustomBean *CustomBean() const {
6968
return (fmt::CustomBean *) bean.get();
7069
};
71-
7270
};
73-
}
71+
} // namespace NekoRay

db/TrafficData.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ namespace NekoRay::traffic {
3737
return QString("%1↑ %2↓").arg(ReadableSize(uplink), ReadableSize(downlink));
3838
}
3939
};
40-
}
40+
} // namespace NekoRay::traffic

db/TrafficLooper.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ namespace NekoRay::traffic {
111111
runOnUiThread([=] {
112112
auto m = GetMainWindow();
113113
if (proxy != nullptr) {
114-
m->refresh_status(
115-
QObject::tr("Proxy: %1\nDirect: %2").arg(proxy->DisplaySpeed(), bypass->DisplaySpeed()));
114+
m->refresh_status(QObject::tr("Proxy: %1\nDirect: %2").arg(proxy->DisplaySpeed(), bypass->DisplaySpeed()));
116115
}
117116
for (const auto &item: items) {
118117
if (item->id < 0) continue;
@@ -125,4 +124,4 @@ namespace NekoRay::traffic {
125124
}
126125
}
127126

128-
}
127+
} // namespace NekoRay::traffic

db/TrafficLooper.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ namespace NekoRay::traffic {
2828
};
2929

3030
extern TrafficLooper *trafficLooper;
31-
}
31+
} // namespace NekoRay::traffic

fmt/AbstractBean.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ namespace NekoRay::fmt {
2020
url.setScheme("nekoray");
2121
url.setHost(type);
2222
url.setFragment(QJsonObject2QString(b, true)
23-
.toUtf8().toBase64(QByteArray::Base64UrlEncoding));
23+
.toUtf8()
24+
.toBase64(QByteArray::Base64UrlEncoding));
2425
return url.toString();
2526
}
2627

@@ -72,4 +73,4 @@ namespace NekoRay::fmt {
7273
onFinished();
7374
});
7475
}
75-
}
76+
} // namespace NekoRay::fmt

fmt/AbstractBean.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ namespace NekoRay::fmt {
6060
virtual QString InsecureHint() { return {}; };
6161

6262
QString DisplayInsecureHint();
63-
6463
};
6564

66-
}
65+
} // namespace NekoRay::fmt

fmt/Bean2CoreObj_box.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace NekoRay::fmt {
66
// https://sing-box.sagernet.org/configuration/shared/v2ray-transport
77

88
if (network != "tcp") {
9-
QJsonObject transport{{"type", network},};
9+
QJsonObject transport{{"type", network}};
1010
if (network == "ws") {
1111
if (!path.isEmpty()) transport["path"] = path;
1212
if (!host.isEmpty()) transport["headers"] = QJsonObject{{"Host", host}};
@@ -36,8 +36,8 @@ namespace NekoRay::fmt {
3636
}
3737
if (!utls.isEmpty()) {
3838
tls["utls"] = QJsonObject{
39-
{"enabled", true},
40-
{"fingerprint", utls},
39+
{"enabled", true},
40+
{"fingerprint", utls},
4141
};
4242
}
4343
outbound->insert("tls", tls);
@@ -88,12 +88,12 @@ namespace NekoRay::fmt {
8888
CoreObjOutboundBuildResult VMessBean::BuildCoreObjSingBox() {
8989
CoreObjOutboundBuildResult result;
9090
QJsonObject outbound{
91-
{"type", "vmess"},
92-
{"server", serverAddress},
93-
{"server_port", serverPort},
94-
{"uuid", uuid.trimmed()},
95-
{"alter_id", aid},
96-
{"security", security},
91+
{"type", "vmess"},
92+
{"server", serverAddress},
93+
{"server_port", serverPort},
94+
{"uuid", uuid.trimmed()},
95+
{"alter_id", aid},
96+
{"security", security},
9797
};
9898

9999
stream->BuildStreamSettingsSingBox(&outbound);
@@ -104,9 +104,9 @@ namespace NekoRay::fmt {
104104
CoreObjOutboundBuildResult TrojanVLESSBean::BuildCoreObjSingBox() {
105105
CoreObjOutboundBuildResult result;
106106
QJsonObject outbound{
107-
{"type", proxy_type == proxy_VLESS ? "vless" : "trojan"},
108-
{"server", serverAddress},
109-
{"server_port", serverPort},
107+
{"type", proxy_type == proxy_VLESS ? "vless" : "trojan"},
108+
{"server", serverAddress},
109+
{"server_port", serverPort},
110110
};
111111

112112
QJsonObject settings;
@@ -154,4 +154,4 @@ namespace NekoRay::fmt {
154154

155155
return result;
156156
}
157-
}
157+
} // namespace NekoRay::fmt

0 commit comments

Comments
 (0)