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
6c6dbec1
Commit
6c6dbec1
authored
Apr 26, 2017
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace CloneTLSConfig() with (*tls.Config).Clone()
parent
acca01bc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2 additions
and
96 deletions
+2
-96
BUILD
staging/src/k8s.io/apimachinery/pkg/util/net/BUILD
+1
-4
http.go
staging/src/k8s.io/apimachinery/pkg/util/net/http.go
+0
-28
http_test.go
staging/src/k8s.io/apimachinery/pkg/util/net/http_test.go
+0
-63
dial.go
staging/src/k8s.io/apiserver/pkg/util/proxy/dial.go
+1
-1
No files found.
staging/src/k8s.io/apimachinery/pkg/util/net/BUILD
View file @
6c6dbec1
...
@@ -19,10 +19,7 @@ go_test(
...
@@ -19,10 +19,7 @@ go_test(
],
],
library = ":go_default_library",
library = ":go_default_library",
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = ["//vendor/github.com/spf13/pflag:go_default_library"],
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
],
)
)
go_library(
go_library(
...
...
staging/src/k8s.io/apimachinery/pkg/util/net/http.go
View file @
6c6dbec1
...
@@ -112,34 +112,6 @@ func DialerFor(transport http.RoundTripper) (DialFunc, error) {
...
@@ -112,34 +112,6 @@ func DialerFor(transport http.RoundTripper) (DialFunc, error) {
}
}
}
}
// CloneTLSConfig returns a tls.Config with all exported fields except SessionTicketsDisabled and SessionTicketKey copied.
// This makes it safe to call CloneTLSConfig on a config in active use by a server.
// TODO: replace with tls.Config#Clone when we move to go1.8
func
CloneTLSConfig
(
cfg
*
tls
.
Config
)
*
tls
.
Config
{
if
cfg
==
nil
{
return
&
tls
.
Config
{}
}
return
&
tls
.
Config
{
Rand
:
cfg
.
Rand
,
Time
:
cfg
.
Time
,
Certificates
:
cfg
.
Certificates
,
NameToCertificate
:
cfg
.
NameToCertificate
,
GetCertificate
:
cfg
.
GetCertificate
,
RootCAs
:
cfg
.
RootCAs
,
NextProtos
:
cfg
.
NextProtos
,
ServerName
:
cfg
.
ServerName
,
ClientAuth
:
cfg
.
ClientAuth
,
ClientCAs
:
cfg
.
ClientCAs
,
InsecureSkipVerify
:
cfg
.
InsecureSkipVerify
,
CipherSuites
:
cfg
.
CipherSuites
,
PreferServerCipherSuites
:
cfg
.
PreferServerCipherSuites
,
ClientSessionCache
:
cfg
.
ClientSessionCache
,
MinVersion
:
cfg
.
MinVersion
,
MaxVersion
:
cfg
.
MaxVersion
,
CurvePreferences
:
cfg
.
CurvePreferences
,
}
}
type
TLSClientConfigHolder
interface
{
type
TLSClientConfigHolder
interface
{
TLSClientConfig
()
*
tls
.
Config
TLSClientConfig
()
*
tls
.
Config
}
}
...
...
staging/src/k8s.io/apimachinery/pkg/util/net/http_test.go
View file @
6c6dbec1
...
@@ -25,72 +25,9 @@ import (
...
@@ -25,72 +25,9 @@ import (
"net/url"
"net/url"
"os"
"os"
"reflect"
"reflect"
"runtime"
"strings"
"testing"
"testing"
"k8s.io/apimachinery/pkg/util/sets"
)
)
func
TestCloneTLSConfig
(
t
*
testing
.
T
)
{
expected
:=
sets
.
NewString
(
// These fields are copied in CloneTLSConfig
"Rand"
,
"Time"
,
"Certificates"
,
"RootCAs"
,
"NextProtos"
,
"ServerName"
,
"InsecureSkipVerify"
,
"CipherSuites"
,
"PreferServerCipherSuites"
,
"MinVersion"
,
"MaxVersion"
,
"CurvePreferences"
,
"NameToCertificate"
,
"GetCertificate"
,
"ClientAuth"
,
"ClientCAs"
,
"ClientSessionCache"
,
// These fields are not copied
"SessionTicketsDisabled"
,
"SessionTicketKey"
,
// These fields are unexported
"serverInitOnce"
,
"mutex"
,
"sessionTicketKeys"
,
// go1.8
"DynamicRecordSizingDisabled"
,
"GetClientCertificate"
,
"GetConfigForClient"
,
"KeyLogWriter"
,
"Renegotiation"
,
"VerifyPeerCertificate"
,
"originalConfig"
,
)
// See #33936.
if
strings
.
HasPrefix
(
runtime
.
Version
(),
"go1.7"
)
{
expected
.
Insert
(
"DynamicRecordSizingDisabled"
,
"Renegotiation"
)
}
fields
:=
sets
.
NewString
()
structType
:=
reflect
.
TypeOf
(
tls
.
Config
{})
for
i
:=
0
;
i
<
structType
.
NumField
();
i
++
{
fields
.
Insert
(
structType
.
Field
(
i
)
.
Name
)
}
if
missing
:=
expected
.
Difference
(
fields
);
len
(
missing
)
>
0
{
t
.
Errorf
(
"Expected fields that were not seen in http.Transport: %v"
,
missing
.
List
())
}
if
extra
:=
fields
.
Difference
(
expected
);
len
(
extra
)
>
0
{
t
.
Errorf
(
"New fields seen in http.Transport: %v
\n
Add to CopyClientTLSConfig if client-relevant, then add to expected list in TestCopyClientTLSConfig"
,
extra
.
List
())
}
}
func
TestGetClientIP
(
t
*
testing
.
T
)
{
func
TestGetClientIP
(
t
*
testing
.
T
)
{
ipString
:=
"10.0.0.1"
ipString
:=
"10.0.0.1"
ip
:=
net
.
ParseIP
(
ipString
)
ip
:=
net
.
ParseIP
(
ipString
)
...
...
staging/src/k8s.io/apiserver/pkg/util/proxy/dial.go
View file @
6c6dbec1
...
@@ -69,7 +69,7 @@ func DialURL(url *url.URL, transport http.RoundTripper) (net.Conn, error) {
...
@@ -69,7 +69,7 @@ func DialURL(url *url.URL, transport http.RoundTripper) (net.Conn, error) {
inferredHost
=
host
inferredHost
=
host
}
}
// Make a copy to avoid polluting the provided config
// Make a copy to avoid polluting the provided config
tlsConfigCopy
:=
utilnet
.
CloneTLSConfig
(
tlsConfig
)
tlsConfigCopy
:=
tlsConfig
.
Clone
(
)
tlsConfigCopy
.
ServerName
=
inferredHost
tlsConfigCopy
.
ServerName
=
inferredHost
tlsConfig
=
tlsConfigCopy
tlsConfig
=
tlsConfigCopy
}
}
...
...
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