@@ -21,6 +21,7 @@ type upstream struct {
2121 LocalBindPort int
2222 Service string
2323 Datacenter string
24+ Protocol string
2425 Nodes []* api.ServiceEntry
2526
2627 done bool
@@ -29,6 +30,7 @@ type upstream struct {
2930type downstream struct {
3031 LocalBindAddress string
3132 LocalBindPort int
33+ Protocol string
3234 TargetAddress string
3335 TargetPort int
3436}
@@ -111,6 +113,13 @@ func (w *Watcher) handleProxyChange(first bool, srv *api.AgentService) {
111113 w .downstream .LocalBindAddress = defaultDownstreamBindAddr
112114 w .downstream .LocalBindPort = srv .Port
113115 w .downstream .TargetAddress = defaultUpstreamBindAddr
116+
117+ if srv .Proxy != nil && srv .Proxy .Config != nil {
118+ if c , ok := srv .Proxy .Config ["protocol" ].(string ); ok {
119+ w .downstream .Protocol = c
120+ }
121+ }
122+
114123 if srv .Connect != nil && srv .Connect .SidecarService != nil && srv .Connect .SidecarService .Proxy != nil && srv .Connect .SidecarService .Proxy .Config != nil {
115124 if b , ok := srv .Connect .SidecarService .Proxy .Config ["bind_address" ].(string ); ok {
116125 w .downstream .LocalBindAddress = b
@@ -155,6 +164,12 @@ func (w *Watcher) startUpstream(up api.Upstream) {
155164 Datacenter : up .Datacenter ,
156165 }
157166
167+ if up .Config ["protocol" ] != nil {
168+ if p , ok := up .Config ["protocol" ].(string ); ok {
169+ u .Protocol = p
170+ }
171+ }
172+
158173 w .lock .Lock ()
159174 w .upstreams [up .DestinationName ] = u
160175 w .lock .Unlock ()
@@ -332,7 +347,7 @@ func (w *Watcher) genCfg() Config {
332347 LocalBindPort : w .downstream .LocalBindPort ,
333348 TargetAddress : w .downstream .TargetAddress ,
334349 TargetPort : w .downstream .TargetPort ,
335-
350+ Protocol : w . downstream . Protocol ,
336351 TLS : TLS {
337352 CAs : w .certCAs ,
338353 Cert : w .leaf .Cert ,
@@ -346,14 +361,13 @@ func (w *Watcher) genCfg() Config {
346361 Service : up .Service ,
347362 LocalBindAddress : up .LocalBindAddress ,
348363 LocalBindPort : up .LocalBindPort ,
349-
364+ Protocol : up . Protocol ,
350365 TLS : TLS {
351366 CAs : w .certCAs ,
352367 Cert : w .leaf .Cert ,
353368 Key : w .leaf .Key ,
354369 },
355370 }
356-
357371 for _ , s := range up .Nodes {
358372 serviceInstancesTotal ++
359373 host := s .Service .Address
0 commit comments