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) { ...@@ -117,7 +117,8 @@ func NewClient(storLink *NodeLink) (*Client, error) {
func openClientByURL(ctx context.Context, u *url.URL) (zodb.IStorage, error) { func openClientByURL(ctx context.Context, u *url.URL) (zodb.IStorage, error) {
// XXX for now url is treated as storage node URL // XXX for now url is treated as storage node URL
// XXX check/use other url fields // 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 { if err != nil {
return nil, err return nil, err
} }
......
...@@ -680,11 +680,9 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) { ...@@ -680,11 +680,9 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
// ---- for convenience: Dial ---- // ---- for convenience: Dial ----
// Dial connects to address on named network, handshakes and wraps the connection as NodeLink // Dial connects to address on given network, handshakes and wraps the connection as NodeLink
// TODO +tls.Config func Dial(ctx context.Context, net Network, addr string) (nl *NodeLink, err error) {
func Dial(ctx context.Context, network, address string) (nl *NodeLink, err error) { peerConn, err := net.Dial(ctx, addr)
d := net.Dialer{}
peerConn, err := d.DialContext(ctx, network, address)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -998,8 +998,8 @@ func masterMain(argv []string) { ...@@ -998,8 +998,8 @@ func masterMain(argv []string) {
}() }()
*/ */
// TODO + TLS net := NetPlain("tcp") // TODO + TLS; not only "tcp" ?
err := ListenAndServe(ctx, "tcp", bind, masterSrv) // XXX "tcp" hardcoded err := ListenAndServe(ctx, net, bind, masterSrv)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
......
...@@ -76,9 +76,8 @@ func Serve(ctx context.Context, l net.Listener, srv Server) error { ...@@ -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 // ListenAndServe listens on network address and then calls Serve to handle incoming connections
// XXX split -> separate Listen() & Serve() func ListenAndServe(ctx context.Context, net Network, laddr string, srv Server) error {
func ListenAndServe(ctx context.Context, net_, laddr string, srv Server) error { l, err := net.Listen(laddr)
l, err := net.Listen(net_, laddr)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -272,8 +272,8 @@ func storageMain(argv []string) { ...@@ -272,8 +272,8 @@ func storageMain(argv []string) {
}() }()
*/ */
// TODO + TLS net := NetPlain("tcp") // TODO + TLS; not only "tcp" ?
err = ListenAndServe(ctx, "tcp", bind, storSrv) // XXX "tcp" hardcoded err = ListenAndServe(ctx, net, bind, storSrv)
if err != nil { if err != nil {
log.Fatal(err) 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