mqsink 0.0.8 → 0.0.10
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.
- checksums.yaml +4 -4
 - data/lib/mqsink/server.rb +30 -34
 - metadata +4 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 34efedf476cf60f8caa7a0088a9845d1ce2d2c61
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a3190f599967e03613965561d12f6ba27b47ad28
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 16f4ece22161c72062f696548de8a2caf57128e45e92a1bdefeb65d01c173a348ce9794f3baeb5bbf733d17ea75ddf7a69e473ddd42edf3bda64898d77909a88
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 78c7079b74480514d1f1e7af2109dd13f7c44615a7afc2bba0d2ef089c4c549b4fecfc7772c4f62083cec7d17e1684e7415a417aef8bd718fb6489df0114a8fc
         
     | 
    
        data/lib/mqsink/server.rb
    CHANGED
    
    | 
         @@ -2,23 +2,22 @@ module MQSink 
     | 
|
| 
       2 
2 
     | 
    
         
             
             class Server
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
              def initialize cfg, debug
         
     | 
| 
       5 
     | 
    
         
            -
               @localhost 
     | 
| 
       6 
     | 
    
         
            -
               @localport 
     | 
| 
       7 
     | 
    
         
            -
               @firewall 
     | 
| 
       8 
     | 
    
         
            -
               @fw_file 
     | 
| 
       9 
     | 
    
         
            -
               @mode 
     | 
| 
       10 
     | 
    
         
            -
               @mqserver 
     | 
| 
       11 
     | 
    
         
            -
               @classifiers 
     | 
| 
       12 
     | 
    
         
            -
               @static_queue 
     | 
| 
       13 
     | 
    
         
            -
               @debug 
     | 
| 
       14 
     | 
    
         
            -
               @acl 
     | 
| 
       15 
     | 
    
         
            -
               @acl_refresh 
     | 
| 
      
 5 
     | 
    
         
            +
               @localhost   	= cfg['localhost']
         
     | 
| 
      
 6 
     | 
    
         
            +
               @localport   	= cfg['localport']
         
     | 
| 
      
 7 
     | 
    
         
            +
               @firewall    	= cfg['firewall']
         
     | 
| 
      
 8 
     | 
    
         
            +
               @fw_file     	= cfg['fw_file']
         
     | 
| 
      
 9 
     | 
    
         
            +
               @mode        	= cfg['mode']
         
     | 
| 
      
 10 
     | 
    
         
            +
               @mqserver    	= cfg['amqp_server']
         
     | 
| 
      
 11 
     | 
    
         
            +
               @classifiers		= cfg['classifiers']
         
     | 
| 
      
 12 
     | 
    
         
            +
               @static_queue 	= cfg['static_queue']
         
     | 
| 
      
 13 
     | 
    
         
            +
               @debug		= debug
         
     | 
| 
      
 14 
     | 
    
         
            +
               @acl   		= build_acl @fw_file
         
     | 
| 
      
 15 
     | 
    
         
            +
               @acl_refresh 	= cfg['fw_refresh']
         
     | 
| 
       16 
16 
     | 
    
         
             
               listen
         
     | 
| 
       17 
17 
     | 
    
         
             
              end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
              def build_acl fw_file
         
     | 
| 
       20 
     | 
    
         
            -
                
     | 
| 
       21 
     | 
    
         
            -
               @acl         = open(fw_file).readlines
         
     | 
| 
      
 20 
     | 
    
         
            +
               @acl = open(fw_file).readlines
         
     | 
| 
       22 
21 
     | 
    
         
             
               return @acl
         
     | 
| 
       23 
22 
     | 
    
         
             
              end
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
         @@ -33,34 +32,31 @@ module MQSink 
     | 
|
| 
       33 
32 
     | 
    
         
             
                   r, w, e = IO.select([@sock], nil, nil)
         
     | 
| 
       34 
33 
     | 
    
         
             
                   if r[0]
         
     | 
| 
       35 
34 
     | 
    
         
             
                     buffer, sockaddr = @sock.recvfrom_nonblock(1500)
         
     | 
| 
       36 
     | 
    
         
            -
                      
     | 
| 
       37 
     | 
    
         
            -
                     @queue << new_buff
         
     | 
| 
      
 35 
     | 
    
         
            +
                     @queue << [ sockaddr[3], buffer ]
         
     | 
| 
       38 
36 
     | 
    
         
             
                   end
         
     | 
| 
       39 
37 
     | 
    
         
             
                 end
         
     | 
