Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a4fa61b4
Unverified
Commit
a4fa61b4
authored
Jun 26, 2020
by
Jenn Magder
Committed by
GitHub
Jun 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ephemeral ports for iOS port forwarding (#60381)
parent
025463f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+11
-2
devices_test.dart
...es/flutter_tools/test/general.shard/ios/devices_test.dart
+7
-0
ios_device_port_forwarder_test.dart
...est/general.shard/ios/ios_device_port_forwarder_test.dart
+12
-4
No files found.
packages/flutter_tools/lib/src/ios/devices.dart
View file @
a4fa61b4
...
...
@@ -14,6 +14,7 @@ import '../artifacts.dart';
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
import
'../base/os.dart'
;
import
'../base/platform.dart'
;
import
'../base/process.dart'
;
import
'../base/utils.dart'
;
...
...
@@ -493,6 +494,7 @@ class IOSDevice extends Device {
dyLdLibEntry:
globals
.
cache
.
dyLdLibEntry
,
id:
id
,
iproxyPath:
_iproxyPath
,
operatingSystemUtils:
globals
.
os
,
);
@visibleForTesting
...
...
@@ -763,11 +765,13 @@ class IOSDevicePortForwarder extends DevicePortForwarder {
@required
MapEntry
<
String
,
String
>
dyLdLibEntry
,
@required
String
id
,
@required
String
iproxyPath
,
@required
OperatingSystemUtils
operatingSystemUtils
,
})
:
_logger
=
logger
,
_dyLdLibEntry
=
dyLdLibEntry
,
_id
=
id
,
_iproxyPath
=
iproxyPath
,
_processUtils
=
ProcessUtils
(
processManager:
processManager
,
logger:
logger
);
_processUtils
=
ProcessUtils
(
processManager:
processManager
,
logger:
logger
),
_operatingSystemUtils
=
operatingSystemUtils
;
/// Create a [IOSDevicePortForwarder] for testing.
///
...
...
@@ -779,6 +783,7 @@ class IOSDevicePortForwarder extends DevicePortForwarder {
@required
ProcessManager
processManager
,
@required
Logger
logger
,
String
id
,
OperatingSystemUtils
operatingSystemUtils
,
})
{
return
IOSDevicePortForwarder
(
processManager:
processManager
,
...
...
@@ -788,6 +793,7 @@ class IOSDevicePortForwarder extends DevicePortForwarder {
dyLdLibEntry:
const
MapEntry
<
String
,
String
>(
'DYLD_LIBRARY_PATH'
,
'/path/to/libs'
,
),
operatingSystemUtils:
operatingSystemUtils
,
);
}
...
...
@@ -796,6 +802,7 @@ class IOSDevicePortForwarder extends DevicePortForwarder {
final
MapEntry
<
String
,
String
>
_dyLdLibEntry
;
final
String
_id
;
final
String
_iproxyPath
;
final
OperatingSystemUtils
_operatingSystemUtils
;
@override
List
<
ForwardedPort
>
forwardedPorts
=
<
ForwardedPort
>[];
...
...
@@ -811,7 +818,9 @@ class IOSDevicePortForwarder extends DevicePortForwarder {
Future
<
int
>
forward
(
int
devicePort
,
{
int
hostPort
})
async
{
final
bool
autoselect
=
hostPort
==
null
||
hostPort
==
0
;
if
(
autoselect
)
{
hostPort
=
1024
;
final
int
freePort
=
await
_operatingSystemUtils
?.
findFreePort
();
// Dynamic port range 49152 - 65535.
hostPort
=
freePort
==
null
||
freePort
==
0
?
49152
:
freePort
;
}
Process
process
;
...
...
packages/flutter_tools/test/general.shard/ios/devices_test.dart
View file @
a4fa61b4
...
...
@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/artifacts.dart';
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
...
...
@@ -226,6 +227,12 @@ void main() {
iproxyPath:
mockArtifacts
.
getArtifactPath
(
Artifact
.
iproxy
,
platform:
TargetPlatform
.
ios
),
logger:
logger
,
processManager:
FakeProcessManager
.
any
(),
operatingSystemUtils:
OperatingSystemUtils
(
fileSystem:
mockFileSystem
,
logger:
logger
,
platform:
FakePlatform
(
operatingSystem:
'macos'
),
processManager:
FakeProcessManager
.
any
(),
),
);
portForwarder
.
addForwardedPorts
(<
ForwardedPort
>[
forwardedPort
]);
return
portForwarder
;
...
...
packages/flutter_tools/test/general.shard/ios/ios_device_port_forwarder_test.dart
View file @
a4fa61b4
...
...
@@ -3,7 +3,9 @@
// found in the LICENSE file.
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
@@ -20,27 +22,33 @@ void main() {
const
int
devicePort
=
456
;
final
FakeProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'iproxy'
,
'
102
4'
,
'456'
,
'1234'
],
command:
<
String
>[
'iproxy'
,
'
4915
4'
,
'456'
,
'1234'
],
// iproxy does not exit with 0 when it cannot forward.
exitCode:
0
,
stdout:
null
,
// no stdout indicates failure.
environment:
kDyLdLibEntry
,
),
const
FakeCommand
(
command:
<
String
>[
'iproxy'
,
'
102
5'
,
'456'
,
'1234'
],
command:
<
String
>[
'iproxy'
,
'
4915
5'
,
'456'
,
'1234'
],
exitCode:
0
,
stdout:
'not empty'
,
environment:
kDyLdLibEntry
,
),
]);
final
MockOperatingSystemUtils
operatingSystemUtils
=
MockOperatingSystemUtils
();
when
(
operatingSystemUtils
.
findFreePort
()).
thenAnswer
((
Invocation
invocation
)
=>
Future
<
int
>.
value
(
49154
));
final
IOSDevicePortForwarder
portForwarder
=
IOSDevicePortForwarder
.
test
(
processManager:
processManager
,
logger:
BufferLogger
.
test
(),
operatingSystemUtils:
operatingSystemUtils
,
);
final
int
hostPort
=
await
portForwarder
.
forward
(
devicePort
);
// First port tried (
102
4) should fail, then succeed on the next
expect
(
hostPort
,
102
4
+
1
);
// First port tried (
4915
4) should fail, then succeed on the next
expect
(
hostPort
,
4915
4
+
1
);
expect
(
processManager
.
hasRemainingExpectations
,
false
);
});
}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment