]> Sergey Matveev's repositories - btrtrc.git/blob - webrtc.go
Upgrade to pion/webrtc@v3
[btrtrc.git] / webrtc.go
1 package torrent
2
3 import (
4         "net"
5         "time"
6
7         "github.com/pion/datachannel"
8         "github.com/pion/webrtc/v3"
9
10         "github.com/anacrolix/torrent/webtorrent"
11 )
12
13 const webrtcNetwork = "webrtc"
14
15 type webrtcNetConn struct {
16         datachannel.ReadWriteCloser
17         webtorrent.DataChannelContext
18 }
19
20 type webrtcNetAddr struct {
21         webrtc.SessionDescription
22 }
23
24 func (webrtcNetAddr) Network() string {
25         return webrtcNetwork
26 }
27
28 func (me webrtcNetAddr) String() string {
29         // TODO: What can I show here that's more like other protocols?
30         return "<WebRTC>"
31 }
32
33 func (me webrtcNetConn) LocalAddr() net.Addr {
34         return webrtcNetAddr{me.Local}
35 }
36
37 func (me webrtcNetConn) RemoteAddr() net.Addr {
38         return webrtcNetAddr{me.Remote}
39 }
40
41 func (w webrtcNetConn) SetDeadline(t time.Time) error {
42         return nil
43 }
44
45 func (w webrtcNetConn) SetReadDeadline(t time.Time) error {
46         return nil
47 }
48
49 func (w webrtcNetConn) SetWriteDeadline(t time.Time) error {
50         return nil
51 }