Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct webrtc callbacks to match new pions api #14

Merged
merged 2 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}