Commit e0a135a6 authored by Kirill Smelkov's avatar Kirill Smelkov

X Adapt Dial / ListenAndServe to unified Network

parent 716493af
......@@ -117,7 +117,8 @@ func NewClient(storLink *NodeLink) (*Client, error) {
func openClientByURL(ctx context.Context, u *url.URL) (zodb.IStorage, error) {
// XXX for now url is treated as storage node URL
// XXX check/use other url fields
storLink, err := Dial(ctx, "tcp", u.Host)
net := NetPlain("tcp") // TODO + TLS; not only "tcp" ?
storLink, err := Dial(ctx, net, u.Host)
if err != nil {
return nil, err
}
......
......@@ -680,11 +680,9 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
// ---- for convenience: Dial ----
// Dial connects to address on named network, handshakes and wraps the connection as NodeLink
// TODO +tls.Config
func Dial(ctx context.Context, network, address string) (nl *NodeLink, err error) {
d := net.Dialer{}
peerConn, err := d.DialContext(ctx, network, address)
// Dial connects to address on given network, handshakes and wraps the connection as NodeLink
func Dial(ctx context.Context, net Network, addr string) (nl *NodeLink, err error) {
peerConn, err := net.Dial(ctx, addr)
if err != nil {
return nil, err
}
......
......@@ -998,8 +998,8 @@ func masterMain(argv []string) {
}()
*/
// TODO + TLS
err := ListenAndServe(ctx, "tcp", bind, masterSrv) // XXX "tcp" hardcoded
net := NetPlain("tcp") // TODO + TLS; not only "tcp" ?
err := ListenAndServe(ctx, net, bind, masterSrv)
if err != nil {
log.Fatal(err)
}
......
......@@ -76,9 +76,8 @@ func Serve(ctx context.Context, l net.Listener, srv Server) error {
}
// ListenAndServe listens on network address and then calls Serve to handle incoming connections
// XXX split -> separate Listen() & Serve()
func ListenAndServe(ctx context.Context, net_, laddr string, srv Server) error {
l, err := net.Listen(net_, laddr)
func ListenAndServe(ctx context.Context, net Network, laddr string, srv Server) error {
l, err := net.Listen(laddr)
if err != nil {
return err
}
......
......@@ -272,8 +272,8 @@ func storageMain(argv []string) {
}()
*/
// TODO + TLS
err = ListenAndServe(ctx, "tcp", bind, storSrv) // XXX "tcp" hardcoded
net := NetPlain("tcp") // TODO + TLS; not only "tcp" ?
err = ListenAndServe(ctx, net, bind, storSrv)
if err != nil {
log.Fatal(err)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment