oversip 1.0.6.beta3 → 1.0.7.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/etc/system_events.rb +7 -0
 - data/etc/websocket_policy.rb +3 -3
 - data/lib/oversip/config.rb +49 -6
 - data/lib/oversip/errors.rb +1 -1
 - data/lib/oversip/launcher.rb +20 -5
 - data/lib/oversip/proxies_config.rb +31 -28
 - data/lib/oversip/version.rb +2 -2
 - data/lib/oversip/websocket/listeners/tcp_server.rb +6 -6
 - data/lib/oversip/websocket/ws_framing.rb +1 -1
 - metadata +17 -17
 
    
        data/etc/system_events.rb
    CHANGED
    
    | 
         @@ -15,4 +15,11 @@ module OverSIP::SystemEvents 
     | 
|
| 
       15 
15 
     | 
    
         
             
                # Do something.
         
     | 
| 
       16 
16 
     | 
    
         
             
              end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
              # This method is called when a USR1 signal is received by the main
         
     | 
| 
      
 19 
     | 
    
         
            +
              # process and allows the user to set custom code to be executed
         
     | 
| 
      
 20 
     | 
    
         
            +
              # or reloaded.
         
     | 
| 
      
 21 
     | 
    
         
            +
              def self.on_user_reload
         
     | 
| 
      
 22 
     | 
    
         
            +
                # Do something.
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       18 
25 
     | 
    
         
             
            end
         
     | 
    
        data/etc/websocket_policy.rb
    CHANGED
    
    | 
         @@ -13,17 +13,17 @@ module OverSIP::WebSocket::Policy 
     | 
|
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
              # Check the value of the Host header, by splitting it into
         
     | 
| 
       15 
15 
     | 
    
         
             
              # host (a String) and port (Fixnum). Both could be _nil_.
         
     | 
| 
       16 
     | 
    
         
            -
              def check_hostport host=nil, port=nil
         
     | 
| 
      
 16 
     | 
    
         
            +
              def self.check_hostport host=nil, port=nil
         
     | 
| 
       17 
17 
     | 
    
         
             
                return true
         
     | 
| 
       18 
18 
     | 
    
         
             
              end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              # Check the value of the Origin header (a String with original value).
         
     | 
| 
       21 
     | 
    
         
            -
              def check_origin origin=nil
         
     | 
| 
      
 21 
     | 
    
         
            +
              def self.check_origin origin=nil
         
     | 
| 
       22 
22 
     | 
    
         
             
                return true
         
     | 
| 
       23 
23 
     | 
    
         
             
              end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
              # Check the request URI path (String) and query (String). Both can be _nil_.
         
     | 
| 
       26 
     | 
    
         
            -
              def check_request_uri path=nil, query=nil
         
     | 
| 
      
 26 
     | 
    
         
            +
              def self.check_request_uri path=nil, query=nil
         
     | 
| 
       27 
27 
     | 
    
         
             
                return true
         
     | 
| 
       28 
28 
     | 
    
         
             
              end
         
     | 
| 
       29 
29 
     | 
    
         | 
    
        data/lib/oversip/config.rb
    CHANGED
    
    | 
         @@ -240,7 +240,15 @@ module OverSIP 
     | 
|
| 
       240 
240 
     | 
    
         
             
                  end
         
     | 
| 
       241 
241 
     | 
    
         | 
| 
       242 
242 
     | 
    
         
             
                  ::OverSIP.configuration = @configuration
         
     | 
| 
       243 
     | 
    
         
            -
             
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 245 
     | 
    
         
            +
                    ::OverSIP::ProxiesConfig.load proxies_yaml
         
     | 
| 
      
 246 
     | 
    
         
            +
                  rescue ::OverSIP::ConfigurationError => e
         
     | 
| 
      
 247 
     | 
    
         
            +
                    fatal "error loading Proxies Configuration file '#{@proxies_file}':  #{e.message}"
         
     | 
| 
      
 248 
     | 
    
         
            +
                  rescue ::Exception => e
         
     | 
| 
      
 249 
     | 
    
         
            +
                    log_system_crit "error loading Proxies Configuration file '#{@proxies_file}':"
         
     | 
| 
      
 250 
     | 
    
         
            +
                    fatal e
         
     | 
| 
      
 251 
     | 
    
         
            +
                  end
         
     | 
| 
       244 
252 
     | 
    
         
             
                end
         
     | 
