Skip to content

Commit

Permalink
ingest: host detection fix
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Dec 13, 2023
1 parent 3e3e569 commit 5d67e13
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ingest/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ func (r *Router) getDataLocator(c *gin.Context, event *AnalyticsServerEvent, ing
} else if c.GetHeader("X-Write-Key") != "" {
cred.WriteKey = c.GetHeader("X-Write-Key")
}
host := c.Request.URL.Hostname()
host := strings.Split(c.Request.Host, ":")[0]
r.Infof("Host: %s Datahost: %s", host, dataHost)
if dataHost != "" && strings.HasSuffix(host, "."+dataHost) {
cred.Slug = strings.TrimSuffix(host, "."+dataHost)
} else {
Expand Down Expand Up @@ -621,7 +622,9 @@ type StreamLocator func(loc *StreamCredentials) *StreamWithDestinations

func (r *Router) getStream(loc *StreamCredentials) *StreamWithDestinations {
var locators []StreamLocator
if loc.IngestType == IngestTypeS2S || loc.IngestType == IngestTypeWriteKeyDefined {
if loc.IngestType == IngestTypeWriteKeyDefined {
locators = []StreamLocator{r.WriteKeyStreamLocator}
} else if loc.IngestType == IngestTypeS2S {
locators = []StreamLocator{r.WriteKeyStreamLocator, r.SlugStreamLocator, r.AmbiguousDomainStreamLocator}
} else {
locators = []StreamLocator{r.SlugStreamLocator, r.DomainStreamLocator, r.WriteKeyStreamLocator}
Expand Down

0 comments on commit 5d67e13

Please sign in to comment.