@@ -8,7 +8,7 @@ import { createClient } from '@libp2p/daemon-client'
8
8
import { createServer } from '@libp2p/daemon-server'
9
9
import { floodsub } from '@libp2p/floodsub'
10
10
import { identify } from '@libp2p/identify'
11
- import { interopTests } from '@libp2p/interop'
11
+ import { UnsupportedError , interopTests } from '@libp2p/interop'
12
12
import { kadDHT , passthroughMapper } from '@libp2p/kad-dht'
13
13
import { logger } from '@libp2p/logger'
14
14
import { mplex } from '@libp2p/mplex'
@@ -46,7 +46,15 @@ async function createGoPeer (options: SpawnOptions): Promise<Daemon> {
46
46
if ( options . noListen === true ) {
47
47
opts . push ( '-noListenAddrs' )
48
48
} else {
49
- opts . push ( '-hostAddrs=/ip4/127.0.0.1/tcp/0' )
49
+ if ( options . transport == null || options . transport === 'tcp' ) {
50
+ opts . push ( '-hostAddrs=/ip4/127.0.0.1/tcp/0' )
51
+ } else if ( options . transport === 'webtransport' ) {
52
+ opts . push ( '-hostAddrs=/ip4/127.0.0.1/udp/0/quic-v1/webtransport' )
53
+ } else if ( options . transport === 'webrtc-direct' ) {
54
+ opts . push ( '-hostAddrs=/ip4/127.0.0.1/udp/0/webrtc-direct' )
55
+ } else {
56
+ throw new UnsupportedError ( )
57
+ }
50
58
}
51
59
52
60
if ( options . encryption != null ) {
@@ -122,7 +130,7 @@ async function createJsPeer (options: SpawnOptions): Promise<Daemon> {
122
130
const opts : Libp2pOptions < ServiceMap > = {
123
131
peerId,
124
132
addresses : {
125
- listen : options . noListen === true ? [ ] : [ '/ip4/127.0.0.1/tcp/0' ]
133
+ listen : [ ]
126
134
} ,
127
135
transports : [ tcp ( ) , circuitRelayTransport ( ) ] ,
128
136
streamMuxers : [ ] ,
@@ -132,6 +140,18 @@ async function createJsPeer (options: SpawnOptions): Promise<Daemon> {
132
140
}
133
141
}
134
142
143
+ if ( options . noListen !== true ) {
144
+ if ( options . transport == null || options . transport === 'tcp' ) {
145
+ opts . addresses ?. listen ?. push ( '/ip4/127.0.0.1/tcp/0' )
146
+ } else {
147
+ throw new UnsupportedError ( )
148
+ }
149
+ }
150
+
151
+ if ( options . transport === 'webtransport' || options . transport === 'webrtc-direct' ) {
152
+ throw new UnsupportedError ( )
153
+ }
154
+
135
155
const services : ServiceFactoryMap = {
136
156
identify : identify ( )
137
157
}
0 commit comments