| 
       245 
253 
     | 
    
         | 
| 
       246 
254 
     | 
    
         | 
| 
         @@ -564,15 +572,50 @@ module OverSIP 
     | 
|
| 
       564 
572 
     | 
    
         
             
                  end
         
     | 
| 
       565 
573 
     | 
    
         
             
                end
         
     | 
| 
       566 
574 
     | 
    
         | 
| 
       567 
     | 
    
         
            -
                def self. 
     | 
| 
      
 575 
     | 
    
         
            +
                def self.system_reload
         
     | 
| 
      
 576 
     | 
    
         
            +
                  log_system_notice "reloading OverSIP..."
         
     | 
| 
      
 577 
     | 
    
         
            +
             
     | 
| 
      
 578 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 579 
     | 
    
         
            +
                   ::Kernel.load @custom_lib_file
         
     | 
| 
      
 580 
     | 
    
         
            +
                   log_system_notice "Custom Library file '#{@custom_lib_file}' reloaded"
         
     | 
| 
      
 581 
     | 
    
         
            +
                  rescue ::Exception => e
         
     | 
| 
      
 582 
     | 
    
         
            +
                    log_system_crit "error reloading Custom Library file '#{@custom_lib_file}':"
         
     | 
| 
      
 583 
     | 
    
         
            +
                    log_system_crit e
         
     | 
| 
      
 584 
     | 
    
         
            +
                  end
         
     | 
| 
      
 585 
     | 
    
         
            +
             
     | 
| 
      
 586 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 587 
     | 
    
         
            +
                   ::Kernel.load @system_events_file
         
     | 
| 
      
 588 
     | 
    
         
            +
                   log_system_notice "System Events file '#{@system_events_file}' reloaded"
         
     | 
| 
      
 589 
     | 
    
         
            +
                  rescue ::Exception => e
         
     | 
| 
      
 590 
     | 
    
         
            +
                    log_system_crit "error reloading System Events file '#{@system_events_file}':"
         
     | 
| 
      
 591 
     | 
    
         
            +
                    log_system_crit e
         
     | 
| 
      
 592 
     | 
    
         
            +
                  end
         
     | 
| 
      
 593 
     | 
    
         
            +
             
     | 
| 
      
 594 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 595 
     | 
    
         
            +
                   ::Kernel.load @events_file
         
     | 
| 
      
 596 
     | 
    
         
            +
                   log_system_notice "Events file '#{@events_file}' reloaded"
         
     | 
| 
      
 597 
     | 
    
         
            +
                  rescue ::Exception => e
         
     | 
| 
      
 598 
     | 
    
         
            +
                    log_system_crit "error reloading Events file '#{@events_file}':"
         
     | 
| 
      
 599 
     | 
    
         
            +
                    log_system_crit e
         
     | 
| 
      
 600 
     | 
    
         
            +
                  end
         
     | 
| 
      
 601 
     | 
    
         
            +
             
     | 
| 
      
 602 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 603 
     | 
    
         
            +
                    proxies_yaml = ::YAML.load_file @proxies_file
         
     | 
| 
      
 604 
     | 
    
         
            +
                    ::OverSIP::ProxiesConfig.load proxies_yaml, reload=true
         
     | 
| 
      
 605 
     | 
    
         
            +
                    log_system_notice "Proxies Configuration file '#{@proxies_file}' reloaded"
         
     | 
| 
      
 606 
     | 
    
         
            +
                  rescue ::OverSIP::ConfigurationError => e
         
     | 
| 
      
 607 
     | 
    
         
            +
                    log_system_crit "error reloading Proxies Configuration file '#{@proxies_file}':  #{e.message}"
         
     | 
| 
      
 608 
     | 
    
         
            +
                  rescue ::Exception => e
         
     | 
| 
      
 609 
     | 
    
         
            +
                    log_system_crit "error reloading Proxies Configuration file '#{@proxies_file}':"
         
     | 
| 
      
 610 
     | 
    
         
            +
                    log_system_crit e
         
     | 
| 
      
 611 
     | 
    
         
            +
                  end
         
     | 
| 
      
 612 
     | 
    
         
            +
             
     | 
| 
       568 
613 
     | 
    
         
             
                  begin
         
     | 
| 
       569 
614 
     | 
    
         
             
                    ::Kernel.load @logic_file
         
     | 
| 
       570 
     | 
    
         
            -
                     
     | 
