@@ -1147,7 +1147,14 @@ func (p *PeerConnManager) InboundPeerConnected(conn net.Conn) {
1147
1147
return
1148
1148
}
1149
1149
1150
- nodePub := conn .(* brontide.Conn ).RemotePub ()
1150
+ brontideConn , ok := conn .(* brontide.Conn )
1151
+ if ! ok {
1152
+ connLog .Errorf ("Unexpected conn type found in " +
1153
+ "InboundPeerConnected: %v" , conn )
1154
+ return
1155
+ }
1156
+
1157
+ nodePub := brontideConn .RemotePub ()
1151
1158
pubStr := string (nodePub .SerializeCompressed ())
1152
1159
1153
1160
p .mu .Lock ()
@@ -1236,7 +1243,14 @@ func (p *PeerConnManager) OutboundPeerConnected(connReq *connmgr.ConnReq,
1236
1243
return
1237
1244
}
1238
1245
1239
- nodePub := conn .(* brontide.Conn ).RemotePub ()
1246
+ brontideConn , ok := conn .(* brontide.Conn )
1247
+ if ! ok {
1248
+ connLog .Errorf ("Unexpected conn type found in " +
1249
+ "OutboundPeerConnected: %v" , conn )
1250
+ return
1251
+ }
1252
+
1253
+ nodePub := brontideConn .RemotePub ()
1240
1254
pubStr := string (nodePub .SerializeCompressed ())
1241
1255
1242
1256
p .mu .Lock ()
@@ -1397,7 +1411,13 @@ func (p *PeerConnManager) cancelConnReqs(pubStr string, skip *uint64) {
1397
1411
func (p * PeerConnManager ) peerConnected (conn net.Conn , connReq * connmgr.ConnReq ,
1398
1412
inbound bool ) {
1399
1413
1400
- brontideConn := conn .(* brontide.Conn )
1414
+ brontideConn , ok := conn .(* brontide.Conn )
1415
+ if ! ok {
1416
+ connLog .Errorf ("Unexpected conn type found in peerConnected: " +
1417
+ "%v" , conn )
1418
+ return
1419
+ }
1420
+
1401
1421
addr := conn .RemoteAddr ()
1402
1422
pubKey := brontideConn .RemotePub ()
1403
1423
@@ -1792,7 +1812,13 @@ func (p *PeerConnManager) connectToPersistentPeer(pubKeyStr string) {
1792
1812
// advertised addresses then remove that connection request.
1793
1813
var updatedConnReqs []* connmgr.ConnReq
1794
1814
for _ , connReq := range p .persistentConnReqs [pubKeyStr ] {
1795
- lnAddr := connReq .Addr .(* lnwire.NetAddress ).Address .String ()
1815
+ wireAddr , ok := connReq .Addr .(* lnwire.NetAddress )
1816
+ if ! ok {
1817
+ connLog .Errorf ("Unexpected network address type %v" ,
1818
+ connReq .Addr )
1819
+ }
1820
+
1821
+ lnAddr := wireAddr .Address .String ()
1796
1822
1797
1823
switch _ , ok := addrMap [lnAddr ]; ok {
1798
1824
// If the existing connection request is using one of the
@@ -2169,7 +2195,12 @@ func noiseDial(idKey keychain.SingleKeyECDH,
2169
2195
netCfg tor.Net , timeout time.Duration ) func (net.Addr ) (net.Conn , error ) {
2170
2196
2171
2197
return func (a net.Addr ) (net.Conn , error ) {
2172
- lnAddr := a .(* lnwire.NetAddress )
2198
+ lnAddr , ok := a .(* lnwire.NetAddress )
2199
+ if ! ok {
2200
+ return nil , fmt .Errorf ("Unexpected network address " +
2201
+ "type %v" , a )
2202
+ }
2203
+
2173
2204
return brontide .Dial (idKey , lnAddr , timeout , netCfg .Dial )
2174
2205
}
2175
2206
}
0 commit comments