fixing create permission handling

This commit is contained in:
Roland Osborne 2023-04-10 10:07:52 -07:00
parent e2b33bccfe
commit 7299d63711
3 changed files with 34 additions and 4 deletions

View File

@ -241,6 +241,7 @@ export function useRingContext() {
// connect signal socket // connect signal socket
connected.current = false; connected.current = false;
candidates.current = []; candidates.current = [];
pc.current = null;
updateState({ remoteVideo: false, remoteAudio: false, remoteStream: null, localVideo: false, localAudio: false, localStream: null }); updateState({ remoteVideo: false, remoteAudio: false, remoteStream: null, localVideo: false, localAudio: false, localStream: null });
videoTrack.current = false; videoTrack.current = false;
@ -288,7 +289,9 @@ export function useRingContext() {
} }
ws.current.onclose = (e) => { ws.current.onclose = (e) => {
// update state to disconnected // update state to disconnected
pc.current.close(); if (pc.current) {
pc.current.close();
}
clearRing(); clearRing();
clearAlive(); clearAlive();
calling.current = null; calling.current = null;

View File

@ -120,11 +120,31 @@ func (s *Sturn) handleMessage(buf []byte, addr net.Addr) {
} }
func (s *Sturn) handleCreatePermissionRequest(msg *SturnMessage, addr net.Addr) { func (s *Sturn) handleCreatePermissionRequest(msg *SturnMessage, addr net.Addr) {
fmt.Println(addr.String(), msg); fmt.Println(addr.String(), msg);
var attributes []SturnAttribute
attributes = append(attributes, SturnAttribute{
atrType: ATRMessageIntegrity,
});
response := &SturnMessage{
class: CLSResponse,
method: MEHCreatePermission,
transaction: msg.transaction,
attributes: attributes,
};
err, n := writeMessage(response, s.buf);
if err != nil {
fmt.Printf("failed to write stun response");
} else {
(*s.conn).WriteTo(s.buf[:n], addr);
fmt.Println("PERM>", s.buf[:n]);
}
return
} }
func (s *Sturn) handleSendIndication(msg *SturnMessage, addr net.Addr) { func (s *Sturn) handleSendIndication(msg *SturnMessage, addr net.Addr) {
fmt.Println(addr.String(), msg); //fmt.Println(addr.String(), msg);
} }
func (s *Sturn) handleBindingRequest(msg *SturnMessage, addr net.Addr) { func (s *Sturn) handleBindingRequest(msg *SturnMessage, addr net.Addr) {
@ -222,7 +242,8 @@ func (s *Sturn) handleAllocateRequest(msg *SturnMessage, addr net.Addr) {
atrType: ATRXorRelayedAddress, atrType: ATRXorRelayedAddress,
byteValue: FAMIPv4, byteValue: FAMIPv4,
intValue: int32(relayPort), intValue: int32(relayPort),
strValue: "98.234.232.221", strValue: "192.168.13.233",
//strValue: "98.234.232.221",
}); });
attributes = append(attributes, SturnAttribute{ attributes = append(attributes, SturnAttribute{
atrType: ATRLifetime, atrType: ATRLifetime,

View File

@ -138,6 +138,12 @@ func setMessageType(class int, method int) (byte, byte) {
if class == CLSError && method == MEHAllocate { if class == CLSError && method == MEHAllocate {
return 0x01, 0x13 return 0x01, 0x13
} }
if class == CLSResponse && method == MEHCreatePermission {
return 0x01, 0x08
}
if class == CLSError && method == MEHCreatePermission {
return 0x01, 0x18
}
return 0x00, 0x00 return 0x00, 0x00
} }