Skip to content

Commit

Permalink
Force reverse tunnel socket to be binded to localhost (#600)
Browse files Browse the repository at this point in the history
* Do not fail if SocketEndpoint::name is specified for tcp tunneling

* Force pfsr source to be bounded to localhost
  • Loading branch information
lostystyg committed Sep 4, 2023
1 parent ade1151 commit 2f8dfdd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/base/TunnelUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ vector<PortForwardSourceRequest> parseRangesToRequests(const string& input) {
int portRangeLength = sourcePortEnd - sourcePortStart + 1;
for (int i = 0; i < portRangeLength; ++i) {
PortForwardSourceRequest pfsr;
pfsr.mutable_source()->set_name("localhost");
pfsr.mutable_source()->set_port(sourcePortStart + i);
pfsr.mutable_destination()->set_port(destinationPortStart + i);
pfsrs.push_back(pfsr);
Expand All @@ -49,6 +50,7 @@ vector<PortForwardSourceRequest> parseRangesToRequests(const string& input) {
"destination must be a range (and vice versa)");
} else {
PortForwardSourceRequest pfsr;
pfsr.mutable_source()->set_name("localhost");
pfsr.mutable_source()->set_port(stoi(sourceDestination[0]));
pfsr.mutable_destination()->set_port(stoi(sourceDestination[1]));
pfsrs.push_back(pfsr);
Expand Down
4 changes: 0 additions & 4 deletions src/terminal/forwarding/PortForwardHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ PortForwardSourceResponse PortForwardHandler::createSource(
SocketEndpoint source;
if (pfsr.has_source()) {
source = pfsr.source();
if (source.has_name()) {
throw runtime_error(
"Named socket tunneling is only allowed with temporary filenames.");
}
} else {
// Make a random file to forward the pipe
string sourcePattern =
Expand Down

0 comments on commit 2f8dfdd

Please sign in to comment.