| 
       571 
     | 
    
         
            -
                    true
         
     | 
| 
      
 615 
     | 
    
         
            +
                    log_system_notice "Logic file '#{@logic_file}' reloaded"
         
     | 
| 
       572 
616 
     | 
    
         
             
                  rescue ::Exception => e
         
     | 
| 
       573 
     | 
    
         
            -
                    log_system_crit "error reloading  
     | 
| 
      
 617 
     | 
    
         
            +
                    log_system_crit "error reloading Logic file '#{@logic_file}':"
         
     | 
| 
       574 
618 
     | 
    
         
             
                    log_system_crit e
         
     | 
| 
       575 
     | 
    
         
            -
                    false
         
     | 
| 
       576 
619 
     | 
    
         
             
                  end
         
     | 
| 
       577 
620 
     | 
    
         
             
                end
         
     | 
| 
       578 
621 
     | 
    
         | 
    
        data/lib/oversip/errors.rb
    CHANGED
    
    
    
        data/lib/oversip/launcher.rb
    CHANGED
    
    | 
         @@ -418,7 +418,7 @@ module OverSIP::Launcher 
     | 
|
| 
       418 
418 
     | 
    
         
             
                end
         
     | 
| 
       419 
419 
     | 
    
         | 
| 
       420 
420 
     | 
    
         
             
                # Signals that must be ignored.
         
     | 
