mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Parse.ipFromSDP function.
This commit is contained in:
parent
ae0643320e
commit
0c7ddeb1d0
2 changed files with 122 additions and 0 deletions
|
@ -112,6 +112,17 @@ Parse =
|
|||
return null if null == units
|
||||
count * Number(units)
|
||||
|
||||
# Parse a connection-address out of the "c=" Connection Data field of a session
|
||||
# description. Return undefined if none is found.
|
||||
# https://tools.ietf.org/html/rfc4566#section-5.7
|
||||
ipFromSDP: (sdp) ->
|
||||
for pattern in [
|
||||
/^c=IN IP4 ([\d.]+)(?:(?:\/\d+)?\/\d+)?(:? |$)/m,
|
||||
/^c=IN IP6 ([0-9A-Fa-f:.]+)(?:\/\d+)?(:? |$)/m,
|
||||
]
|
||||
m = pattern.exec(sdp)
|
||||
return m[1] if m?
|
||||
|
||||
|
||||
Params =
|
||||
getBool: (query, param, defaultValue) ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue