Skip to content

Commit 2b687b4

Browse files
feat: support sni tuple in wss multiaddr (#39)
Supports WSS addresses with SNI. --------- Co-authored-by: Alex Potsides <[email protected]>
1 parent 90d2d6e commit 2b687b4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export const WebSockets = fmt(_WebSockets)
309309

310310
const _WebSocketsSecure = or(
311311
and(_WEB, literal('wss'), optional(peerId())),
312-
and(_WEB, literal('tls'), literal('ws'), optional(peerId()))
312+
and(_WEB, literal('tls'), optional(and(literal('sni'), string())), literal('ws'), optional(peerId()))
313313
)
314314

315315
/**

test/index.spec.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,19 @@ describe('multiaddr matcher', () => {
138138
'/dns4/ipfs.io/tls/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
139139
'/dns6/ipfs.io/tls/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
140140
'/ip4/1.2.3.4/tcp/3456/tls/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
141-
'/ip6/::/tcp/3456/tls/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79'
141+
'/ip6/::/tcp/3456/tls/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
142+
'/ip4/147.75.87.65/tcp/4002/tls/sni/147-75-87-65.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/ws',
143+
'/ip4/147.75.87.65/tcp/4002/tls/sni/147-75-87-65.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/ws/p2p/12D3KooWDpp7U7W9Q8feMZPPEpPP5FKXTUakLgnVLbavfjb9mzrT',
144+
'/dns4/147-75-80-75.k51qzi5uqu5dho0o9zm90239gjuacg6q1s69e0l1k5ow6kna869fsyb7ukjpeg.libp2p.direct/tcp/4002/tls/ws',
145+
'/dns4/147-75-80-75.k51qzi5uqu5dho0o9zm90239gjuacg6q1s69e0l1k5ow6kna869fsyb7ukjpeg.libp2p.direct/tcp/4002/tls/ws/p2p/12D3KooWDpp7U7W9Q8feMZPPEpPP5FKXTUakLgnVLbavfjb9mzrT',
146+
'/dns/147-75-87-65.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/tcp/4002/tls/ws',
147+
'/dns/147-75-87-65.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/tcp/4002/tls/ws/p2p/12D3KooWDpp7U7W9Q8feMZPPEpPP5FKXTUakLgnVLbavfjb9mzrT',
148+
'/ip6/2604:1380:4601:f600::1/tcp/4002/tls/sni/2604-1380-4601-f600--1.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/ws',
149+
'/ip6/2604:1380:4601:f600::1/tcp/4002/tls/sni/2604-1380-4601-f600--1.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/ws/p2p/12D3KooWDpp7U7W9Q8feMZPPEpPP5FKXTUakLgnVLbavfjb9mzrT',
150+
'/dns6/2604-1380-4601-f600--1.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/tcp/4002/tls/ws',
151+
'/dns6/2604-1380-4601-f600--1.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/tcp/4002/tls/ws/p2p/12D3KooWDpp7U7W9Q8feMZPPEpPP5FKXTUakLgnVLbavfjb9mzrT',
152+
'/dns/2604-1380-4601-f600--1.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/tcp/4002/tls/ws',
153+
'/dns/2604-1380-4601-f600--1.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/tcp/4002/tls/ws/p2p/12D3KooWDpp7U7W9Q8feMZPPEpPP5FKXTUakLgnVLbavfjb9mzrT'
142154
]
143155

144156
const goodWSS = [

0 commit comments

Comments
 (0)