11import { noise } from "@chainsafe/libp2p-noise" ;
2- import { tls } from "@libp2p/tls" ;
32import { yamux } from "@chainsafe/libp2p-yamux" ;
43import { createDelegatedRoutingV1HttpApiClient } from "@helia/delegated-routing-v1-http-api-client" ;
54import { delegatedHTTPRoutingDefaults } from "@helia/routers" ;
6- import { autoNAT } from "@libp2p/autonat" ;
75import { bootstrap } from "@libp2p/bootstrap" ;
8- import { circuitRelayTransport } from "@libp2p/circuit-relay-v2" ;
9- import { dcutr } from "@libp2p/dcutr" ;
106import { identify , identifyPush } from "@libp2p/identify" ;
117import { kadDHT , removePrivateAddressesMapper } from "@libp2p/kad-dht" ;
128import { ping } from "@libp2p/ping" ;
139import { tcp } from "@libp2p/tcp" ;
14- import { uPnPNAT } from "@libp2p/upnp-nat" ;
15- import { webRTC , webRTCDirect } from "@libp2p/webrtc" ;
10+ import { webRTCDirect } from "@libp2p/webrtc" ;
1611import { webSockets } from "@libp2p/websockets" ;
17- import { ipnsSelector } from "ipns/selector" ;
18- import { ipnsValidator } from "ipns/validator" ;
19- import * as filters from "@libp2p/websockets/filters" ;
20- import { pubsubPeerDiscovery } from "@libp2p/pubsub-peer-discovery" ;
2112import { gossipsub } from "@chainsafe/libp2p-gossipsub" ;
22- import { webTransport } from "@libp2p/webtransport" ;
2313import { keychain } from "@libp2p/keychain" ;
24- import { autoTLS } from "@ipshipyard/libp2p-auto-tls" ;
2514
2615export function CreateLibp2pOptions (
2716 publicIP : string ,
2817 TcpPort : number ,
29- WSPort : number ,
30- WSSPort : number ,
3118 WebRTCDirectPort : number
3219) {
3320 let appendAnnounce : string [ ] = [ ] ;
3421 // If a public ip was provided, use append announce
3522 if ( publicIP != "0.0.0.0" ) {
3623 appendAnnounce = [
3724 `/ip4/${ publicIP } /tcp/${ TcpPort } ` ,
38- `/ip4/${ publicIP } /tcp/${ WSPort } /ws` ,
39- `/ip4/${ publicIP } /tcp/${ WSSPort } /tls/ws` ,
4025 `/ip4/${ publicIP } /udp/${ WebRTCDirectPort } /webrtc-direct` ,
4126 ] ;
4227 }
@@ -46,41 +31,16 @@ export function CreateLibp2pOptions(
4631 addresses : {
4732 listen : [
4833 `/ip4/0.0.0.0/tcp/${ TcpPort } ` ,
49- `/ip4/0.0.0.0/tcp/${ WSPort } /ws` ,
50- `/ip4/0.0.0.0/tcp/${ WSSPort } /ws` ,
5134 `/ip4/0.0.0.0/udp/${ WebRTCDirectPort } /webrtc-direct` ,
52- // "/p2p-circuit",
53- // "/webrtc",
5435 ] ,
5536 // Two websocket adresses are added for auto-tls to work.
5637 // Per: https://github.com/libp2p/js-libp2p/issues/2929
5738 // TODO: Append announce is only needed if upnp does not work. And ports are manually opened.
5839 appendAnnounce : appendAnnounce ,
5940 } ,
60- transports : [
61- tcp ( ) ,
62- // circuitRelayTransport(),
63- // webRTC(),
64- webRTCDirect ( ) ,
65- // webTransport(),
66- webSockets ( ) ,
67- ] ,
68- connectionEncrypters : [
69- noise ( ) ,
70- // tls()
71- ] ,
41+ transports : [ tcp ( ) , webRTCDirect ( ) , webSockets ( ) ] ,
42+ connectionEncrypters : [ noise ( ) ] ,
7243 streamMuxers : [ yamux ( ) ] ,
73- connectionGater : {
74- denyDialMultiaddr : ( ) => false ,
75- } ,
76- connectionManager : {
77- // With the latest version of libp2p the timeouts for stream upgrades seems to be too aggresive
78- // https://github.com/libp2p/js-libp2p/issues/2897#issuecomment-2674706509
79- inboundStreamProtocolNegotiationTimeout : 1e4 ,
80- inboundUpgradeTimeout : 1e4 ,
81- outboundStreamProtocolNegotiationTimeout : 1e4 ,
82- outboundUpgradeTimeout : 1e4 ,
83- } ,
8444 peerDiscovery : [
8545 bootstrap ( {
8646 list : [
@@ -100,8 +60,6 @@ export function CreateLibp2pOptions(
10060 pubsub : gossipsub ( {
10161 allowPublishToZeroTopicPeers : true ,
10262 } ) ,
103- autoNAT : autoNAT ( ) ,
104- dcutr : dcutr ( ) ,
10563 delegatedRouting : ( ) =>
10664 createDelegatedRoutingV1HttpApiClient (
10765 "https://delegated-ipfs.dev" ,
@@ -114,19 +72,11 @@ export function CreateLibp2pOptions(
11472 // Server mode makes the node unable to receive connections, I think it is becuase it is always full.
11573 // We do not need server mode anyway.
11674 clientMode : true ,
117- validators : {
118- ipns : ipnsValidator ,
119- } ,
120- selectors : {
121- ipns : ipnsSelector ,
122- } ,
12375 } ) ,
12476 identify : identify ( ) ,
12577 identifyPush : identifyPush ( ) ,
12678 ping : ping ( ) ,
127- upnp : uPnPNAT ( ) ,
12879 keychain : keychain ( ) ,
129- autoTLS : autoTLS ( ) ,
13080 } ,
13181 } ;
13282}
0 commit comments