(network, addr string)
| 225 | } |
| 226 | |
| 227 | func Dial(network, addr string) (net.Conn, error) { |
| 228 | // Temporary laziness hack, avoiding doing a |
| 229 | // cross-compiled Android cgo build. |
| 230 | // Without cgo, package net uses |
| 231 | // /etc/resolv.conf (not available on |
| 232 | // Android). We really want a cgo binary to |
| 233 | // use Android's DNS cache, but it's kinda |
| 234 | // hard/impossible to cross-compile for now. |
| 235 | statTCPStart.Incr(1) |
| 236 | host, port, err := net.SplitHostPort(addr) |
| 237 | if err != nil { |
| 238 | statTCPFail.Incr(1) |
| 239 | return nil, fmt.Errorf("couldn't split %q", addr) |
| 240 | } |
| 241 | if OnAndroid() { |
| 242 | // Only do the Android DNS lookups when actually |
| 243 | // running on a device. We also run in "Android mode" |
| 244 | // (IsChild) in tests and interactive debugging. |
| 245 | host = androidLookupHost(host) |
| 246 | } |
| 247 | c, err := net.Dial(network, net.JoinHostPort(host, port)) |
| 248 | if err != nil { |
| 249 | statTCPFail.Incr(1) |
| 250 | return nil, err |
| 251 | } |
| 252 | statTCPStarted.Incr(1) |
| 253 | return &statTrackingConn{Conn: c}, err |
| 254 | } |
| 255 | |
| 256 | func TLSConfig() (*tls.Config, error) { |
| 257 | if !OnAndroid() { |
no test coverage detected