Skip to content

Commit

Permalink
Merge pull request #14 from maxmcd/fix-pions-webrtc-breaking-changes
Browse files Browse the repository at this point in the history
Correct webrtc callbacks to match new pions api
  • Loading branch information
maxmcd authored Nov 19, 2018
2 parents ec7138d + f3e38c7 commit b0aba6b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
8 changes: 6 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ jobs:
name: run go tests
command: |
set -e
go get -v .
go get golang.org/x/lint/golint
go get -u github.com/mitchellh/colorstring
go get -u github.com/pions/webrtc
go get -u github.com/kr/pty
go get -u golang.org/x/crypto/ssh/terminal
go get -u github.com/btcsuite/btcutil/base58
go get -u golang.org/x/lint/golint
golint
go test
go test ./pkg/sd
Expand Down
6 changes: 2 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ func (cs *clientSession) run() (err error) {
return
}

cs.dc.Lock()
cs.dc.OnOpen = cs.dataChannelOnOpen()
cs.dc.Onmessage = cs.dataChannelOnMessage()
cs.dc.Unlock()
cs.dc.OnOpen(cs.dataChannelOnOpen())
cs.dc.OnMessage(cs.dataChannelOnMessage())

if cs.offer, err = sd.Decode(cs.offerString); err != nil {
log.Println(err)
Expand Down
8 changes: 3 additions & 5 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,8 @@ func (hs *hostSession) dataChannelOnMessage() func(payload datachannel.Payload)
func (hs *hostSession) onDataChannel() func(dc *webrtc.RTCDataChannel) {
return func(dc *webrtc.RTCDataChannel) {
hs.dc = dc
dc.Lock()
defer dc.Unlock()
dc.OnOpen = hs.dataChannelOnOpen()
dc.Onmessage = hs.dataChannelOnMessage()
dc.OnOpen(hs.dataChannelOnOpen())
dc.OnMessage(hs.dataChannelOnMessage())
}
}

Expand All @@ -186,7 +184,7 @@ func (hs *hostSession) mustReadStdin() (string, error) {
}

func (hs *hostSession) createOffer() (err error) {
hs.pc.OnDataChannel = hs.onDataChannel()
hs.pc.OnDataChannel(hs.onDataChannel())

// Create an offer to send to the browser
offer, err := hs.pc.CreateOffer(nil)
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ go get -u github.com/maxmcd/webtty
```
WebTTY uses the wonderful [pions/webrtc](https://github.com/pions/webrtc) for WebRTC communication. It currently requires OpenSSL to build. More here: [https://github.com/pions/webrtc#install](https://github.com/pions/webrtc#install)

There were recent breaking api changes in the pions/webrtc library. Make sure to run `go get -u github.com/pions/webrtc` if you're running into any installation errors.

### Running

```shell
Expand Down Expand Up @@ -80,4 +82,3 @@ I think this somewhat violates the spirit of this tool because it relies on a th
SDP descriptions are encrypted when uploaded and encryption keys are shared with the connection data to decrypt. So presumably the service being compromised is not problematic.

Very open to any ideas on how to enable trusted one-way connections. Please open an issue or reach out if you have thoughts. For now, the `-o` flag will print a warning and link to this explanation.

4 changes: 2 additions & 2 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func (s *session) createPeerConnection() (err error) {
// if s.pc.OnDataChannel == nil {
// return errors.New("Couldn't create a peerConnection")
// }
s.pc.OnICEConnectionStateChange = func(connectionState ice.ConnectionState) {
s.pc.OnICEConnectionStateChange(func(connectionState ice.ConnectionState) {
log.Printf("ICE Connection State has changed: %s\n", connectionState.String())
}
})
return
}

0 comments on commit b0aba6b

Please sign in to comment.