refraction-networking / conjure

Conjure Refraction Networking station code
https://refraction.network
Apache License 2.0
70 stars 19 forks source link

Use switch with default for RemoteAddr parsing #200

Closed jmwample closed 1 year ago

jmwample commented 1 year ago

make mocking conns slightly easier for handleNewTCPConn()

If using a non-IP based net.Conn you will need to wrap and mock / override RemoteAddr() to make sure it does return a net.IP.

    remoteIP := getRemoteAsIP(clientConn)
    if remoteIP == nil {
        // Socket returned non-IP Remote Address - we can't really use that. If testing w/ pipe try
        // wrapping with struct to provide mock RemoteAddr which return a real IP address.
                return
        }