| 
       421 
     | 
    
         
            -
                ignore_signals = [:ALRM, :INT, :PIPE, :POLL, :PROF, : 
     | 
| 
      
 421 
     | 
    
         
            +
                ignore_signals = [:ALRM, :INT, :PIPE, :POLL, :PROF, :USR2, :WINCH]
         
     | 
| 
       422 
422 
     | 
    
         
             
                ignore_signals.each do |signal|
         
     | 
| 
       423 
423 
     | 
    
         
             
                  begin
         
     | 
| 
       424 
424 
     | 
    
         
             
                    trap signal do
         
     | 
| 
         @@ -429,11 +429,26 @@ module OverSIP::Launcher 
     | 
|
| 
       429 
429 
     | 
    
         
             
                  end
         
     | 
| 
       430 
430 
     | 
    
         
             
                end
         
     | 
| 
       431 
431 
     | 
    
         | 
| 
       432 
     | 
    
         
            -
                #  
     | 
| 
       433 
     | 
    
         
            -
                 
     | 
| 
      
 432 
     | 
    
         
            +
                # Special treatment for VTALRM signal (TODO: since it occurs too much).
         
     | 
| 
      
 433 
     | 
    
         
            +
                trap :VTALRM do
         
     | 
| 
      
 434 
     | 
    
         
            +
                end
         
     | 
| 
      
 435 
     | 
    
         
            +
             
     | 
| 
      
 436 
     | 
    
         
            +
                # Signal HUP reloads OverSIP system configuration.
         
     | 
| 
       434 
437 
     | 
    
         
             
                trap :HUP do
         
     | 
| 
       435 
     | 
    
         
            -
                   
     | 
| 
       436 
     | 
    
         
            -
                  ::OverSIP::Config. 
     | 
| 
      
 438 
     | 
    
         
            +
                  log_system_notice "HUP signal received, reloading configuration files..."
         
     | 
| 
      
 439 
     | 
    
         
            +
                  ::OverSIP::Config.system_reload
         
     | 
| 
      
 440 
     | 
    
         
            +
                end
         
     | 
| 
      
 441 
     | 
    
         
            +
             
     | 
| 
      
 442 
     | 
    
         
            +
                # Signal USR1 reloads custom code provided by the user.
         
     | 
| 
      
 443 
     | 
    
         
            +
                trap :USR1 do
         
     | 
| 
      
 444 
     | 
    
         
            +
                  log_system_notice "USR1 signal received, calling user provided OverSIP::SystemEvents.on_user_reload() callback..."
         
     | 
| 
      
 445 
     | 
    
         
            +
                  # Run the user provided on_started callback.
         
     | 
| 
      
 446 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 447 
     | 
    
         
            +
                    ::OverSIP::SystemEvents.on_user_reload
         
     | 
| 
      
 448 
     | 
    
         
            +
                  rescue ::Exception => e
         
     | 
| 
      
 449 
     | 
    
         
            +
                    log_system_crit "error calling user provided OverSIP::SystemEvents.on_user_reload() callback:"
         
     | 
| 
      
 450 
     | 
    
         
            +
                    log_system_crit e
         
     | 
| 
      
 451 
     | 
    
         
            +
                  end
         
     | 
| 
       437 
452 
     | 
    
         
             
                end
         
     | 
| 
       438 
453 
     | 
    
         | 
| 
       439 
454 
     | 
    
         
             
                # Signal CHLD is sent by syslogger process if it dies.
         
     | 
| 
         @@ -9,8 +9,6 @@ module OverSIP 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  @log_id ||= "ProxiesConfig"
         
     | 
| 
       10 
10 
     | 
    
         
             
                end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                @proxies = {}
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
12 
     | 
    
         
             
                @proxy_configuration = {
         
     | 
| 
       15 
13 
     | 
    
         
             
                  :do_loose_routing           => true,
         
     | 
| 
       16 
14 
     | 
    
         
             
                  :use_dns                    => true,
         
     | 
| 
         @@ -45,51 +43,53 @@ module OverSIP 
     | 
|
| 
       45 
43 
     | 
    
         
             
                  :tls_validation             => :boolean
         
     | 
| 
       46 
44 
     | 
    
         
             
                }
         
     | 
| 
       47 
45 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
                def self.load proxies_yaml
         
     | 
| 
       49 
     | 
    
         
            -
                  unless proxies_yaml.is_a? Hash
         
     | 
| 
       50 
     | 
    
         
            -
                    fatal "invalid proxies configuration file, it is not a collection"
         
     | 
| 
       51 
     | 
    
         
            -
                  end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 46 
     | 
    
         
            +
                def self.load proxies_yaml, reload=false
         
     | 
| 
       53 
47 
     | 
    
         
             
                  begin
         
     | 
| 
      
 48 
     | 
    
         
            +
                    unless proxies_yaml.is_a? ::Hash
         
     | 
| 
      
 49 
     | 
    
         
            +
                      raise "invalid proxies configuration file, it is not a collection"
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                    proxies = {}
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
       54 
54 
     | 
    
         
             
                    proxies_yaml.each do |proxy, conf|
         
     | 
| 
       55 
     | 
    
         
            -
                      unless proxy.is_a? String
         
     | 
| 
       56 
     | 
    
         
            -
                         
     | 
| 
      
 55 
     | 
    
         
            +
                      unless proxy.is_a? ::String
         
     | 
| 
      
 56 
     | 
    
         
            +
                        raise "proxy name is not a string (#{proxy.inspect})"
         
     | 
| 
       57 
57 
     | 
    
         
             
                      end
         
     | 
| 
       58 
58 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                       
     | 
| 
       60 
     | 
    
         
            -
                       
     | 
| 
       61 
     | 
    
         
            -
                         
     | 
| 
      
 59 
     | 
    
         
            +
                      proxies[proxy.to_sym] = @proxy_configuration.dup
         
     | 
| 
      
 60 
     | 
    
         
            +
                      proxies[proxy.to_sym].each do |parameter, default_value|
         
     | 
| 
      
 61 
     | 
    
         
            +
                        proxies[proxy.to_sym][parameter] = default_value.clone rescue default_value
         
     | 
| 
       62 
62 
     | 
    
         
             
                      end
         
     | 
| 
       63 
63 
     | 
    
         | 
| 
       64 
64 
     | 
    
         
             
                      PROXY_CONFIG_VALIDATIONS.each do |parameter, validations|
         
     | 
| 
       65 
65 
     | 
    
         
             
                        values = proxies_yaml[proxy][parameter.to_s]
         
     | 
| 
       66 
     | 
    
         
            -
                        validations = [ validations ]  unless validations.is_a?(Array)
         
     | 
| 
      
 66 
     | 
    
         
            +
                        validations = [ validations ]  unless validations.is_a?(::Array)
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
68 
     | 
    
         
             
                        if values == nil
         
     | 
| 
       69 
69 
     | 
    
         
             
                          if validations.include? :required
         
     | 
| 
       70 
     | 
    
         
            -
                             
     | 
| 
      
 70 
     | 
    
         
            +
                            raise "#{proxy}[#{parameter}] requires a value"
         
     | 
| 
       71 
71 
     | 
    
         
             
                          end
         
     | 
| 
       72 
72 
     | 
    
         
             
                          next
         
     | 
| 
       73 
73 
     | 
    
         
             
                        end
         
     | 
| 
       74 
74 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
                        if values.is_a? Array
         
     | 
| 
      
 75 
     | 
    
         
            +
                        if values.is_a? ::Array
         
     | 
| 
       76 
76 
     | 
    
         
             
                          unless validations.include? :multi_value
         
     | 
| 
       77 
     | 
    
         
            -
                             
     | 
| 
      
 77 
     | 
    
         
            +
                            raise "#{proxy}[#{parameter}] does not allow multiple values"
         
     | 
| 
       78 
78 
     | 
    
         
             
                          end
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
       80 
80 
     | 
    
         
             
                          if validations.include? :non_empty and values.empty?
         
     | 
| 
       81 
     | 
    
         
            -
                             
     | 
| 
      
 81 
     | 
    
         
            +
                            raise "#{proxy}[#{parameter}] does not allow empty values"
         
     | 
| 
       82 
82 
     | 
    
         
             
                          end
         
     | 
| 
       83 
83 
     | 
    
         
             
                        end
         
     | 
| 
       84 
84 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
                        values = ( values.is_a?(Array) ? values : [ values ] )
         
     | 
| 
      
 85 
     | 
    
         
            +
                        values = ( values.is_a?(::Array) ? values : [ values ] )
         
     | 
| 
       86 
86 
     | 
    
         | 
| 
       87 
87 
     | 
    
         
             
                        values.each do |value|
         
     | 
| 
       88 
88 
     | 
    
         
             
                          validations.each do |validation|
         
     | 
| 
       89 
89 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
                            if validation.is_a? Symbol
         
     | 
| 
      
 90 
     | 
    
         
            +
                            if validation.is_a? ::Symbol
         
     | 
| 
       91 
91 
     | 
    
         
             
                              args = []
         
     | 
| 
       92 
     | 
    
         
            -
                            elsif validation.is_a? Array
         
     | 
| 
      
 92 
     | 
    
         
            +
                            elsif validation.is_a? ::Array
         
     | 
| 
       93 
93 
     | 
    
         
             
                              args = validation[1..-1]
         
     | 
| 
       94 
94 
     | 
    
         
             
                              validation = validation[0]
         
     | 
| 
       95 
95 
     | 
    
         
             
                            end
         
     | 
| 
         @@ -97,24 +97,27 @@ module OverSIP 
     | 
|
| 
       97 
97 
     | 
    
         
             
                            next if [:required, :multi_value, :non_empty].include? validation
         
     | 
| 
       98 
98 
     | 
    
         | 
| 
       99 
99 
     | 
    
         
             
                            unless send validation, value, *args
         
     | 
| 
       100 
     | 
    
         
            -
                               
     | 
| 
      
 100 
     | 
    
         
            +
                              raise "#{proxy}[#{parameter}] has invalid value '#{::OverSIP::Config.humanize_value value}' (does not satisfy '#{validation}' validation requirement)"
         
     | 
| 
       101 
101 
     | 
    
         
             
                            end
         
     | 
| 
       102 
102 
     | 
    
         
             
                          end
         
     | 
| 
       103 
103 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
                           
     | 
| 
      
 104 
     | 
    
         
            +
                          proxies[proxy.to_sym][parameter] = ( validations.include?(:multi_value) ? values : values[0] )
         
     | 
| 
       105 
105 
     | 
    
         
             
                        end
         
     | 
| 
       106 
106 
     | 
    
         | 
| 
       107 
107 
     | 
    
         
             
                      end  # PROXY_CONFIG_VALIDATIONS[section].each
         
     | 
| 
       108 
108 
     | 
    
         
             
                    end  # proxies_yaml.each
         
     | 
| 
       109 
109 
     | 
    
         | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
                     
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
                     
     | 
| 
      
 110 
     | 
    
         
            +
                  rescue ::Exception => e
         
     | 
| 
      
 111 
     | 
    
         
            +
                    unless reload
         
     | 
| 
      
 112 
     | 
    
         
            +
                      fatal e.message
         
     | 
| 
      
 113 
     | 
    
         
            +
                    else
         
     | 
| 
      
 114 
     | 
    
         
            +
                      raise ::OverSIP::ConfigurationError, e.message
         
     | 
| 
      
 115 
     | 
    
         
            +
                    end
         
     | 
| 
       116 
116 
     | 
    
         
             
                  end
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
      
 118 
     | 
    
         
            +
                  @proxies = proxies
         
     | 
| 
      
 119 
     | 
    
         
            +
                  post_process
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
       118 
121 
     | 
    
         
             
                  ::OverSIP.proxies = @proxies
         
     | 
| 
       119 
122 
     | 
    
         
             
                end
         
     | 
| 
       120 
123 
     | 
    
         | 
    
        data/lib/oversip/version.rb
    CHANGED
    
    
| 
         @@ -3,7 +3,6 @@ module OverSIP::WebSocket 
     | 
|
| 
       3 
3 
     | 
    
         
             
              class TcpServer < ::EM::Connection
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                include ::OverSIP::Logger
         
     | 
| 
       6 
     | 
    
         
            -
                include ::OverSIP::WebSocket::Policy
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
7 
     | 
    
         
             
                # Max size (bytes) of the buffered data when receiving message headers
         
     | 
| 
       9 
8 
     | 
    
         
             
                # (avoid DoS attacks).
         
     | 
| 
         @@ -71,7 +70,7 @@ module OverSIP::WebSocket 
     | 
|
| 
       71 
70 
     | 
    
         | 
| 
       72 
71 
     | 
    
         
             
                  @ws_framing.tcp_closed  if @ws_framing
         
     | 
| 
       73 
72 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
                  if @ 
     | 
| 
      
 73 
     | 
    
         
            +
                  if @ws_handshake_done
         
     | 
| 
       75 
74 
     | 
    
         
             
                    begin
         
     | 
| 
       76 
75 
     | 
    
         
             
                      ::OverSIP::Events.on_websocket_connection_closed self
         
     | 
| 
       77 
76 
     | 
    
         
             
                    rescue ::Exception => e
         
     | 
| 
         @@ -209,19 +208,19 @@ module OverSIP::WebSocket 
     | 
|
| 
       209 
208 
     | 
    
         | 
| 
       210 
209 
     | 
    
         
             
                  # Check WebSocket policy.
         
     | 
| 
       211 
210 
     | 
    
         | 
| 
       212 
     | 
    
         
            -
                  unless check_hostport(@http_request.host, @http_request.port)
         
     | 
| 
      
 211 
     | 
    
         
            +
                  unless ::OverSIP::WebSocket::Policy.check_hostport(@http_request.host, @http_request.port)
         
     | 
| 
       213 
212 
     | 
    
         
             
                    log_system_notice "host/port policy not satisfied (host=#{@http_request.host.inspect}, port=#{@http_request.port.inspect}) => 403"
         
     | 
| 
       214 
213 
     | 
    
         
             
                    http_reject 403, "request host/port not satisfied"
         
     | 
| 
       215 
214 
     | 
    
         
             
                    return false
         
     | 
| 
       216 
215 
     | 
    
         
             
                  end
         
     | 
| 
       217 
216 
     | 
    
         | 
| 
       218 
     | 
    
         
            -
                  unless check_origin(@http_request.hdr_origin)
         
     | 
| 
      
 217 
     | 
    
         
            +
                  unless ::OverSIP::WebSocket::Policy.check_origin(@http_request.hdr_origin)
         
     | 
| 
       219 
218 
     | 
    
         
             
                    log_system_notice "'Origin' policy not satisfied (origin=#{@http_request.hdr_origin.inspect}) => 403"
         
     | 
| 
       220 
219 
     | 
    
         
             
                    http_reject 403, "request 'Origin' not satisfied"
         
     | 
| 
       221 
220 
     | 
    
         
             
                    return false
         
     | 
| 
       222 
221 
     | 
    
         
             
                  end
         
     | 
| 
       223 
222 
     | 
    
         | 
| 
       224 
     | 
    
         
            -
                  unless check_request_uri(@http_request.uri_path, @http_request.uri_query)
         
     | 
| 
      
 223 
     | 
    
         
            +
                  unless ::OverSIP::WebSocket::Policy.check_request_uri(@http_request.uri_path, @http_request.uri_query)
         
     | 
| 
       225 
224 
     | 
    
         
             
                    log_system_notice "request URI path/query not satisfied (path=#{@http_request.uri_path.inspect}, query=#{@http_request.uri_query.inspect}) => 403"
         
     | 
| 
       226 
225 
     | 
    
         
             
                    http_reject 403, "request URI path/query not satisfied"
         
     | 
| 
       227 
226 
     | 
    
         
             
                    return false
         
     | 
| 
         @@ -242,7 +241,7 @@ module OverSIP::WebSocket 
     | 
|
| 
       242 
241 
     | 
    
         
             
                    return false
         
     | 
| 
       243 
242 
     | 
    
         
             
                  end
         
     | 
| 
       244 
243 
     | 
    
         | 
| 
       245 
     | 
    
         
            -
                  # The user provided callback could have reject the WS connection 
     | 
| 
      
 244 
     | 
    
         
            +
                  # The user provided callback could have reject the WS connection, so
         
     | 
| 
       246 
245 
     | 
    
         
             
                  # check it not to reply a 101 after the reply sent by the user.
         
     | 
| 
       247 
246 
     | 
    
         
             
                  if @state == :new_websocket_connection_callback
         
     | 
| 
       248 
247 
     | 
    
         
             
                    @state = :accept_ws_handshake
         
     | 
| 
         @@ -276,6 +275,7 @@ module OverSIP::WebSocket 
     | 
|
| 
       276 
275 
     | 
    
         
             
                  @ws_framing = ::OverSIP::WebSocket::WsFraming.new(self, @buffer)
         
     | 
| 
       277 
276 
     | 
    
         
             
                  @ws_framing.ws_app = @ws_app_klass.new(self, @ws_framing)
         
     | 
| 
       278 
277 
     | 
    
         | 
| 
      
 278 
     | 
    
         
            +
                  @ws_handshake_done = true
         
     | 
| 
       279 
279 
     | 
    
         
             
                  @state = :websocket_frames
         
     | 
| 
       280 
280 
     | 
    
         
             
                  true
         
     | 
| 
       281 
281 
     | 
    
         
             
                end
         
     | 
| 
         @@ -575,7 +575,7 @@ module OverSIP::WebSocket 
     | 
|
| 
       575 
575 
     | 
    
         
             
                  unless in_reply_to_close
         
     | 
| 
       576 
576 
     | 
    
         
             
                    # Let's some time for the client to send us a close frame (it will
         
     | 
| 
       577 
577 
     | 
    
         
             
                    # be ignored anyway) before closing the TCP connection.
         
     | 
| 
       578 
     | 
    
         
            -
                    EM.add_timer(0.2) do
         
     | 
| 
      
 578 
     | 
    
         
            +
                    ::EM.add_timer(0.2) do
         
     | 
| 
       579 
579 
     | 
    
         
             
                      @connection.close_connection_after_writing
         
     | 
| 
       580 
580 
     | 
    
         
             
                    end
         
     | 
| 
       581 
581 
     | 
    
         
             
                  else
         
     | 
    
        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.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.7.beta1
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 6
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -13,7 +13,7 @@ date: 2012-08-02 00:00:00.000000000 Z 
     | 
|
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: eventmachine-le
         
     | 
| 
       16 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: &19620160 !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: *19620160
         
     | 
| 
       25 
25 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       26 
26 
     | 
    
         
             
              name: iobuffer
         
     | 
| 
       27 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 27 
     | 
    
         
            +
              requirement: &19619700 !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: *19619700
         
     | 
| 
       36 
36 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       37 
37 
     | 
    
         
             
              name: em-posixmq
         
     | 
| 
       38 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 38 
     | 
    
         
            +
              requirement: &19619240 !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: *19619240
         
     | 
| 
       47 
47 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       48 
48 
     | 
    
         
             
              name: em-udns
         
     | 
| 
       49 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 49 
     | 
    
         
            +
              requirement: &19618780 !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: *19618780
         
     | 
| 
       58 
58 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       59 
59 
     | 
    
         
             
              name: escape_utils
         
     | 
| 
       60 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 60 
     | 
    
         
            +
              requirement: &19618320 !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: *19618320
         
     | 
| 
       69 
69 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       70 
70 
     | 
    
         
             
              name: term-ansicolor
         
     | 
| 
       71 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: &19617940 !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: *19617940
         
     | 
| 
       80 
80 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       81 
81 
     | 
    
         
             
              name: posix-spawn
         
     | 
| 
       82 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 82 
     | 
    
         
            +
              requirement: &19617400 !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: *19617400
         
     | 
| 
       91 
91 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       92 
92 
     | 
    
         
             
              name: rake
         
     | 
| 
       93 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 93 
     | 
    
         
            +
              requirement: &19616900 !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: *19616900
         
     | 
| 
       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
         
     |