summaryrefslogtreecommitdiff
path: root/edgemesh
diff options
context:
space:
mode:
authorarcanique <strugaml@163.com>2019-09-04 19:35:37 +0800
committerarcanique <strugaml@163.com>2019-09-05 12:00:16 +0800
commit32833097b1572a0955cc9805f947255cac348e7d (patch)
treea93223b62fdaf85e7bb9846b4cf685bf9b77f1c9 /edgemesh
parentL4 Proxy support (diff)
downloadkubeedge-32833097b1572a0955cc9805f947255cac348e7d.tar.gz
fix bug #1097
Diffstat (limited to 'edgemesh')
-rw-r--r--edgemesh/pkg/proxy/proxy.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/edgemesh/pkg/proxy/proxy.go b/edgemesh/pkg/proxy/proxy.go
index 8bac1e486..eddee5778 100644
--- a/edgemesh/pkg/proxy/proxy.go
+++ b/edgemesh/pkg/proxy/proxy.go
@@ -50,6 +50,7 @@ const (
defaultIpPoolSize = 20
defaultTcpClientTimeout = time.Second * 2
defaultTcpReconnectTimes = 3
+ firstPort = 0
)
var (
@@ -544,23 +545,18 @@ func (c *conntrack) processServerProxy() {
//isL4Proxy Determine whether to use L4 proxy
func IsL4Proxy(svc *v1.Service) bool {
+ if len(svc.Spec.Ports) == 0 {
+ return false
+ }
// In the defination of k8s-Service, we can use Service.Spec.Ports.Name to
// indicate whether the Service enables L4 proxy mode. According to our
// current L7 mode only support the http protocol. Other 7-layer protocols
// are automatically degraded to tcp until supported
- port := svc.Spec.Ports[0]
+ port := svc.Spec.Ports[firstPort]
switch port.Name {
- case "websocket":
- return true
- case "http":
- return false
- case "grpc":
- return true
- case "https":
- return true
- case "tcp":
+ case "websocket", "grpc", "https", "tcp":
return true
- case "udp":
+ case "http", "udp":
return false
default:
return true