forked from anacrolix/torrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebrtc.go
51 lines (38 loc) · 911 Bytes
/
webrtc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package torrent
import (
"net"
"time"
"github.com/pion/datachannel"
"github.com/pion/webrtc/v2"
"github.com/anacrolix/torrent/webtorrent"
)
const webrtcNetwork = "webrtc"
type webrtcNetConn struct {
datachannel.ReadWriteCloser
webtorrent.DataChannelContext
}
type webrtcNetAddr struct {
webrtc.SessionDescription
}
func (webrtcNetAddr) Network() string {
return webrtcNetwork
}
func (me webrtcNetAddr) String() string {
// TODO: What can I show here that's more like other protocols?
return "<WebRTC>"
}
func (me webrtcNetConn) LocalAddr() net.Addr {
return webrtcNetAddr{me.Local}
}
func (me webrtcNetConn) RemoteAddr() net.Addr {
return webrtcNetAddr{me.Remote}
}
func (w webrtcNetConn) SetDeadline(t time.Time) error {
return nil
}
func (w webrtcNetConn) SetReadDeadline(t time.Time) error {
return nil
}
func (w webrtcNetConn) SetWriteDeadline(t time.Time) error {
return nil
}