I have created an http.Client with a custom TLS dialer. The custom TLS dialer creates a *tls.Conn and while doing this, it logs out a lot of information such as which server is used.
Now, when I make an HTTP request, I want to log out which dial produced the *tls.Conn the HTTP request ended up using. Using httptrace.ClientTrace.GotConn it is possible to get the net.Conn that was used by the request. But how do I relate that with which dial was used to create it? I see four options but they all have drawbacks: 1) I can keep a map from net.Conn to information that identifies the dial. But when can I delete entries from this map? Go does not have weak pointers. 2) I can make a my own struct and return from my custom dialer: type myConn struct { net.Conn dialInfo string } However, that does not work well for TLS. The reason is that the Go HTTP client has special logic in case a custom dialer returns a *tls.Conn. That logic will be disabled. 3) I can log out the address of the net.Conn object both from my custom dialer and from GotConn. I can do that by using something like reflect.ValueOf(conn).Pointer(). However in practice it seems like different net.Conn objects can easily get the same address. 4) I can log out the local and remote IP addresses and port of the net.Conn both from the dialer and from GotConn. It is a lot of information and different connections may use the same IP and ports. But maybe the best I can do? Any other ideas? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f23ba2d3-37d2-4c2e-9f5d-59c2d8797339n%40googlegroups.com.