Skip to content

Commit d43cd23

Browse files
committed
use host:port as default proxy name
1 parent c4bbc21 commit d43cd23

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

YtFlowApp/CoreProxy.cpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,7 @@ namespace winrt::YtFlowApp::implementation
6868

6969
std::string Sip002Decoder::DecodeName(ParsedUri const &uri)
7070
{
71-
std::string proxyName = UriUnescape(std::string(uri.fragment));
72-
if (proxyName.empty())
73-
{
74-
proxyName = "New Shadowsocks Proxy";
75-
}
76-
return proxyName;
71+
return UriUnescape(std::string(uri.fragment));
7772
}
7873
PluginDecodeResult Sip002Decoder::DecodeProtocol(ParsedUri const &uri, ProxyPlugin &plugin,
7974
std::string_view tcpNext, std::string_view udpNext) const
@@ -281,12 +276,7 @@ namespace winrt::YtFlowApp::implementation
281276

282277
std::string TrojanDecoder::DecodeName(ParsedUri const &uri)
283278
{
284-
std::string proxyName = UriUnescape(std::string(uri.fragment));
285-
if (proxyName.empty())
286-
{
287-
proxyName = "New Trojan Proxy";
288-
}
289-
return proxyName;
279+
return UriUnescape(std::string(uri.fragment));
290280
}
291281
PluginDecodeResult TrojanDecoder::DecodeProtocol(ParsedUri const &uri, ProxyPlugin &plugin,
292282
std::string_view tcpNext, std::string_view) const
@@ -369,12 +359,7 @@ namespace winrt::YtFlowApp::implementation
369359
{
370360
return remarks.value().get();
371361
}
372-
std::string proxyName = UriUnescape(std::string(uri.fragment));
373-
if (proxyName.empty())
374-
{
375-
proxyName = "New SOCKS5 Proxy";
376-
}
377-
return proxyName;
362+
return UriUnescape(std::string(uri.fragment));
378363
}
379364
PluginDecodeResult Socks5Decoder::DecodeProtocol(ParsedUri const &uri, ProxyPlugin &plugin,
380365
std::string_view tcpNext, std::string_view udpNext) const
@@ -422,12 +407,7 @@ namespace winrt::YtFlowApp::implementation
422407
}
423408
std::string HttpDecoder::DecodeName(ParsedUri const &uri)
424409
{
425-
std::string proxyName = UriUnescape(std::string(uri.fragment));
426-
if (proxyName.empty())
427-
{
428-
proxyName = "New HTTP Proxy";
429-
}
430-
return proxyName;
410+
return UriUnescape(std::string(uri.fragment));
431411
}
432412
PluginDecodeResult HttpDecoder::DecodeProtocol(ParsedUri const &uri, ProxyPlugin &plugin, std::string_view tcpNext,
433413
std::string_view) const

YtFlowApp/CoreProxyImpl.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,16 @@ namespace winrt::YtFlowApp::implementation
245245
{
246246
return std::nullopt;
247247
}
248+
if (name.empty())
249+
{
250+
name = host + ":" + std::to_string(port);
251+
}
248252
ProxyPlugin redirPlugin{
249253
.name = "r",
250254
.plugin = std::string(REDIR_PLUGIN_NAME),
251-
.param = nlohmann::json::to_cbor(
252-
{{"dest", {{"host", host}, {"port", port}}}, {"tcp_next", tcpOut}, {"udp_next", udpOut}}),
255+
.param = nlohmann::json::to_cbor({{"dest", {{"host", std::move(host)}, {"port", port}}},
256+
{"tcp_next", tcpOut},
257+
{"udp_next", udpOut}}),
253258
};
254259
proxy.plugins.emplace_back(std::move(redirPlugin));
255260
tcpOut = "r.tcp";

0 commit comments

Comments
 (0)