diff --git a/core/tunhandler.go b/core/tunhandler.go index 2284e6d4..41b404f7 100644 --- a/core/tunhandler.go +++ b/core/tunhandler.go @@ -17,11 +17,8 @@ import ( "golang.org/x/net/ipv6" ) -type key [16]byte - -func ipToTunRouteKey(ip net.IP) (key key) { - copy(key[:], ip.To16()) - return +func ipToTunRouteKey(ip net.IP) string { + return ip.To16().String() } type tunHandler struct { @@ -253,11 +250,11 @@ func (h *tunHandler) transportTun(tun net.Conn, conn net.PacketConn, raddr net.A return err } - rkey := ipToTunRouteKey(src) - if actual, loaded := h.routes.LoadOrStore(rkey, addr); loaded { + routeKey := ipToTunRouteKey(src) + if actual, loaded := h.routes.LoadOrStore(routeKey, addr); loaded { if actual.(net.Addr).String() != addr.String() { log.Debugf("[tun] update route: %s -> %s (old %s)", src, addr, actual.(net.Addr)) - h.routes.Store(rkey, addr) + h.routes.Store(routeKey, addr) } } else { log.Debugf("[tun] new route: %s -> %s", src, addr) diff --git a/dns/dns.go b/dns/dns.go index f30aadd6..9821717e 100644 --- a/dns/dns.go +++ b/dns/dns.go @@ -26,8 +26,8 @@ func GetDNSServiceIPFromPod(clientset *kubernetes.Clientset, restclient *rest.RE for i := range ipp { resolvConf.Servers[i] = ipp[i] } - return resolvConf, nil } + return resolvConf, nil } else { return nil, err } diff --git a/pkg/connect.go b/pkg/connect.go index 5cace7e4..03426d43 100644 --- a/pkg/connect.go +++ b/pkg/connect.go @@ -82,7 +82,7 @@ func (c *ConnectOptions) createRemoteInboundPod() { tunIp.IP.String(), c.routerIP, virtualShadowIp.String(), - strings.Join(list, ","), + trafficManager.String(), ) } else { err = CreateInboundPod( @@ -93,7 +93,7 @@ func (c *ConnectOptions) createRemoteInboundPod() { tunIp.IP.String(), c.routerIP, virtualShadowIp.String(), - strings.Join(list, ","), + trafficManager.String(), ) } if err != nil { diff --git a/remote/envoy.go b/remote/envoy.go index ff0868a3..f8db6719 100644 --- a/remote/envoy.go +++ b/remote/envoy.go @@ -352,6 +352,8 @@ func getEnvoyConfig(port uint32, localAddress string) string { }) withHeader := envoyresource.MakeCluster("", "service_debug_withHeader") + withHeader.ClusterDiscoveryType = &v22.Cluster_Type{Type: v22.Cluster_STATIC} + withHeader.EdsClusterConfig = nil withHeader.LoadAssignment = &v22.ClusterLoadAssignment{ ClusterName: "service_debug_withoutHeader", Endpoints: []*endpoint.LocalityLbEndpoints{ @@ -372,6 +374,8 @@ func getEnvoyConfig(port uint32, localAddress string) string { Policy: nil, } withoutHeader := envoyresource.MakeCluster("", "service_debug_withoutHeader") + withoutHeader.ClusterDiscoveryType = &v22.Cluster_Type{Type: v22.Cluster_STATIC} + withoutHeader.EdsClusterConfig = nil withoutHeader.LoadAssignment = &v22.ClusterLoadAssignment{ ClusterName: "service_debug_withoutHeader", Endpoints: []*endpoint.LocalityLbEndpoints{ @@ -397,7 +401,7 @@ func getEnvoyConfig(port uint32, localAddress string) string { Clusters: []*v22.Cluster{withHeader, withoutHeader}, }, } - marshal, _ := json.Marshal(&resources) + marshal, _ := json.Marshal(resources) toYAML, _ := yaml.JSONToYAML(marshal) return string(toYAML) } diff --git a/remote/remote_test.go b/remote/remote_test.go index 48765fdd..4735b536 100644 --- a/remote/remote_test.go +++ b/remote/remote_test.go @@ -277,9 +277,10 @@ func server() { } func TestParseEnvoy(t *testing.T) { - port := uint32(0) - localAddress := "" - getEnvoyConfig(port, localAddress) + port := uint32(8080) + localAddress := "223.254.254.2" + config := getEnvoyConfig(port, localAddress) + fmt.Println(config) } func init() {