Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0b7b613b
Commit
0b7b613b
authored
Oct 21, 2016
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add BindNetwork to GenericApiServer.Config
parent
07f78836
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
config.go
pkg/genericapiserver/config.go
+3
-0
serve.go
pkg/genericapiserver/serve.go
+8
-4
No files found.
pkg/genericapiserver/config.go
View file @
0b7b613b
...
@@ -177,6 +177,9 @@ type Config struct {
...
@@ -177,6 +177,9 @@ type Config struct {
type
ServingInfo
struct
{
type
ServingInfo
struct
{
// BindAddress is the ip:port to serve on
// BindAddress is the ip:port to serve on
BindAddress
string
BindAddress
string
// BindNetwork is the type of network to bind to - defaults to "tcp", accepts "tcp",
// "tcp4", and "tcp6".
BindNetwork
string
}
}
type
SecureServingInfo
struct
{
type
SecureServingInfo
struct
{
...
...
pkg/genericapiserver/serve.go
View file @
0b7b613b
...
@@ -89,7 +89,7 @@ func (s *GenericAPIServer) serveSecurely(stopCh <-chan struct{}) error {
...
@@ -89,7 +89,7 @@ func (s *GenericAPIServer) serveSecurely(stopCh <-chan struct{}) error {
}
}
glog
.
Infof
(
"Serving securely on %s"
,
s
.
SecureServingInfo
.
BindAddress
)
glog
.
Infof
(
"Serving securely on %s"
,
s
.
SecureServingInfo
.
BindAddress
)
s
.
effectiveSecurePort
,
err
=
runServer
(
secureServer
,
stopCh
)
s
.
effectiveSecurePort
,
err
=
runServer
(
secureServer
,
s
.
SecureServingInfo
.
BindNetwork
,
s
topCh
)
return
err
return
err
}
}
...
@@ -104,19 +104,23 @@ func (s *GenericAPIServer) serveInsecurely(stopCh <-chan struct{}) error {
...
@@ -104,19 +104,23 @@ func (s *GenericAPIServer) serveInsecurely(stopCh <-chan struct{}) error {
}
}
glog
.
Infof
(
"Serving insecurely on %s"
,
s
.
InsecureServingInfo
.
BindAddress
)
glog
.
Infof
(
"Serving insecurely on %s"
,
s
.
InsecureServingInfo
.
BindAddress
)
var
err
error
var
err
error
s
.
effectiveInsecurePort
,
err
=
runServer
(
insecureServer
,
stopCh
)
s
.
effectiveInsecurePort
,
err
=
runServer
(
insecureServer
,
s
.
InsecureServingInfo
.
BindNetwork
,
s
topCh
)
return
err
return
err
}
}
// runServer listens on the given port, then spawns a go-routine continuously serving
// runServer listens on the given port, then spawns a go-routine continuously serving
// until the stopCh is closed. The port is returned. This function does not block.
// until the stopCh is closed. The port is returned. This function does not block.
func
runServer
(
server
*
http
.
Server
,
stopCh
<-
chan
struct
{})
(
int
,
error
)
{
func
runServer
(
server
*
http
.
Server
,
network
string
,
stopCh
<-
chan
struct
{})
(
int
,
error
)
{
if
len
(
server
.
Addr
)
==
0
{
if
len
(
server
.
Addr
)
==
0
{
return
0
,
errors
.
New
(
"address cannot be empty"
)
return
0
,
errors
.
New
(
"address cannot be empty"
)
}
}
if
len
(
network
)
==
0
{
network
=
"tcp"
}
// first listen is synchronous (fail early!)
// first listen is synchronous (fail early!)
ln
,
err
:=
net
.
Listen
(
"tcp"
,
server
.
Addr
)
ln
,
err
:=
net
.
Listen
(
network
,
server
.
Addr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"failed to listen on %v: %v"
,
server
.
Addr
,
err
)
return
0
,
fmt
.
Errorf
(
"failed to listen on %v: %v"
,
server
.
Addr
,
err
)
}
}
...
...
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