mirror of https://github.com/BTCPrivate/lnd.git
add tcp dial bypass for pbx
This commit is contained in:
parent
10835c6498
commit
26d9ae7f2b
15
lndc/conn.go
15
lndc/conn.go
|
@ -55,10 +55,19 @@ func NewConn(conn net.Conn) *LNDConn {
|
||||||
func (c *LNDConn) Dial(
|
func (c *LNDConn) Dial(
|
||||||
myId *btcec.PrivateKey, address string, remoteId []byte) error {
|
myId *btcec.PrivateKey, address string, remoteId []byte) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
if !c.ViaPbx {
|
||||||
if c.Conn != nil {
|
if c.Conn != nil {
|
||||||
return fmt.Errorf("connection already established")
|
return fmt.Errorf("connection already established")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First, open the TCP connection itself.
|
||||||
|
c.Conn, err = net.Dial("tcp", address)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Before dialing out to the remote host, verify that `remoteId` is either
|
// Before dialing out to the remote host, verify that `remoteId` is either
|
||||||
// a pubkey or a pubkey hash.
|
// a pubkey or a pubkey hash.
|
||||||
if len(remoteId) != 33 && len(remoteId) != 20 {
|
if len(remoteId) != 33 && len(remoteId) != 20 {
|
||||||
|
@ -66,12 +75,6 @@ func (c *LNDConn) Dial(
|
||||||
"pubkey hash")
|
"pubkey hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, open the TCP connection itself.
|
|
||||||
c.Conn, err = net.Dial("tcp", address)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calc remote LNId; need this for creating pbx connections just because
|
// Calc remote LNId; need this for creating pbx connections just because
|
||||||
// LNid is in the struct does not mean it's authed!
|
// LNid is in the struct does not mean it's authed!
|
||||||
if len(remoteId) == 20 {
|
if len(remoteId) == 20 {
|
||||||
|
|
Loading…
Reference in New Issue