Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
7ddf7dda
Commit
7ddf7dda
authored
Dec 10, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/rpc: remove the PortRange stuff
parent
3b3d09cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
71 deletions
+0
-71
packer/plugin/plugin.go
packer/plugin/plugin.go
+0
-3
packer/rpc/port.go
packer/rpc/port.go
+0
-30
packer/rpc/port_test.go
packer/rpc/port_test.go
+0
-38
No files found.
packer/plugin/plugin.go
View file @
7ddf7dda
...
...
@@ -62,9 +62,6 @@ func Server() (*packrpc.Server, error) {
log
.
Printf
(
"Plugin minimum port: %d
\n
"
,
minPort
)
log
.
Printf
(
"Plugin maximum port: %d
\n
"
,
maxPort
)
// Set the RPC port range
packrpc
.
PortRange
(
int
(
minPort
),
int
(
maxPort
))
var
address
string
var
listener
net
.
Listener
for
port
:=
minPort
;
port
<=
maxPort
;
port
++
{
...
...
packer/rpc/port.go
deleted
100644 → 0
View file @
3b3d09cb
package
rpc
import
(
"fmt"
"net"
)
var
portRangeMin
int
=
10000
var
portRangeMax
int
=
11000
// This sets the port range that the RPC stuff will use when creating
// new temporary servers. Some RPC calls require the creation of temporary
// RPC servers. These allow you to pick a range these bind to.
func
PortRange
(
min
,
max
int
)
{
portRangeMin
=
min
portRangeMax
=
max
}
// This finds an open port in the given range and returns a listener
// bound to that port.
func
netListenerInRange
(
min
,
max
int
)
net
.
Listener
{
for
port
:=
min
;
port
<=
max
;
port
++
{
l
,
err
:=
net
.
Listen
(
"tcp"
,
fmt
.
Sprintf
(
"127.0.0.1:%d"
,
port
))
if
err
==
nil
{
return
l
}
}
return
nil
}
packer/rpc/port_test.go
deleted
100644 → 0
View file @
3b3d09cb
package
rpc
import
(
"net"
"strings"
"testing"
)
func
addrPort
(
address
net
.
Addr
)
string
{
parts
:=
strings
.
Split
(
address
.
String
(),
":"
)
return
parts
[
len
(
parts
)
-
1
]
}
func
Test_netListenerInRange
(
t
*
testing
.
T
)
{
// Open up port 10000 so that we take up a port
L1000
,
err
:=
net
.
Listen
(
"tcp"
,
"127.0.0.1:11000"
)
defer
L1000
.
Close
()
if
err
!=
nil
{
t
.
Fatalf
(
"bad: %s"
,
err
)
}
if
err
==
nil
{
// Verify it selects an open port
L
:=
netListenerInRange
(
11000
,
11005
)
if
L
==
nil
{
t
.
Fatal
(
"L should not be nil"
)
}
if
addrPort
(
L
.
Addr
())
!=
"11001"
{
t
.
Fatalf
(
"bad: %s"
,
L
.
Addr
())
}
// Returns nil if there are no open ports
L
=
netListenerInRange
(
11000
,
11000
)
if
L
!=
nil
{
t
.
Fatalf
(
"bad: %#v"
,
L
)
}
}
}
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