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

WebRTC client & server #2135

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
be4d077
Experiment with a WebRTC client
tomaka Jan 21, 2022
9b00ba7
Tweaks
tomaka Jan 21, 2022
368fcbf
Add comment about worker
tomaka Jan 21, 2022
6028b53
WIP
tomaka Jan 21, 2022
938598a
WIP
tomaka Jan 23, 2022
009ed59
Missing await
tomaka Jan 23, 2022
05cab74
WIP
tomaka Jan 23, 2022
81f2166
Remove this whole certificate generation thing
tomaka Jan 23, 2022
e447789
WIP
tomaka Jan 23, 2022
47a5497
Tweaks to genRandomPayload
tomaka Jan 23, 2022
2ec5323
WIP
tomaka Jan 23, 2022
412ca74
bin/web-server: initial commit
melekes Mar 9, 2022
688a934
bin/webrtc-server: add handlers
melekes Mar 10, 2022
e80dde7
add CTRL-C handler
melekes Mar 10, 2022
02c8748
add webrtc-sdp crate for modifying sdp
melekes Mar 11, 2022
b57d1f3
remove sendrecv attr as it's default value
melekes Mar 11, 2022
ff4b88c
add doc for sctp-port and max-message-size
melekes Mar 11, 2022
4b4020b
lock files changes
melekes Mar 15, 2022
ccbeec1
remove certificates from js client dir
melekes Mar 15, 2022
56dd084
webrtc js: add a comment for candidate attr
melekes Mar 15, 2022
ca52f78
use settings engine to disable cert verification
melekes Mar 15, 2022
8fda941
use single UDP socket as a mux
melekes Mar 15, 2022
e83aa16
no need to parse SDP
melekes Mar 15, 2022
591c0b5
refactor JS client to use pc functions
melekes Mar 16, 2022
0f23739
log ice conn state changes in server
melekes Mar 16, 2022
79c5616
add docs for ice-lite
melekes Mar 18, 2022
da40d38
enable debugging and create valid key/cert
melekes Mar 18, 2022
c433903
write README with instructions
melekes Mar 18, 2022
206f282
set lite and DTLS role for server
melekes Mar 18, 2022
56eaa6b
regenerate key
melekes Mar 18, 2022
eb0e08a
update key
melekes Mar 18, 2022
f6560e4
working connection
melekes Mar 21, 2022
c347cda
add a=end-of-candidates attribute
melekes Mar 21, 2022
4bb5a1d
remove group & end-of-candidates attrs
melekes Mar 21, 2022
ecba040
minor logging changes
melekes Mar 21, 2022
50242e6
handle ipv6
melekes Mar 22, 2022
03972a9
update readme
melekes Mar 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 16 additions & 6 deletions bin/wasm-node/javascript/src/webrtc/index.ts
Expand Up @@ -210,20 +210,30 @@ export default function(targetIp: string, protocol: 'tcp' | 'udp', targetPort: n
// The maximum SCTP user message size (in bytes) (RFC8841)
"a=max-message-size:100000" + "\n" +
// A transport address for a candidate that can be used for connectivity checks (RFC8839).
"a=candidate:0 1 " + (protocol == 'tcp' ? "TCP" : "UDP") + " 2113667327 " + targetIp + " " + targetPort + " typ host" + "\n";
"a=candidate:1 1 " + (protocol == 'tcp' ? "TCP" : "UDP") + " 2113667327 " + targetIp + " " + targetPort + " typ host" + "\n" +
// Indicate that there will be no further candidates.
"a=end-of-candidates" + "\n";
melekes marked this conversation as resolved.
Show resolved Hide resolved

await webrtc.setRemoteDescription({ type: "answer", sdp: remoteSdp });
await pc.setRemoteDescription({ type: "answer", sdp: remoteSdp });

console.log(webrtc.remoteDescription!.sdp);
});
console.log(pc.remoteDescription!.sdp);
};

dataChannel.onopen = () => {
console.log('open!');
console.log(`'${dataChannel.label}' opened`);
};

dataChannel.onerror = (error) => {
console.log('error! ' + error);
console.log(`'${dataChannel.label}' errored: ${error}`);
};

dataChannel.onclose = () => {
console.log(`'${dataChannel.label}' closed`);
};

dataChannel.onmessage = (m) => {
console.log(`new message on '${dataChannel.label}': '${m.data}'`);
}
}

/**
Expand Down
3 changes: 1 addition & 2 deletions bin/webrtc-server/src/main.rs
Expand Up @@ -153,13 +153,12 @@ async fn main() -> Result<()> {
se.set_ice_credentials(ICE_USER.to_string(), ICE_PASSWD.to_string());
let api = APIBuilder::new().with_setting_engine(se).build();
let certificate = load_certificate().expect("failed to load certificate");
debug!("EXPIRES {:?}", certificate.get_fingerprints());
let config = RTCConfiguration {
certificates: vec![certificate],
..Default::default()
};

let peer_connection = Arc::new(api.new_peer_connection(config).await?);
let peer_connection = api.new_peer_connection(config).await?;

let (done_tx, done_rx) = async_channel::bounded(1);

Expand Down