(ctx context.Context, fn func(context.Context, string) (net.Conn, error), addr resolver.Address, grpcUA string)
| 159 | } |
| 160 | |
| 161 | func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error), addr resolver.Address, grpcUA string) (net.Conn, error) { |
| 162 | address := addr.Addr |
| 163 | networkType, ok := networktype.Get(addr) |
| 164 | if fn != nil { |
| 165 | // Special handling for unix scheme with custom dialer. Back in the day, |
| 166 | // we did not have a unix resolver and therefore targets with a unix |
| 167 | // scheme would end up using the passthrough resolver. So, user's used a |
| 168 | // custom dialer in this case and expected the original dial target to |
| 169 | // be passed to the custom dialer. Now, we have a unix resolver. But if |
| 170 | // a custom dialer is specified, we want to retain the old behavior in |
| 171 | // terms of the address being passed to the custom dialer. |
| 172 | if networkType == "unix" && !strings.HasPrefix(address, "\x00") { |
| 173 | // Supported unix targets are either "unix://absolute-path" or |
| 174 | // "unix:relative-path". |
| 175 | if filepath.IsAbs(address) { |
| 176 | return fn(ctx, "unix://"+address) |
| 177 | } |
| 178 | return fn(ctx, "unix:"+address) |
| 179 | } |
| 180 | return fn(ctx, address) |
| 181 | } |
| 182 | if !ok { |
| 183 | networkType, address = ParseDialTarget(address) |
| 184 | } |
| 185 | if opts, present := proxyattributes.Get(addr); present { |
| 186 | return proxyDial(ctx, addr, grpcUA, opts) |
| 187 | } |
| 188 | return internal.NetDialerWithTCPKeepalive().DialContext(ctx, networkType, address) |
| 189 | } |
| 190 | |
| 191 | func isTemporary(err error) bool { |
| 192 | switch err := err.(type) { |
no test coverage detected