Remove Go 1.9 / AppEngine support; assume go1.12 build tag (#3767)
This commit is contained in:
@ -16,8 +16,6 @@ matrix:
|
|||||||
env: GO111MODULE=on
|
env: GO111MODULE=on
|
||||||
- go: 1.12.x
|
- go: 1.12.x
|
||||||
env: GO111MODULE=on
|
env: GO111MODULE=on
|
||||||
- go: 1.9.x
|
|
||||||
env: GAE=1
|
|
||||||
|
|
||||||
go_import_path: google.golang.org/grpc
|
go_import_path: google.golang.org/grpc
|
||||||
|
|
||||||
@ -30,13 +28,11 @@ before_install:
|
|||||||
install:
|
install:
|
||||||
- try3() { eval "$*" || eval "$*" || eval "$*"; }
|
- try3() { eval "$*" || eval "$*" || eval "$*"; }
|
||||||
- try3 'if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else make testdeps; fi'
|
- try3 'if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else make testdeps; fi'
|
||||||
- if [[ -n "${GAE}" ]]; then source ./install_gae.sh; make testappenginedeps; fi
|
|
||||||
- if [[ -n "${VET}" ]]; then ./vet.sh -install; fi
|
- if [[ -n "${VET}" ]]; then ./vet.sh -install; fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- set -e
|
- set -e
|
||||||
- if [[ -n "${TESTEXTRAS}" ]]; then examples/examples_test.sh; interop/interop_test.sh; make testsubmodule; exit 0; fi
|
- if [[ -n "${TESTEXTRAS}" ]]; then examples/examples_test.sh; interop/interop_test.sh; make testsubmodule; exit 0; fi
|
||||||
- if [[ -n "${VET}" ]]; then ./vet.sh; fi
|
- if [[ -n "${VET}" ]]; then ./vet.sh; fi
|
||||||
- if [[ -n "${GAE}" ]]; then make testappengine; exit 0; fi
|
|
||||||
- if [[ -n "${RACE}" ]]; then make testrace; exit 0; fi
|
- if [[ -n "${RACE}" ]]; then make testrace; exit 0; fi
|
||||||
- make test
|
- make test
|
||||||
|
@ -57,6 +57,5 @@ How to get your contributions merged smoothly and quickly.
|
|||||||
- `make vet` to catch vet errors
|
- `make vet` to catch vet errors
|
||||||
- `make test` to run the tests
|
- `make test` to run the tests
|
||||||
- `make testrace` to run tests in race mode
|
- `make testrace` to run tests in race mode
|
||||||
- optional `make testappengine` to run tests with appengine
|
|
||||||
|
|
||||||
- Exceptions to the rules can be made if there's a compelling reason for doing so.
|
- Exceptions to the rules can be made if there's a compelling reason for doing so.
|
||||||
|
8
Makefile
8
Makefile
@ -22,12 +22,6 @@ test: testdeps
|
|||||||
testsubmodule: testdeps
|
testsubmodule: testdeps
|
||||||
cd security/advancedtls && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/advancedtls/...
|
cd security/advancedtls && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/advancedtls/...
|
||||||
|
|
||||||
testappengine: testappenginedeps
|
|
||||||
goapp test -cpu 1,4 -timeout 7m google.golang.org/grpc/...
|
|
||||||
|
|
||||||
testappenginedeps:
|
|
||||||
goapp get -d -v -t -tags 'appengine appenginevm' google.golang.org/grpc/...
|
|
||||||
|
|
||||||
testdeps:
|
testdeps:
|
||||||
go get -d -v -t google.golang.org/grpc/...
|
go get -d -v -t google.golang.org/grpc/...
|
||||||
|
|
||||||
@ -53,8 +47,6 @@ vetdeps:
|
|||||||
deps \
|
deps \
|
||||||
proto \
|
proto \
|
||||||
test \
|
test \
|
||||||
testappengine \
|
|
||||||
testappenginedeps \
|
|
||||||
testdeps \
|
testdeps \
|
||||||
testrace \
|
testrace \
|
||||||
updatedeps \
|
updatedeps \
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2018 gRPC authors.
|
* Copyright 2018 gRPC authors.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build !linux appengine
|
// +build !linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build linux,!appengine
|
// +build linux
|
||||||
// +build 386 amd64
|
// +build 386 amd64
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -58,7 +58,7 @@ type protoToSocketOptFunc func([]*channelzpb.SocketOption) *channelz.SocketOptio
|
|||||||
|
|
||||||
// protoToSocketOpt is used in function socketProtoToStruct to extract socket option
|
// protoToSocketOpt is used in function socketProtoToStruct to extract socket option
|
||||||
// data from unmarshaled proto message.
|
// data from unmarshaled proto message.
|
||||||
// It is only defined under linux, non-appengine environment on x86 architecture.
|
// It is only defined under linux environment on x86 architecture.
|
||||||
var protoToSocketOpt protoToSocketOptFunc
|
var protoToSocketOpt protoToSocketOptFunc
|
||||||
|
|
||||||
// emptyTime is used for detecting unset value of time.Time type.
|
// emptyTime is used for detecting unset value of time.Time type.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build 386,linux,!appengine
|
// +build 386,linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build amd64,linux,!appengine
|
// +build amd64,linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
// +build go1.12
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2019 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package credentials
|
|
||||||
|
|
||||||
import "crypto/tls"
|
|
||||||
|
|
||||||
// This init function adds cipher suite constants only defined in Go 1.12.
|
|
||||||
func init() {
|
|
||||||
cipherSuiteLookup[tls.TLS_AES_128_GCM_SHA256] = "TLS_AES_128_GCM_SHA256"
|
|
||||||
cipherSuiteLookup[tls.TLS_AES_256_GCM_SHA384] = "TLS_AES_256_GCM_SHA384"
|
|
||||||
cipherSuiteLookup[tls.TLS_CHACHA20_POLY1305_SHA256] = "TLS_CHACHA20_POLY1305_SHA256"
|
|
||||||
}
|
|
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2018 gRPC authors.
|
* Copyright 2018 gRPC authors.
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
// +build appengine
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2018 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package internal
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net"
|
|
||||||
)
|
|
||||||
|
|
||||||
// WrapSyscallConn returns newConn on appengine.
|
|
||||||
func WrapSyscallConn(rawConn, newConn net.Conn) net.Conn {
|
|
||||||
return newConn
|
|
||||||
}
|
|
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2018 gRPC authors.
|
* Copyright 2018 gRPC authors.
|
||||||
|
@ -241,6 +241,10 @@ var cipherSuiteLookup = map[uint16]string{
|
|||||||
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
|
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
|
||||||
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
|
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
|
||||||
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
|
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
|
||||||
|
// Go 1.12
|
||||||
|
tls.TLS_AES_128_GCM_SHA256: "TLS_AES_128_GCM_SHA256",
|
||||||
|
tls.TLS_AES_256_GCM_SHA384: "TLS_AES_256_GCM_SHA384",
|
||||||
|
tls.TLS_CHACHA20_POLY1305_SHA256: "TLS_CHACHA20_POLY1305_SHA256",
|
||||||
}
|
}
|
||||||
|
|
||||||
// cloneTLSConfig returns a shallow clone of the exported
|
// cloneTLSConfig returns a shallow clone of the exported
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.11
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.11
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
TMP=$(mktemp -d /tmp/sdk.XXX) \
|
|
||||||
&& curl -o $TMP.zip "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.68.zip" \
|
|
||||||
&& unzip -q $TMP.zip -d $TMP \
|
|
||||||
&& export PATH="$PATH:$TMP/go_appengine"
|
|
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2018 gRPC authors.
|
* Copyright 2018 gRPC authors.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build !linux appengine
|
// +build !linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -37,6 +37,6 @@ type SocketOptionData struct {
|
|||||||
// Windows OS doesn't support Socket Option
|
// Windows OS doesn't support Socket Option
|
||||||
func (s *SocketOptionData) Getsockopt(fd uintptr) {
|
func (s *SocketOptionData) Getsockopt(fd uintptr) {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
logger.Warning("Channelz: socket options are not supported on non-linux os and appengine.")
|
logger.Warning("Channelz: socket options are not supported on non-linux os.")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build linux,!appengine
|
// +build linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build !linux appengine
|
// +build !linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build linux,go1.10,!appengine
|
// +build linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
// +build !go1.10
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2020 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package credentials
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/tls"
|
|
||||||
"net/url"
|
|
||||||
)
|
|
||||||
|
|
||||||
//TODO(ZhenLian): delete this file when we remove Go 1.9 tests.
|
|
||||||
func SPIFFEIDFromState(state tls.ConnectionState) *url.URL {
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2019 gRPC authors.
|
* Copyright 2019 gRPC authors.
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
// +build appengine
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2019 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package buffer
|
|
||||||
|
|
||||||
// CircularBuffer is a no-op implementation for appengine builds.
|
|
||||||
//
|
|
||||||
// Appengine does not support stats because of lack of the support for unsafe
|
|
||||||
// pointers, which are necessary to efficiently store and retrieve things into
|
|
||||||
// and from a circular buffer. As a result, Push does not do anything and Drain
|
|
||||||
// returns an empty slice.
|
|
||||||
type CircularBuffer struct{}
|
|
||||||
|
|
||||||
// NewCircularBuffer returns a no-op for appengine builds.
|
|
||||||
func NewCircularBuffer(size uint32) (*CircularBuffer, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Push returns a no-op for appengine builds.
|
|
||||||
func (cb *CircularBuffer) Push(x interface{}) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drain returns a no-op for appengine builds.
|
|
||||||
func (cb *CircularBuffer) Drain() []interface{} {
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2019 gRPC authors.
|
* Copyright 2019 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2019 gRPC authors.
|
* Copyright 2019 gRPC authors.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2018 gRPC authors.
|
* Copyright 2018 gRPC authors.
|
||||||
@ -43,7 +41,7 @@ func GetCPUTime() int64 {
|
|||||||
return ts.Nano()
|
return ts.Nano()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rusage is an alias for syscall.Rusage under linux non-appengine environment.
|
// Rusage is an alias for syscall.Rusage under linux environment.
|
||||||
type Rusage syscall.Rusage
|
type Rusage syscall.Rusage
|
||||||
|
|
||||||
// GetRusage returns the resource usage of current process.
|
// GetRusage returns the resource usage of current process.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build !linux appengine
|
// +build !linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -35,40 +35,40 @@ var logger = grpclog.Component("core")
|
|||||||
|
|
||||||
func log() {
|
func log() {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
logger.Info("CPU time info is unavailable on non-linux or appengine environment.")
|
logger.Info("CPU time info is unavailable on non-linux environment.")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCPUTime returns the how much CPU time has passed since the start of this process.
|
// GetCPUTime returns the how much CPU time has passed since the start of this process.
|
||||||
// It always returns 0 under non-linux or appengine environment.
|
// It always returns 0 under non-linux environment.
|
||||||
func GetCPUTime() int64 {
|
func GetCPUTime() int64 {
|
||||||
log()
|
log()
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rusage is an empty struct under non-linux or appengine environment.
|
// Rusage is an empty struct under non-linux environment.
|
||||||
type Rusage struct{}
|
type Rusage struct{}
|
||||||
|
|
||||||
// GetRusage is a no-op function under non-linux or appengine environment.
|
// GetRusage is a no-op function under non-linux environment.
|
||||||
func GetRusage() (rusage *Rusage) {
|
func GetRusage() (rusage *Rusage) {
|
||||||
log()
|
log()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPUTimeDiff returns the differences of user CPU time and system CPU time used
|
// CPUTimeDiff returns the differences of user CPU time and system CPU time used
|
||||||
// between two Rusage structs. It a no-op function for non-linux or appengine environment.
|
// between two Rusage structs. It a no-op function for non-linux environment.
|
||||||
func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) {
|
func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) {
|
||||||
log()
|
log()
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTCPUserTimeout is a no-op function under non-linux or appengine environments
|
// SetTCPUserTimeout is a no-op function under non-linux environments
|
||||||
func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
|
func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
|
||||||
log()
|
log()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTCPUserTimeout is a no-op function under non-linux or appengine environments
|
// GetTCPUserTimeout is a no-op function under non-linux environments
|
||||||
// a negative return value indicates the operation is not supported
|
// a negative return value indicates the operation is not supported
|
||||||
func GetTCPUserTimeout(conn net.Conn) (int, error) {
|
func GetTCPUserTimeout(conn net.Conn) (int, error) {
|
||||||
log()
|
log()
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
// +build linux
|
// +build linux
|
||||||
// +build !appengine
|
|
||||||
// +build go1.11
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
@ -1,41 +0,0 @@
|
|||||||
// +build !go1.10
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2020 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package advancedtls
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/tls"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
// buildGetCertificates returns the first element of o.GetCertificates.
|
|
||||||
func buildGetCertificates(clientHello *tls.ClientHelloInfo, o *ServerOptions) (*tls.Certificate, error) {
|
|
||||||
if o.GetCertificates == nil {
|
|
||||||
return nil, fmt.Errorf("function GetCertificates must be specified")
|
|
||||||
}
|
|
||||||
certificates, err := o.GetCertificates(clientHello)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if len(certificates) == 0 {
|
|
||||||
return nil, fmt.Errorf("no certificates configured")
|
|
||||||
}
|
|
||||||
return certificates[0], nil
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
// +build !go1.10
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2019 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package advancedtls
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/tls"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
|
||||||
"google.golang.org/grpc/security/advancedtls/testdata"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TestGetCertificatesSNI tests SNI logic for go1.9.
|
|
||||||
func TestGetCertificatesSNI(t *testing.T) {
|
|
||||||
// Load server certificates for setting the serverGetCert callback function.
|
|
||||||
serverCert1, err := tls.LoadX509KeyPair(testdata.Path("server_cert_1.pem"), testdata.Path("server_key_1.pem"))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("tls.LoadX509KeyPair(server_cert_1.pem, server_key_1.pem) failed: %v", err)
|
|
||||||
}
|
|
||||||
serverCert2, err := tls.LoadX509KeyPair(testdata.Path("server_cert_2.pem"), testdata.Path("server_key_2.pem"))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("tls.LoadX509KeyPair(server_cert_2.pem, server_key_2.pem) failed: %v", err)
|
|
||||||
}
|
|
||||||
serverCert3, err := tls.LoadX509KeyPair(testdata.Path("server_cert_3.pem"), testdata.Path("server_key_3.pem"))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("tls.LoadX509KeyPair(server_cert_3.pem, server_key_3.pem) failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
tests := []struct {
|
|
||||||
desc string
|
|
||||||
serverGetCert func(*tls.ClientHelloInfo) ([]*tls.Certificate, error)
|
|
||||||
serverName string
|
|
||||||
wantCert tls.Certificate
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
desc: "Select serverCert1",
|
|
||||||
serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) {
|
|
||||||
return []*tls.Certificate{&serverCert1, &serverCert2, &serverCert3}, nil
|
|
||||||
},
|
|
||||||
// "foo.bar.com" is the common name on server certificate server_cert_1.pem.
|
|
||||||
serverName: "foo.bar.com",
|
|
||||||
wantCert: serverCert1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "Select serverCert2",
|
|
||||||
serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) {
|
|
||||||
return []*tls.Certificate{&serverCert1, &serverCert2, &serverCert3}, nil
|
|
||||||
},
|
|
||||||
// "foo.bar.server2.com" is the common name on server certificate server_cert_2.pem.
|
|
||||||
serverName: "foo.bar.server2.com",
|
|
||||||
wantCert: serverCert1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "Select serverCert3",
|
|
||||||
serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) {
|
|
||||||
return []*tls.Certificate{&serverCert1, &serverCert2, &serverCert3}, nil
|
|
||||||
},
|
|
||||||
// "google.com" is one of the DNS names on server certificate server_cert_3.pem.
|
|
||||||
serverName: "google.com",
|
|
||||||
wantCert: serverCert1,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, test := range tests {
|
|
||||||
test := test
|
|
||||||
t.Run(test.desc, func(t *testing.T) {
|
|
||||||
serverOptions := &ServerOptions{
|
|
||||||
GetCertificates: test.serverGetCert,
|
|
||||||
}
|
|
||||||
serverConfig, err := serverOptions.config()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("serverOptions.config() failed: %v", err)
|
|
||||||
}
|
|
||||||
pointFormatUncompressed := uint8(0)
|
|
||||||
clientHello := &tls.ClientHelloInfo{
|
|
||||||
CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA},
|
|
||||||
ServerName: test.serverName,
|
|
||||||
SupportedCurves: []tls.CurveID{tls.CurveP256},
|
|
||||||
SupportedPoints: []uint8{pointFormatUncompressed},
|
|
||||||
SupportedVersions: []uint16{tls.VersionTLS10},
|
|
||||||
}
|
|
||||||
gotCertificate, err := serverConfig.GetCertificate(clientHello)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("serverConfig.GetCertificate(clientHello) failed: %v", err)
|
|
||||||
}
|
|
||||||
if !cmp.Equal(gotCertificate, test.wantCert, cmp.AllowUnexported(tls.Certificate{})) {
|
|
||||||
t.Errorf("GetCertificates() = %v, want %v", gotCertificate, test.wantCert)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.10
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2019 gRPC authors.
|
* Copyright 2019 gRPC authors.
|
@ -1,4 +1,4 @@
|
|||||||
// +build go1.10,linux,!appengine
|
// +build linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2018 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// vet checks whether files that are supposed to be built on appengine running
|
|
||||||
// Go 1.10 or earlier import an unsupported package (e.g. "unsafe", "syscall").
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"go/build"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fail := false
|
|
||||||
b := build.Default
|
|
||||||
b.BuildTags = []string{"appengine", "appenginevm"}
|
|
||||||
argsWithoutProg := os.Args[1:]
|
|
||||||
for _, dir := range argsWithoutProg {
|
|
||||||
p, err := b.Import(".", dir, 0)
|
|
||||||
if _, ok := err.(*build.NoGoError); ok {
|
|
||||||
continue
|
|
||||||
} else if err != nil {
|
|
||||||
fmt.Printf("build.Import failed due to %v\n", err)
|
|
||||||
fail = true
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, pkg := range p.Imports {
|
|
||||||
if pkg == "syscall" || pkg == "unsafe" {
|
|
||||||
fmt.Printf("Package %s/%s importing %s package without appengine build tag is NOT ALLOWED!\n", p.Dir, p.Name, pkg)
|
|
||||||
fail = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if fail {
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
4
vet.sh
4
vet.sh
@ -89,10 +89,6 @@ not git grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/" -- "*.go"
|
|||||||
# - Ensure all xds proto imports are renamed to *pb or *grpc.
|
# - Ensure all xds proto imports are renamed to *pb or *grpc.
|
||||||
git grep '"github.com/envoyproxy/go-control-plane/envoy' -- '*.go' | not grep -v 'pb "\|grpc "'
|
git grep '"github.com/envoyproxy/go-control-plane/envoy' -- '*.go' | not grep -v 'pb "\|grpc "'
|
||||||
|
|
||||||
# - Check imports that are illegal in appengine (until Go 1.11).
|
|
||||||
# TODO: Remove when we drop Go 1.10 support
|
|
||||||
go list -f {{.Dir}} ./... | xargs go run test/go_vet/vet.go
|
|
||||||
|
|
||||||
# - gofmt, goimports, golint (with exceptions for generated code), go vet.
|
# - gofmt, goimports, golint (with exceptions for generated code), go vet.
|
||||||
gofmt -s -d -l . 2>&1 | fail_on_output
|
gofmt -s -d -l . 2>&1 | fail_on_output
|
||||||
goimports -l . 2>&1 | not grep -vE "\.pb\.go"
|
goimports -l . 2>&1 | not grep -vE "\.pb\.go"
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2019 gRPC authors.
|
* Copyright 2019 gRPC authors.
|
||||||
|
Reference in New Issue
Block a user