@@ -631,7 +631,7 @@ JsSIP.UA.prototype.loadConfig = function(configuration) {
631
631
632
632
// Session parameters
633
633
no_answer_timeout : 60 ,
634
- stun_server : 'stun.l.google.com:19302' ,
634
+ stun_server : 'stun:stun .l.google.com:19302' ,
635
635
636
636
// Loggin parameters
637
637
trace_sip : false ,
@@ -696,6 +696,14 @@ JsSIP.UA.prototype.loadConfig = function(configuration) {
696
696
return false ;
697
697
}
698
698
699
+ // Turn
700
+ if ( settings . turn_server ) {
701
+ if ( ! settings . turn_username || ! settings . turn_password ) {
702
+ console . error ( 'TURN username and password must be specified' ) ;
703
+ return false ;
704
+ }
705
+ }
706
+
699
707
// Post Configuration Process
700
708
701
709
// Instance-id for GRUU
@@ -741,6 +749,14 @@ JsSIP.UA.prototype.loadConfig = function(configuration) {
741
749
742
750
}
743
751
752
+ // TURN URI
753
+ if ( settings . turn_server ) {
754
+ uri = JsSIP . grammar . parse ( settings . turn_server , 'turn_URI' ) ;
755
+ settings . turn_uri = uri . scheme + ':' ;
756
+ settings . turn_uri += settings . turn_username + '@' ;
757
+ settings . turn_uri += settings . turn_server . substr ( uri . scheme . length + 1 ) ;
758
+ }
759
+
744
760
contact = {
745
761
uri : { value : 'sip:' + uri . user + '@' + settings . via_host + ';transport=ws' , writable : false , configurable : false }
746
762
} ;
@@ -795,6 +811,10 @@ JsSIP.UA.configuration_skeleton = (function() {
795
811
"hack_ip_in_contact" , //false
796
812
"password" ,
797
813
"stun_server" ,
814
+ "turn_server" ,
815
+ "turn_username" ,
816
+ "turn_password" ,
817
+ "turn_uri" ,
798
818
"no_answer_timeout" , // 30 seconds.
799
819
"register_expires" , // 600 seconds.
800
820
"trace_sip" ,
@@ -913,12 +933,28 @@ JsSIP.UA.configuration_check = {
913
933
}
914
934
} ,
915
935
stun_server : function ( stun_server ) {
916
- var parsed ;
917
-
918
- parsed = JsSIP . grammar . parse ( stun_server , 'hostport' ) ;
919
-
920
- if ( parsed === - 1 ) {
921
- console . log ( JsSIP . c . LOG_UA + 'Invalid stun_server: ' + stun_server ) ;
936
+ if ( JsSIP . grammar . parse ( stun_server , 'stun_URI' ) === - 1 ) {
937
+ return false ;
938
+ } else {
939
+ return true ;
940
+ }
941
+ } ,
942
+ turn_server : function ( turn_server ) {
943
+ if ( JsSIP . grammar . parse ( turn_server , 'turn_URI' ) === - 1 ) {
944
+ return false ;
945
+ } else {
946
+ return true ;
947
+ }
948
+ } ,
949
+ turn_username : function ( turn_username ) {
950
+ if ( JsSIP . grammar . parse ( turn_username , 'user' ) === - 1 ) {
951
+ return false ;
952
+ } else {
953
+ return true ;
954
+ }
955
+ } ,
956
+ turn_password : function ( turn_password ) {
957
+ if ( JsSIP . grammar . parse ( turn_password , 'password' ) === - 1 ) {
922
958
return false ;
923
959
} else {
924
960
return true ;
0 commit comments