Skip to content

Commit

Permalink
Allow wildcard additional_hostnames, fixes #2391
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Jul 18, 2020
1 parent 4ffd59e commit e5e6822
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/ddevapp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ func (app *DdevApp) ValidateConfig() error {

// validate hostnames
for _, hn := range app.GetHostnames() {
// If they have provided "*.<hostname>" then ignore the *. part.
hn = strings.TrimPrefix(hn, "*.")
if !hostRegex.MatchString(hn) {
return fmt.Errorf("invalid hostname: %s. See https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_hostnames for valid hostname requirements", hn).(invalidHostname)
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/ddevapp/ddevapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,10 @@ func (app *DdevApp) AddHostsEntriesIfNeeded() error {

for _, name := range app.GetHostnames() {
if app.UseDNSWhenPossible && globalconfig.IsInternetActive() {
hostIPs, err := net.LookupHost(name)
// If they have provided "*.<name>" then look up the suffix
checkName := strings.TrimPrefix(name, "*.")
hostIPs, err := net.LookupHost(checkName)

// If we had successful lookup and dockerIP matches
// (which won't happen on Docker Toolbox) then don't bother
// with adding to hosts file.
Expand Down

0 comments on commit e5e6822

Please sign in to comment.