Skip to content

Commit

Permalink
fix: match websocket addresses that include a peer id (#156)
Browse files Browse the repository at this point in the history
Update `WebSockets` and `WebSocketsSecure` to also match websocket
addresses that end in `/p2p/Qmfoo`.
  • Loading branch information
achingbrain committed Jun 1, 2023
1 parent 7cb7281 commit 080936f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,28 @@ export const UTP = and(UDP, base('utp'))
export const QUIC = and(UDP, base('quic'))
export const QUICV1 = and(UDP, base('quic-v1'))

export const WebSockets = or(
const _WebSockets = or(
and(TCP, base('ws')),
and(DNS, base('ws'))
)

export const WebSocketsSecure = or(
export const WebSockets = or(
_WebSockets,
and(_WebSockets, base('p2p'))
)

const _WebSocketsSecure = or(
and(TCP, base('wss')),
and(DNS, base('wss')),
and(TCP, base('tls'), base('ws')),
and(DNS, base('tls'), base('ws'))
)

export const WebSocketsSecure = or(
_WebSocketsSecure,
and(_WebSocketsSecure, base('p2p'))
)

export const HTTP = or(
and(TCP, base('http')),
and(IP, base('http')),
Expand Down Expand Up @@ -99,8 +109,8 @@ export const P2PWebRTCDirect = or(
)

export const Reliable = or(
WebSockets,
WebSocketsSecure,
_WebSockets,
_WebSocketsSecure,
HTTP,
HTTPS,
P2PWebRTCStar,
Expand Down

0 comments on commit 080936f

Please sign in to comment.