Skip to content

Commit

Permalink
fix: incompatible sing-box config export
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelam committed Mar 23, 2024
1 parent bd17cfc commit d70edf1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/generator/config/subexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2317,9 +2317,9 @@ void proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json, std::v
{
addSingBoxCommonMembers(proxy, x, "hysteria", allocator);
if (!x.Up.empty())
proxy.AddMember("up", rapidjson::StringRef(x.Up.c_str()), allocator);
proxy.AddMember("up_mbps", x.UpSpeed, allocator);
if (!x.Down.empty())
proxy.AddMember("down", rapidjson::StringRef(x.Down.c_str()), allocator);
proxy.AddMember("down_mbps", x.DownSpeed, allocator);
if (!x.OBFS.empty())
{
proxy.AddMember("obfs", rapidjson::StringRef(x.OBFS.c_str()), allocator);
Expand Down
13 changes: 11 additions & 2 deletions src/parser/subparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,28 @@ void hysteriaConstruct(
if (!up.empty())
{
if (up.length() > 4 && up.find("bps") == up.length() - 3)

node.Up = up;
else if (to_int(up))
{
node.UpSpeed = to_int(up);
node.Up = up + " Mbps";
}
}
node.UpSpeed = to_int(up_speed);
if (!up_speed.empty())
node.UpSpeed = to_int(up_speed);
if (!down.empty())
{
if (down.length() > 4 && down.find("bps") == down.length() - 3)
node.Down = down;
else if (to_int(down))
{
node.DownSpeed = to_int(down);
node.Down = down + " Mbps";
}
}
node.DownSpeed = to_int(down_speed);
if (!down_speed.empty())
node.DownSpeed = to_int(down_speed);
node.AuthStr = auth_str;
if (!auth.empty())
node.AuthStr = base64Decode(auth);
Expand Down

0 comments on commit d70edf1

Please sign in to comment.