Skip to content

Commit 2ee1d32

Browse files
committed
f
1 parent 0a09330 commit 2ee1d32

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

api/adc/types.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,18 +482,21 @@ func ComposeRouteName(namespace, name string, rule string) string {
482482

483483
// ComposeStreamRouteName uses namespace, name and rule name to compose
484484
// the stream_route name.
485-
func ComposeStreamRouteName(namespace, name string, rule string) string {
485+
func ComposeStreamRouteName(namespace, name string, rule string, typ string) string {
486+
if typ == "" {
487+
typ = "TCP"
488+
}
486489
// FIXME Use sync.Pool to reuse this buffer if the upstream
487490
// name composing code path is hot.
488-
p := make([]byte, 0, len(namespace)+len(name)+len(rule)+6)
491+
p := make([]byte, 0, len(namespace)+len(name)+len(rule)+len(typ)+6)
489492
buf := bytes.NewBuffer(p)
490493

491494
buf.WriteString(namespace)
492495
buf.WriteByte('_')
493496
buf.WriteString(name)
494497
buf.WriteByte('_')
495498
buf.WriteString(rule)
496-
buf.WriteString("_tcp")
499+
buf.WriteString(typ)
497500

498501
return buf.String()
499502
}

internal/adc/translator/apisixroute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ func (t *Translator) translateStreamRule(tctx *provider.TranslateContext, ar *ap
422422
t.loadRoutePlugins(tctx, ar, part.Plugins, plugins)
423423

424424
sr := adc.NewDefaultStreamRoute()
425-
sr.Name = adc.ComposeStreamRouteName(ar.Namespace, ar.Name, part.Name)
425+
sr.Name = adc.ComposeStreamRouteName(ar.Namespace, ar.Name, part.Name, part.Protocol)
426426
sr.ID = id.GenID(sr.Name)
427427
sr.ServerPort = part.Match.IngressPort
428428
sr.SNI = part.Match.Host

internal/adc/translator/tcproute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (t *Translator) TranslateTCPRoute(tctx *provider.TranslateContext, tcpRoute
151151
}
152152
}
153153
streamRoute := adctypes.NewDefaultStreamRoute()
154-
streamRouteName := adctypes.ComposeStreamRouteName(tcpRoute.Namespace, tcpRoute.Name, fmt.Sprintf("%d", ruleIndex))
154+
streamRouteName := adctypes.ComposeStreamRouteName(tcpRoute.Namespace, tcpRoute.Name, fmt.Sprintf("%d", ruleIndex), "TCP")
155155
streamRoute.Name = streamRouteName
156156
streamRoute.ID = id.GenID(streamRouteName)
157157
streamRoute.Labels = labels

internal/adc/translator/udproute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (t *Translator) TranslateUDPRoute(tctx *provider.TranslateContext, udpRoute
140140
}
141141
}
142142
streamRoute := adctypes.NewDefaultStreamRoute()
143-
streamRouteName := adctypes.ComposeStreamRouteName(udpRoute.Namespace, udpRoute.Name, fmt.Sprintf("%d", ruleIndex))
143+
streamRouteName := adctypes.ComposeStreamRouteName(udpRoute.Namespace, udpRoute.Name, fmt.Sprintf("%d", ruleIndex), "UDP")
144144
streamRoute.Name = streamRouteName
145145
streamRoute.ID = id.GenID(streamRouteName)
146146
streamRoute.Labels = labels

0 commit comments

Comments
 (0)