From a5bc4d464ad74fd6abbbe88da940421ecb603618 Mon Sep 17 00:00:00 2001 From: chzyer <0@0xdf.com> Date: Thu, 31 Mar 2016 14:20:14 +0800 Subject: [PATCH] [remote] add a onListen func --- remote.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/remote.go b/remote.go index 2d1847c..7c5ede9 100644 --- a/remote.go +++ b/remote.go @@ -394,11 +394,16 @@ func (r *RemoteCli) Serve() error { return nil } -func ListenRemote(n, addr string, cfg *Config, h func(*Instance)) error { +func ListenRemote(n, addr string, cfg *Config, h func(*Instance), onListen ...func(net.Listener) error) error { ln, err := net.Listen(n, addr) if err != nil { return err } + if len(onListen) > 0 { + if err := onListen[0](ln); err != nil { + return err + } + } for { conn, err := ln.Accept() if err != nil {