snapshot of https://github.com/pion/webrtc.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
Fuzz / fuzz (push) Failing after 0s
CodeQL / analyze (push) Failing after 0s
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
Fuzz / fuzz (push) Failing after 0s
CodeQL / analyze (push) Failing after 0s
This commit is contained in:
65
dtlstransport_js.go
Normal file
65
dtlstransport_js.go
Normal file
@@ -0,0 +1,65 @@
|
||||
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package webrtc
|
||||
|
||||
import "syscall/js"
|
||||
|
||||
// DTLSTransport allows an application access to information about the DTLS
|
||||
// transport over which RTP and RTCP packets are sent and received by
|
||||
// RTPSender and RTPReceiver, as well other data such as SCTP packets sent
|
||||
// and received by data channels.
|
||||
type DTLSTransport struct {
|
||||
// Pointer to the underlying JavaScript DTLSTransport object.
|
||||
underlying js.Value
|
||||
}
|
||||
|
||||
// JSValue returns the underlying RTCDtlsTransport
|
||||
func (r *DTLSTransport) JSValue() js.Value {
|
||||
return r.underlying
|
||||
}
|
||||
|
||||
// ICETransport returns the currently-configured *ICETransport or nil
|
||||
// if one has not been configured
|
||||
func (r *DTLSTransport) ICETransport() *ICETransport {
|
||||
underlying := r.underlying.Get("iceTransport")
|
||||
if underlying.IsNull() || underlying.IsUndefined() {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &ICETransport{
|
||||
underlying: underlying,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *DTLSTransport) GetRemoteCertificate() []byte {
|
||||
if t.underlying.IsNull() || t.underlying.IsUndefined() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Firefox does not support getRemoteCertificates: https://bugzilla.mozilla.org/show_bug.cgi?id=1805446
|
||||
jsGet := t.underlying.Get("getRemoteCertificates")
|
||||
if jsGet.IsUndefined() || jsGet.IsNull() {
|
||||
return nil
|
||||
}
|
||||
|
||||
jsCerts := t.underlying.Call("getRemoteCertificates")
|
||||
if jsCerts.Length() == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
buf := jsCerts.Index(0)
|
||||
u8 := js.Global().Get("Uint8Array").New(buf)
|
||||
|
||||
if u8.Length() == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
cert := make([]byte, u8.Length())
|
||||
js.CopyBytesToGo(cert, u8)
|
||||
|
||||
return cert
|
||||
}
|
||||
Reference in New Issue
Block a user