Allow the socket to be specified

This commit is contained in:
Asim Aslam
2019-07-10 19:07:18 +01:00
parent 7e0d4fe0cf
commit 1f218f7b48
2 changed files with 21 additions and 3 deletions

View File

@@ -43,6 +43,7 @@ type link struct {
func newLink(options options.Options) *link {
// default values
var sock transport.Socket
id := "local"
addr := "127.0.0.1:10001"
tr := transport.DefaultTransport
@@ -62,11 +63,19 @@ func newLink(options options.Options) *link {
tr = ltr.(transport.Transport)
}
lsock, ok := options.Values().Get("link.socket")
if ok {
sock = lsock.(transport.Socket)
}
l := &link{
// the remote end to dial
addr: addr,
// transport to dial link
transport: tr,
// the socket to use
// this is nil if not specified
socket: sock,
// unique id assigned to the link
id: id,
// the closed channel used to close the conn