Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embed: connect json gateway with user-provided listen address #8221

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ func startClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err error) {
if sctx.l, err = net.Listen(proto, addr); err != nil {
return nil, err
}
// net.Listener will rewrite ipv4 0.0.0.0 to ipv6 [::], breaking
// hosts that disable ipv6. So, use the address given by the user.
sctx.addr = addr

if fdLimit, fderr := runtimeutil.FDLimit(); fderr == nil {
if fdLimit <= reservedInternalFDNum {
Expand Down
3 changes: 2 additions & 1 deletion embed/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (

type serveCtx struct {
l net.Listener
addr string
secure bool
insecure bool

Expand Down Expand Up @@ -171,7 +172,7 @@ type registerHandlerFunc func(context.Context, *gw.ServeMux, *grpc.ClientConn) e

func (sctx *serveCtx) registerGateway(opts []grpc.DialOption) (*gw.ServeMux, error) {
ctx := sctx.ctx
conn, err := grpc.DialContext(ctx, sctx.l.Addr().String(), opts...)
conn, err := grpc.DialContext(ctx, sctx.addr, opts...)
if err != nil {
return nil, err
}
Expand Down