mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-28 04:10:44 -04:00
prevent binding 0.0.0.0 -> ::0 (#2094)
This commit is contained in:
parent
be2d33e4b6
commit
61411f2f4f
1 changed files with 9 additions and 1 deletions
|
|
@ -3,18 +3,26 @@ package server
|
|||
import (
|
||||
"io"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/vault"
|
||||
)
|
||||
|
||||
func tcpListenerFactory(config map[string]string, _ io.Writer) (net.Listener, map[string]string, vault.ReloadFunc, error) {
|
||||
bind_proto := "tcp"
|
||||
addr, ok := config["address"]
|
||||
if !ok {
|
||||
addr = "127.0.0.1:8200"
|
||||
}
|
||||
|
||||
ln, err := net.Listen("tcp", addr)
|
||||
// If they've passed 0.0.0.0, we only want to bind on IPv4
|
||||
// rather than golang's dual stack default
|
||||
if strings.HasPrefix(addr, "0.0.0.0:") {
|
||||
bind_proto = "tcp4"
|
||||
}
|
||||
|
||||
ln, err := net.Listen(bind_proto, addr)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue