mirror of
https://github.com/nestriness/cdc-file-transfer.git
synced 2026-01-30 14:35:37 +02:00
[cdc_rsync] Use ephemeral port on client (#96)
Instead of calling netstat locally to find out available ports in a tight range, call bind() with port zero to find an available ephemeral port. This is faster and much simpler, and will eventually help getting rid of PortManager. Also fixes issues with running SSH commands on Windows when the remote shell is Powershell (aka Backslash Bingo).
This commit is contained in:
@@ -585,40 +585,6 @@ TEST_F(ParamsTest, IncludeExcludeMixed_ProperOrder) {
|
||||
ExpectNoError();
|
||||
}
|
||||
|
||||
TEST_F(ParamsTest, ForwardPort_Single) {
|
||||
const char* argv[] = {"cdc_rsync.exe", "--forward-port=65535", kSrc,
|
||||
kUserHostDst, NULL};
|
||||
EXPECT_TRUE(Parse(static_cast<int>(std::size(argv)) - 1, argv, ¶meters_));
|
||||
EXPECT_EQ(parameters_.options.forward_port_first, 65535);
|
||||
EXPECT_EQ(parameters_.options.forward_port_last, 65535);
|
||||
ExpectNoError();
|
||||
}
|
||||
|
||||
TEST_F(ParamsTest, ForwardPort_Range) {
|
||||
const char* argv[] = {
|
||||
"cdc_rsync.exe", "--forward-port", "1-2", kSrc, kUserHostDst, NULL};
|
||||
EXPECT_TRUE(Parse(static_cast<int>(std::size(argv)) - 1, argv, ¶meters_));
|
||||
EXPECT_EQ(parameters_.options.forward_port_first, 1);
|
||||
EXPECT_EQ(parameters_.options.forward_port_last, 2);
|
||||
ExpectNoError();
|
||||
}
|
||||
|
||||
TEST_F(ParamsTest, ForwardPort_NoValue) {
|
||||
const char* argv[] = {"cdc_rsync.exe", "--forward-port=", kSrc, kUserHostDst,
|
||||
NULL};
|
||||
EXPECT_FALSE(
|
||||
Parse(static_cast<int>(std::size(argv)) - 1, argv, ¶meters_));
|
||||
ExpectError(NeedsValueError("forward-port"));
|
||||
}
|
||||
|
||||
TEST_F(ParamsTest, ForwardPort_BadValueTooSmall) {
|
||||
const char* argv[] = {"cdc_rsync.exe", "--forward-port=0", kSrc, kUserHostDst,
|
||||
NULL};
|
||||
EXPECT_FALSE(
|
||||
Parse(static_cast<int>(std::size(argv)) - 1, argv, ¶meters_));
|
||||
ExpectError("Failed to parse");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace params
|
||||
} // namespace cdc_ft
|
||||
|
||||
Reference in New Issue
Block a user