oversip 1.1.0.beta3 → 1.1.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/etc/server.rb +9 -0
- data/ext/sip_parser/sip_parser_ruby.c +1 -1
- data/lib/oversip/default_server.rb +5 -0
- data/lib/oversip/launcher.rb +42 -12
- data/lib/oversip/logger.rb +1 -1
- data/lib/oversip/sip/listeners/tcp_client.rb +1 -1
- data/lib/oversip/sip/listeners/tcp_server.rb +1 -1
- data/lib/oversip/sip/listeners/tls_tunnel_server.rb +1 -1
- data/lib/oversip/sip/listeners/udp_reactor.rb +3 -1
- data/lib/oversip/sip/modules/registrar_without_path.rb +5 -8
- data/lib/oversip/sip/sip.rb +0 -4
- data/lib/oversip/version.rb +1 -1
- data/lib/oversip/websocket/listeners/tcp_server.rb +7 -5
- metadata +18 -18
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
<a href="http://www.oversip.net"><img src="http://www-test.oversip.net/images/dev/oversip-banner.png"/></a>
|
2
2
|
|
3
|
+
[![Build Status](https://secure.travis-ci.org/versatica/OverSIP.png?branch=master)](http://travis-ci.org/versatica/OverSIP)
|
4
|
+
|
3
5
|
**WEB UNDER CONSTRUCTION:** The code is stable and working. This web page and documentation is not... please wait a bit.
|
4
6
|
|
5
7
|
OverSIP is an async SIP proxy/server programmable in Ruby language.
|
data/etc/server.rb
CHANGED
@@ -50,6 +50,15 @@ end
|
|
50
50
|
# end
|
51
51
|
|
52
52
|
|
53
|
+
# This method is called after OverSIP has been terminated. It's called
|
54
|
+
# with argument "error" which is _true_ in case OverSIP has died in an
|
55
|
+
# unexpected way.
|
56
|
+
#
|
57
|
+
# def (OverSIP::SystemEvents).on_terminated error
|
58
|
+
# [...]
|
59
|
+
# end
|
60
|
+
|
61
|
+
|
53
62
|
|
54
63
|
|
55
64
|
### OverSIP SIP Events:
|
@@ -642,7 +642,7 @@ static void header_param(VALUE parsed, enum header_field header_field, const cha
|
|
642
642
|
TRACE();
|
643
643
|
VALUE v;
|
644
644
|
VALUE header_params;
|
645
|
-
|
645
|
+
|
646
646
|
switch(header_field) {
|
647
647
|
case header_field_via:
|
648
648
|
if ((header_params = rb_ivar_get(parsed, id_via_params)) == Qnil) {
|
data/lib/oversip/launcher.rb
CHANGED
@@ -8,6 +8,8 @@ module OverSIP::Launcher
|
|
8
8
|
|
9
9
|
|
10
10
|
def self.daemonize!(options)
|
11
|
+
@log_id = "launcher (daemonize)"
|
12
|
+
|
11
13
|
$stdin.reopen("/dev/null")
|
12
14
|
|
13
15
|
# grandparent (launcher) : Reads pipe, exits when master is ready.
|
@@ -30,7 +32,7 @@ module OverSIP::Launcher
|
|
30
32
|
# its PID.
|
31
33
|
master_pid = nil
|
32
34
|
begin
|
33
|
-
::Timeout
|
35
|
+
::Timeout.timeout(READY_PIPE_TIMEOUT/2) do
|
34
36
|
master_pid = rd.gets("\n").to_i rescue nil
|
35
37
|
end
|
36
38
|
rescue ::Timeout::Error
|
@@ -80,6 +82,8 @@ module OverSIP::Launcher
|
|
80
82
|
|
81
83
|
|
82
84
|
def self.run(options)
|
85
|
+
@log_id = "launcher (run)"
|
86
|
+
|
83
87
|
configuration = ::OverSIP.configuration
|
84
88
|
|
85
89
|
# Store the master process PID.
|
@@ -94,7 +98,6 @@ module OverSIP::Launcher
|
|
94
98
|
# I'm master process.
|
95
99
|
if (syslogger_pid = fork) != nil
|
96
100
|
::OverSIP.syslogger_pid = syslogger_pid
|
97
|
-
log_system_info "starting syslogger process (PID #{syslogger_pid})..."
|
98
101
|
::OverSIP::Logger.load_methods
|
99
102
|
|
100
103
|
# Load all the libraries for the master process.
|
@@ -117,6 +120,8 @@ module OverSIP::Launcher
|
|
117
120
|
exit
|
118
121
|
end
|
119
122
|
|
123
|
+
@log_id = "launcher (master)"
|
124
|
+
|
120
125
|
::EM.run do
|
121
126
|
|
122
127
|
log_system_info "using Ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{RUBY_PLATFORM}]"
|
@@ -402,10 +407,17 @@ module OverSIP::Launcher
|
|
402
407
|
|
403
408
|
|
404
409
|
def self.trap_signals
|
405
|
-
# This should never occur
|
410
|
+
# This should never occur (unless some not trapped signal is received
|
411
|
+
# and causes Ruby to exit, or maybe the user called "exit()" within its
|
412
|
+
# custom code).
|
406
413
|
at_exit do
|
407
|
-
|
408
|
-
|
414
|
+
if $!.is_a? ::SystemExit
|
415
|
+
log_system_notice "exiting due to SystemExit..."
|
416
|
+
terminate error=false
|
417
|
+
else
|
418
|
+
log_system_crit "exiting due to an unknown cause ($! = #{$!.inspect})..."
|
419
|
+
terminate error=true
|
420
|
+
end
|
409
421
|
end
|
410
422
|
|
411
423
|
# Signals that cause OverSIP to terminate.
|
@@ -413,7 +425,7 @@ module OverSIP::Launcher
|
|
413
425
|
exit_signals.each do |signal|
|
414
426
|
trap signal do
|
415
427
|
log_system_notice "#{signal} signal received, exiting..."
|
416
|
-
terminate
|
428
|
+
terminate error=false
|
417
429
|
end
|
418
430
|
end
|
419
431
|
|
@@ -459,22 +471,35 @@ module OverSIP::Launcher
|
|
459
471
|
end
|
460
472
|
|
461
473
|
|
462
|
-
def self.terminate error=false
|
474
|
+
def self.terminate error=false, fatal=false
|
475
|
+
unless fatal
|
476
|
+
# Run the user provided on_terminated callback.
|
477
|
+
log_system_info "calling OverSIP::SystemEvents.on_terminated()..."
|
478
|
+
begin
|
479
|
+
::OverSIP::SystemEvents.on_terminated error
|
480
|
+
rescue ::Exception => e
|
481
|
+
log_system_crit "error calling OverSIP::SystemEvents.on_terminated():"
|
482
|
+
log_system_crit e
|
483
|
+
end
|
484
|
+
end
|
485
|
+
|
463
486
|
unless error
|
464
487
|
log_system_info "exiting, thank you for tasting #{::OverSIP::PROGRAM_NAME}"
|
465
488
|
end
|
466
489
|
|
467
|
-
# Kill Stud processes.
|
490
|
+
# Kill Stud processes and delete its temporal file with the full certificate.
|
468
491
|
kill_stud_processes
|
492
|
+
::File.delete ::OverSIP.configuration[:tls][:full_cert] rescue nil
|
469
493
|
|
470
494
|
# Wait a bit so pending log messages in the Posix MQ can be queued.
|
471
495
|
sleep 0.1
|
472
|
-
delete_pid_file
|
473
496
|
::OverSIP::Logger.close
|
474
497
|
|
475
498
|
# Fill the syslogger process.
|
476
499
|
kill_syslogger_process
|
477
500
|
|
501
|
+
delete_pid_file
|
502
|
+
|
478
503
|
# Exit by preventing any exception.
|
479
504
|
exit!( error ? false : true )
|
480
505
|
end
|
@@ -508,7 +533,7 @@ module OverSIP::Launcher
|
|
508
533
|
uid = ::Etc.getpwnam(user).uid if user
|
509
534
|
gid = ::Etc.getgrnam(group).gid if group
|
510
535
|
if uid or gid
|
511
|
-
if gid
|
536
|
+
if gid and ::Process.egid != gid
|
512
537
|
::Process.initgroups(user, gid) if user
|
513
538
|
::Process::GID.change_privilege(gid)
|
514
539
|
end
|
@@ -527,9 +552,10 @@ module OverSIP::Launcher
|
|
527
552
|
|
528
553
|
bin_dir = ::File.join(::File.absolute_path(::File.dirname(__FILE__)), "../../bin/")
|
529
554
|
stdout_file = "/tmp/stud.#{listen_ip}:#{listen_port}.out"
|
555
|
+
stderr_file = "/tmp/stud.#{listen_ip}:#{listen_port}.err"
|
530
556
|
|
531
557
|
::Dir.chdir(bin_dir) do
|
532
|
-
pid = ::POSIX::Spawn.spawn "./oversip_stud #{stud_user_group} #{ssl_option} -f '#{listen_ip},#{listen_port}' -b '#{bg_ip},#{bg_port}' -n 2 -s --daemon --write-proxy #{::OverSIP.configuration[:tls][:full_cert]}", :out => stdout_file, :err =>
|
558
|
+
pid = ::POSIX::Spawn.spawn "./oversip_stud #{stud_user_group} #{ssl_option} -f '#{listen_ip},#{listen_port}' -b '#{bg_ip},#{bg_port}' -n 2 -s --daemon --write-proxy #{::OverSIP.configuration[:tls][:full_cert]}", :out => stdout_file, :err => stderr_file
|
533
559
|
::Process.waitpid(pid)
|
534
560
|
end
|
535
561
|
|
@@ -546,8 +572,12 @@ module OverSIP::Launcher
|
|
546
572
|
::File.delete stdout_file rescue nil
|
547
573
|
|
548
574
|
unless pid
|
549
|
-
|
575
|
+
stderr = ::File.read stderr_file
|
576
|
+
::File.delete stderr_file rescue nil
|
577
|
+
log_system_crit "error spawning stud server for listening on #{listen_ip} : #{listen_port}:"
|
578
|
+
fatal stderr
|
550
579
|
end
|
580
|
+
::File.delete stderr_file rescue nil
|
551
581
|
|
552
582
|
::OverSIP.stud_pids ||= []
|
553
583
|
::OverSIP.stud_pids << pid
|
data/lib/oversip/logger.rb
CHANGED
@@ -19,11 +19,11 @@ module OverSIP::SIP
|
|
19
19
|
|
20
20
|
# Add the ;ov-ob param to the Contact URI.
|
21
21
|
request.contact.set_param "ov-ob", request.connection_outbound_flow_token
|
22
|
+
# NOTE: request.contact_params is a String with the original Contact URI params
|
23
|
+
# so they are added at the end of the new URI with the added ;ov-ob param.
|
22
24
|
# TODO: This should be done automatically, right?
|
23
25
|
request.set_header "Contact", "#{request.contact.to_s}#{request.contact_params}"
|
24
|
-
|
25
26
|
return true
|
26
|
-
|
27
27
|
else
|
28
28
|
return false
|
29
29
|
end
|
@@ -31,9 +31,9 @@ module OverSIP::SIP
|
|
31
31
|
|
32
32
|
def self.extract_outbound_from_ruri request
|
33
33
|
# Do nothing if the request already contains a Route header with the Outbound flow token (so
|
34
|
-
# the registrar *does* support Path.
|
34
|
+
# the registrar *does* support Path).
|
35
35
|
unless request.incoming_outbound_requested?
|
36
|
-
if ov_ob = request.ruri.del_param("ov-ob")
|
36
|
+
if (ov_ob = request.ruri.del_param("ov-ob"))
|
37
37
|
log_system_debug "incoming Outbound flow token extracted from ;ov-ob param in RURI for #{request.log_id}" if $oversip_debug
|
38
38
|
request.route_outbound_flow_token = ov_ob
|
39
39
|
request.incoming_outbound_requested = true
|
@@ -42,7 +42,7 @@ module OverSIP::SIP
|
|
42
42
|
return false
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
else
|
46
46
|
# If the request already contains a proper Outbound Route header, then at least try to remove
|
47
47
|
# the ;ov-ob param from the RURI.
|
48
48
|
request.ruri.del_param("ov-ob")
|
@@ -57,13 +57,10 @@ module OverSIP::SIP
|
|
57
57
|
|
58
58
|
if (contacts = message.headers["Contact"])
|
59
59
|
log_system_debug "reverting original Contact value (removing ;ov-ob Outbound param) for response" if $oversip_debug
|
60
|
-
|
61
60
|
contacts.each do |contact|
|
62
61
|
contact.gsub! /;ov-ob=[_\-0-9A-Za-z]+/, ""
|
63
62
|
end
|
64
|
-
|
65
63
|
return true
|
66
|
-
|
67
64
|
else
|
68
65
|
return false
|
69
66
|
end
|
data/lib/oversip/sip/sip.rb
CHANGED
data/lib/oversip/version.rb
CHANGED
@@ -64,10 +64,12 @@ module OverSIP::WebSocket
|
|
64
64
|
def unbind cause=nil
|
65
65
|
@local_closed = true if cause == ::Errno::ETIMEDOUT
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
if $oversip_debug
|
68
|
+
log_msg = "connection from #{remote_desc} "
|
69
|
+
log_msg << ( @local_closed ? "locally closed" : "remotely closed" )
|
70
|
+
log_msg << " (cause: #{cause.inspect})" if cause
|
71
|
+
log_system_debug log_msg
|
72
|
+
end unless $!
|
71
73
|
|
72
74
|
@ws_framing.tcp_closed if @ws_framing
|
73
75
|
|
@@ -78,7 +80,7 @@ module OverSIP::WebSocket
|
|
78
80
|
log_system_error "error calling OverSIP::WebSocketEvents.on_connection_closed():"
|
79
81
|
log_system_error e
|
80
82
|
end
|
81
|
-
end
|
83
|
+
end unless $!
|
82
84
|
end
|
83
85
|
|
84
86
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oversip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0.
|
4
|
+
version: 1.1.0.beta4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine-le
|
16
|
-
requirement: &
|
16
|
+
requirement: &18475300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.1.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *18475300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: iobuffer
|
27
|
-
requirement: &
|
27
|
+
requirement: &18474840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.1.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *18474840
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: em-posixmq
|
38
|
-
requirement: &
|
38
|
+
requirement: &18474380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.2.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *18474380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: em-udns
|
49
|
-
requirement: &
|
49
|
+
requirement: &18473920 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.3.6
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *18473920
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: escape_utils
|
60
|
-
requirement: &
|
60
|
+
requirement: &18473460 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.2.4
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *18473460
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: term-ansicolor
|
71
|
-
requirement: &
|
71
|
+
requirement: &18473080 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *18473080
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: posix-spawn
|
82
|
-
requirement: &
|
82
|
+
requirement: &18472540 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.3.6
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *18472540
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rake
|
93
|
-
requirement: &
|
93
|
+
requirement: &18472040 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: 0.9.2
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *18472040
|
102
102
|
description: ! "OverSIP is an async SIP server. Built on top of Ruby EventMachine\n
|
103
103
|
\ library it follows the Reactor Pattern, allowing thousands of concurrent connections
|
104
104
|
and requests\n handled by a single processor in a never-blocking fashion. It
|