| 
       40 
38 
     | 
    
         
             
               end
         
     | 
| 
       41 
39 
     | 
    
         
             
               consumer = Thread.new do
         
     | 
| 
       42 
40 
     | 
    
         
             
                 while true do
         
     | 
| 
       43 
     | 
    
         
            -
                    
     | 
| 
       44 
     | 
    
         
            -
                   puts "+ mqsink [debug]: rx_buffer length = #{@queue.length}" if @debug == 1 and  
     | 
| 
       45 
     | 
    
         
            -
                    
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                     lookup = acl.lookup
         
     | 
| 
       56 
     | 
    
         
            -
                   else # do not apply ACL when firewall is disabled #
         
     | 
| 
      
 41 
     | 
    
         
            +
                   rip, buffer = @queue.pop
         
     | 
| 
      
 42 
     | 
    
         
            +
                   puts "+ mqsink [debug]: rx_buffer length = #{@queue.length}" if @debug == 1 and buffer != nil
         
     | 
| 
      
 43 
     | 
    
         
            +
                   case @firewall
         
     | 
| 
      
 44 
     | 
    
         
            +
                     when 'on'
         
     | 
| 
      
 45 
     | 
    
         
            +
                       buffer != nil
         
     | 
| 
      
 46 
     | 
    
         
            +
                       @acl = build_acl @fw_file if count == 5 and @acl_refresh == 'on'
         
     | 
| 
      
 47 
     | 
    
         
            +
                       count = 0 if count == 5 and @acl_refresh == 'on'
         
     | 
| 
      
 48 
     | 
    
         
            +
                       count += 1
         
     | 
| 
      
 49 
     | 
    
         
            +
                       puts "+ mqsink [debug]: verifying authorization for client -> #{rip} .." if @debug == 1
         
     | 
| 
      
 50 
     | 
    
         
            +
                       acl = MQSink::ACL.new rip, @acl
         
     | 
| 
      
 51 
     | 
    
         
            +
                       lookup = acl.lookup
         
     | 
| 
      
 52 
     | 
    
         
            +
                   else
         
     | 
| 
       57 
53 
     | 
    
         
             
                     lookup = 0
         
     | 
| 
       58 
54 
     | 
    
         
             
                   end
         
     | 
| 
       59 
     | 
    
         
            -
                    
     | 
| 
       60 
     | 
    
         
            -
                      
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
      
 55 
     | 
    
         
            +
                   case lookup
         
     | 
| 
      
 56 
     | 
    
         
            +
                     when 0
         
     | 
| 
      
 57 
     | 
    
         
            +
                       puts "+ mqsink [debug]: buffer accepted -> #{buffer}" if @debug == 1
         
     | 
| 
      
 58 
     | 
    
         
            +
                       relay = MQSink::AMQP.new buffer, rip, @mode, @mqserver, @classifiers, @static_queue, @debug
         
     | 
| 
      
 59 
     | 
    
         
            +
                       relay.publish
         
     | 
| 
       64 
60 
     | 
    
         
             
                   else
         
     | 
| 
       65 
61 
     | 
    
         
             
                     puts "+ mqsink [debug]: client is not authorized .. ignoring buffer .." if @debug == 1
         
     | 
| 
       66 
62 
     | 
    
         
             
                   end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,18 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: mqsink
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.10
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Samer Abdel-Hafez
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-04-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: a smart and lightweight udp to amqp translator
         
     | 
| 
       14 
14 
     | 
    
         
             
            email:
         
     | 
| 
       15 
     | 
    
         
            -
            - sam@ 
     | 
| 
      
 15 
     | 
    
         
            +
            - sam@arahant.net
         
     | 
| 
       16 
16 
     | 
    
         
             
            executables:
         
     | 
| 
       17 
17 
     | 
    
         
             
            - mqsinkd
         
     | 
| 
       18 
18 
     | 
    
         
             
            extensions: []
         
     | 
| 
         @@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       42 
42 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       43 
43 
     | 
    
         
             
            requirements: []
         
     | 
| 
       44 
44 
     | 
    
         
             
            rubyforge_project: mqsink
         
     | 
| 
       45 
     | 
    
         
            -
            rubygems_version: 2.0. 
     | 
| 
      
 45 
     | 
    
         
            +
            rubygems_version: 2.0.14
         
     | 
| 
       46 
46 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       47 
47 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       48 
48 
     | 
    
         
             
            summary: udp to amqp bridge
         
     |