• Kirill Smelkov's avatar
    xnet: New package that provides uniform access for working with both TCP and TLS/TCP · 7f62584e
    Kirill Smelkov authored
    Std net.Conn already can represent both plain TCP connections and
    connections wrapped with TLS. However the connections itself need to be
    created differently. This might become inconvenient when establishing
    connections should be inside server logic where it is desirable to have
    one codepath which works uniformly via interfaces.
    
    This patch introduces Networker - new interface which represents
    access-point to a streaming network. One can Dial or Listen on it and
    get underlying network name.
    
    Two functions are also provided to create networkers for plain TCP
    and to wrap a networker with TLS layer.
    
    This way one can initially decide and setup a networker, pass it to
    server logic, and server inside uses just Networker interface
    transparently either listening/connecting via regular sockets, or via
    sockets wrapped with TLS layer.
    7f62584e
net.go 2.95 KB