( config *cfg.Config, nodeInfo p2p.NodeInfo, nodeKey *p2p.NodeKey, proxyApp proxy.AppConns, )
| 496 | } |
| 497 | |
| 498 | func createTransport( |
| 499 | config *cfg.Config, |
| 500 | nodeInfo p2p.NodeInfo, |
| 501 | nodeKey *p2p.NodeKey, |
| 502 | proxyApp proxy.AppConns, |
| 503 | ) ( |
| 504 | *p2p.MultiplexTransport, |
| 505 | []p2p.PeerFilterFunc, |
| 506 | ) { |
| 507 | var ( |
| 508 | mConnConfig = p2p.MConnConfig(config.P2P) |
| 509 | transport = p2p.NewMultiplexTransport(nodeInfo, *nodeKey, mConnConfig) |
| 510 | connFilters = []p2p.ConnFilterFunc{} |
| 511 | peerFilters = []p2p.PeerFilterFunc{} |
| 512 | ) |
| 513 | |
| 514 | if !config.P2P.AllowDuplicateIP { |
| 515 | connFilters = append(connFilters, p2p.ConnDuplicateIPFilter()) |
| 516 | } |
| 517 | |
| 518 | // Filter peers by addr or pubkey with an ABCI query. |
| 519 | // If the query return code is OK, add peer. |
| 520 | if config.FilterPeers { |
| 521 | connFilters = append( |
| 522 | connFilters, |
| 523 | // ABCI query for address filtering. |
| 524 | func(_ p2p.ConnSet, c net.Conn, _ []net.IP) error { |
| 525 | res, err := proxyApp.Query().QuerySync(abci.RequestQuery{ |
| 526 | Path: fmt.Sprintf("/p2p/filter/addr/%s", c.RemoteAddr().String()), |
| 527 | }) |
| 528 | if err != nil { |
| 529 | return err |
| 530 | } |
| 531 | if res.IsErr() { |
| 532 | return fmt.Errorf("error querying abci app: %v", res) |
| 533 | } |
| 534 | |
| 535 | return nil |
| 536 | }, |
| 537 | ) |
| 538 | |
| 539 | peerFilters = append( |
| 540 | peerFilters, |
| 541 | // ABCI query for ID filtering. |
| 542 | func(_ p2p.IPeerSet, p p2p.Peer) error { |
| 543 | res, err := proxyApp.Query().QuerySync(abci.RequestQuery{ |
| 544 | Path: fmt.Sprintf("/p2p/filter/id/%s", p.ID()), |
| 545 | }) |
| 546 | if err != nil { |
| 547 | return err |
| 548 | } |
| 549 | if res.IsErr() { |
| 550 | return fmt.Errorf("error querying abci app: %v", res) |
| 551 | } |
| 552 | |
| 553 | return nil |
| 554 | }, |
| 555 | ) |
no test coverage detected