torrent/webrtc.go

52 lines
911 B
Go
Raw Normal View History

package torrent
import (
"net"
"time"
"github.com/pion/datachannel"
2021-02-21 21:30:34 +00:00
"github.com/pion/webrtc/v3"
2020-04-07 04:30:27 +00:00
"github.com/anacrolix/torrent/webtorrent"
)
2020-04-07 04:30:27 +00:00
const webrtcNetwork = "webrtc"
type webrtcNetConn struct {
datachannel.ReadWriteCloser
2020-04-07 04:30:27 +00:00
webtorrent.DataChannelContext
}
type webrtcNetAddr struct {
2020-04-07 04:30:27 +00:00
webrtc.SessionDescription
}
func (webrtcNetAddr) Network() string {
2020-04-07 04:30:27 +00:00
return webrtcNetwork
}
2020-04-07 04:30:27 +00:00
func (me webrtcNetAddr) String() string {
// TODO: What can I show here that's more like other protocols?
return "<WebRTC>"
}
2020-04-07 04:30:27 +00:00
func (me webrtcNetConn) LocalAddr() net.Addr {
return webrtcNetAddr{me.Local}
}
2020-04-07 04:30:27 +00:00
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
}