Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for Ruby 1.9.1

- Rewrite to use latest net-ssh
- Update to 1.9.1 syntax
  • Loading branch information...
commit a2d8b32c7908a432bba4adc30144463cc8b530f8 1 parent d37f880
Erlend Simonsen Fudge authored
13 lib/gl_tail.rb
View
@@ -5,7 +5,7 @@
#
module GlTail
- VERSION = '0.1.7'
+ VERSION = '0.1.8'
end
begin
@@ -38,12 +38,12 @@ module GlTail
end
begin
- gem 'net-ssh', '< 1.2'
+ gem 'net-ssh'
require 'net/ssh'
rescue LoadError
puts "Missing gem net-ssh."
puts "Ubuntu:"
- puts " sudo gem install -y net-ssh -v 1.1.4 -r"
+ puts " sudo gem install -y net-ssh -r"
exit
end
@@ -56,16 +56,19 @@ module GlTail
exit
end
+$PHYSICS = true
+
begin
require 'chipmunk'
rescue LoadError
- puts "Missing Chipmunk C extension."
+ puts "Missing Chipmunk C extension. Disabling physics..."
puts "Ubuntu:"
puts " cd vendor/Chipmunk-4.1.0/ruby"
puts " ruby extconf.rb"
puts " sudo make install"
puts " cd ../../../"
- exit
+
+ $PHYSICS = false
end
$:.unshift(File.dirname(__FILE__)) # this should be obsolete once its a gem
32 lib/gl_tail/element.rb
View
@@ -326,21 +326,23 @@ def render(engine, options = { })
bs = (size + 0.0005) * engine.screen.window_width * engine.screen.aspect
- a.body = CP::Body.new(0.0001, 0.0001)
- a.body.m = bs * 5.5
- a.body.p = CP::Vec2.new(a.x * engine.screen.window_width * engine.screen.aspect, a.y * engine.screen.window_height)
- if a.x < 0.0
- a.body.v = CP::Vec2.new(250,0)
- else
- a.body.v = CP::Vec2.new(-250,0)
- end
- a.shape = CP::Shape::Circle.new(a.body, bs, CP::Vec2.new(0.0, 0.0))
- a.shape.e = 0.9
- a.shape.u = 1
-
- engine.space.add_body(a.body)
- engine.space.add_shape(a.shape)
- end
+ if $PHYSICS
+ a.body = CP::Body.new(0.0001, 0.0001)
+ a.body.m = bs * 5.5
+ a.body.p = CP::Vec2.new(a.x * engine.screen.window_width * engine.screen.aspect, a.y * engine.screen.window_height)
+ if a.x < 0.0
+ a.body.v = CP::Vec2.new(250,0)
+ else
+ a.body.v = CP::Vec2.new(-250,0)
+ end
+ a.shape = CP::Shape::Circle.new(a.body, bs, CP::Vec2.new(0.0, 0.0))
+ a.shape.e = 0.9
+ a.shape.u = 1
+
+ engine.space.add_body(a.body)
+ engine.space.add_shape(a.shape)
+ end
+ end
end
@delete = []
33 lib/gl_tail/engine.rb
View
@@ -41,7 +41,7 @@ def draw
@render_time ||= 0
@t = Time.new
- @space.step(1.0/60.0)
+ @space.step(1.0/60.0) if $PHYSICS
glClear(GL_COLOR_BUFFER_BIT);
# glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -141,7 +141,7 @@ def timer(value)
# Change view angle, exit upon ESC
def key(k, x, y)
- case k
+ case k.ord
when 27 # Escape
exit
when 32 # Space
@@ -171,7 +171,7 @@ def key(k, x, y)
@config.screen.mode = 1 - @config.screen.mode.to_i
BlobStore.empty
end
- puts "Keypress: #{k}"
+ puts "Keypress: #{k.ord}"
glutPostRedisplay()
end
@@ -211,12 +211,12 @@ def reshape(width, height)
BlobStore.empty # Flush cached objects to recreate with correct size
- unless defined?(@static_body)
+ if !defined?(@static_body) && $PHYSICS
puts "Adding static shapes.."
@static_body = CP::Body.new(Float::MAX, Float::MAX)
end
- if @config.screen.bounce
+ if @config.screen.bounce && $PHYSICS
if @static_shapes && @static_shapes.size > 0
0.upto(3) do |i|
@space.remove_static_shape(@static_shapes[i])
@@ -255,7 +255,7 @@ def reshape(width, height)
shape.u = 1
@space.add_static_shape(shape)
@static_shapes[3] = shape
- elsif @static_shapes && @static_shapes.size > 0
+ elsif @static_shapes && @static_shapes.size > 0
0.upto(3) do |i|
@space.remove_static_shape(@static_shapes[i])
end
@@ -289,11 +289,14 @@ def initialize(config)
@frames = 0
@t0 = 0
@left_left = @left_right = @right_left = @right_right = 0.0 # TODO: Why is draw called before these are set by reshape?
- @space = CP::Space.new
- @space.damping = 0.89
- @space.gravity = CP::Vec2.new(0, -85)
- @space.iterations = 2
- @space.elastic_iterations = 0
+
+ if $PHYSICS
+ @space = CP::Space.new
+ @space.damping = 0.89
+ @space.gravity = CP::Vec2.new(0, -85)
+ @space.iterations = 2
+ @space.elastic_iterations = 0
+ end
end
def start
@@ -312,13 +315,15 @@ def start
glutMouseFunc(method(:mouse).to_proc)
glutMotionFunc(method(:motion).to_proc)
-# glutIdleFunc(method(:idle).to_proc)
+# glutIdleFunc(method(:idle).to_proc)
glutTimerFunc(14, method(:timer).to_proc, 0)
# glLightfv(GL_LIGHT0, GL_POSITION, [5.0, 5.0, 0.0, 0.0])
- glLightfv(GL_LIGHT0, GL_AMBIENT, [0,0,0,1])
- glLightModel(GL_LIGHT_MODEL_AMBIENT, [0.1,0.1,0.1,1]);
+# glLightfv(GL_LIGHT0, GL_AMBIENT, [0,0,0,1])
+
+# glLightModel(GL_LIGHT_MODEL_AMBIENT, [0.1,0.1,0.1,1]);
+
# glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
# glLightModel(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
8 lib/gl_tail/font_store.rb
View
@@ -20,7 +20,7 @@ def self.generate_textures
# Add missing pixels to increase height by 3
32.upto(255) do |c|
- @font[c] += @font[c] + [0,0,0].pack("C*") * 24
+ @font[c] += @font[c] + ([0,0,0].pack("C*") * 24)
end
0.upto(196607) do |i|
@@ -35,9 +35,9 @@ def self.generate_textures
offset = row * 256*16*3 + col*8*3
0.upto(15) do |y|
0.upto(7) do |x|
- font_data[offset + y*256*3 + x*3 +0] = @font[c][y*8*3 + x*3 + 0]
- font_data[offset + y*256*3 + x*3 +1] = @font[c][y*8*3 + x*3 + 1]
- font_data[offset + y*256*3 + x*3 +2] = @font[c][y*8*3 + x*3 + 2]
+ font_data[offset + y*256*3 + x*3 +0] = @font[c][y*8*3 + x*3 + 0].ord
+ font_data[offset + y*256*3 + x*3 +1] = @font[c][y*8*3 + x*3 + 1].ord
+ font_data[offset + y*256*3 + x*3 +2] = @font[c][y*8*3 + x*3 + 2].ord
end
end
18 lib/gl_tail/parsers/named.rb
View
@@ -41,16 +41,16 @@ def parse( line )
# you can use size to distinguish request types
def set_type_size(type)
set_size = case type
- when "A" : 10
- when "PTR" : 90
- when "AAAA" : 70
- when "TXT" : 60
- when "SOA" : 50
- when "MX" : 40
- when "SRV" : 30
- when "ANY" : 100
+ when "A" then 10
+ when "PTR" then 90
+ when "AAAA" then 70
+ when "TXT" then 60
+ when "SOA" then 50
+ when "MX" then 40
+ when "SRV" then 30
+ when "ANY" then 100
else
150
end
end
-end
+end
40 lib/gl_tail/parsers/pfsense.rb
View
@@ -10,13 +10,13 @@
# Available Blocks
#action: block|pass
#rule: Rule number matched
-#proto: carp|icmp|tcp|udp|ah|igmp|esp|gre you get the idea..
+#ipprotocol: carp|icmp|tcp|udp|ah|igmp|esp|gre you get the idea..
#int: This will be the actual interface (fxp0, vlan2, em1, etc) as the 'friendly' name is not put in the logs.
-#srchost: source host/IP
-#srcport: source port
-#dsthost: destination host/IP
-#dstport: destination port
-#srcdst: source host and port > destination host and port
+#sourcehost: source host/IP
+#sourceport: source port
+#destinationhost: destination host/IP
+#destinationport: destination port
+#sourcedestination: source host and port > destination host and port
class PFSenseParser < Parser
require 'date'
@@ -64,7 +64,7 @@ def getport(thisport)
def parse( line )
if line.include?('(match)') and not line.include?('ICMPv6') and not line.include?('icmp6')
- proto = "TCP"
+ ipprotocol = "TCP"
_, ltime, host, rule, action, int, details, src, dst = /(.*)\s(.*)\spf:\s.*\srule\s(.*)\(match\)\:\s(.*)\s\w+\son\s(\w+)\:\s\((.*)\)\s(.*)\s>\s(.*)\:\s.*/.match(line).to_a
# Assume the server is in the same time zone as the viewing client.
@@ -84,9 +84,9 @@ def parse( line )
# Debug
# printf("Adding entry from %s hours, %s minutes ago\n", hours.to_s, minutes.to_s)
- srchost, srcport = getipandport(src)
+ sourcehost, sourceport = getipandport(src)
- dsthost, dstport = getipandport(dst)
+ destinationhost, destinationport = getipandport(dst)
rule = rule.split('/')[0]
@@ -95,26 +95,26 @@ def parse( line )
add_activity(:block => 'Flags', :name => flags)
end
if details.include?('proto ')
- _, proto = /.*\sproto\s(.*)\s\(/.match(details).to_a
+ _, ipprotocol = /.*\sproto\s(.*)\s\(/.match(details).to_a
elsif details.include?('proto: ')
- _, proto = /.*\sproto:\s(.*)\s\(/.match(details).to_a
+ _, ipprotocol = /.*\sproto:\s(.*)\s\(/.match(details).to_a
elsif details.include?('next-header ')
- _, proto = /.*\snext-header\s(.*)\s\(/.match(details).to_a
+ _, ipprotocol = /.*\snext-header\s(.*)\s\(/.match(details).to_a
end
add_activity(:block => 'action', :name => action.to_s)
add_activity(:block => 'int', :name => host.to_s + ":" + int.to_s)
add_activity(:block => 'rule', :name => rule.to_s)
- add_activity(:block => 'proto', :name => proto.to_s)
- add_activity(:block => 'srchost', :name => srchost.to_s)
- if srcport != "none"
- add_activity(:block => 'srcport', :name => srcport.to_s)
+ add_activity(:block => 'ipprotocol', :name => ipprotocol.to_s)
+ add_activity(:block => 'sourcehost', :name => sourechost.to_s)
+ if sourceport != "none"
+ add_activity(:block => 'sourceport', :name => sourceport.to_s)
end
- add_activity(:block => 'dsthost', :name => dsthost.to_s, :type => 5)
- if dstport != "none"
- add_activity(:block => 'dstport', :name => dstport.to_s, :type => 5)
+ add_activity(:block => 'destinationhost', :name => destinationhost.to_s, :type => 5)
+ if destinationport != "none"
+ add_activity(:block => 'destinationport', :name => destinationport.to_s, :type => 5)
end
- add_activity(:block => 'srcdst', :name => srchost.to_s + getport(srcport) + " > " + dsthost.to_s + getport(dstport) + " (" + proto.to_s + ")")
+ add_activity(:block => 'sourcedestination', :name => sourcehost.to_s + getport(sourceport) + " > " + destinationhost.to_s + getport(destinationport) + " (" + ipprotocol.to_s + ")")
else
# Debug
# printf("Not adding entry from %s hours, %s minutes ago\n", hours.to_s, minutes.to_s)
4 lib/gl_tail/parsers/squid.rb
View
@@ -16,8 +16,8 @@ def parse( line )
add_activity(:block => 'hosts', :name => host, :size => size)
add_activity(:block => 'types', :name => method, :size => size) if method
_, site = /http:\/\/(.+?)\/.+/.match(uri).to_a
- if site:
- add_activity(:block => 'sites', :name => site, :size => size)
+ if site
+ add_activity(:block => 'sites', :name => site, :size => size)
end
end
end
30 lib/gl_tail/sources/ssh.rb
View
@@ -46,27 +46,27 @@ def init
# FIXME: add support for multiple files (eg. write files accessor)
do_tail(files, command)
- @session.connection.process
+ @session.process(0)
end
def process
- @session.connection.process(true)
+ @session.process(0)
end
def update
- @channels.each { |ch| ch.connection.ping! }
+ @channels.each { |ch| ch.process }
end
def parse_line(data)
- @buffer.gsub(/\r\n/,"\n").gsub(/\n/, "\n\n").each("") do |line|
+ @buffer.split("\n").each() do |line|
- unless line.include? "\n\n"
- @buffer = "#{line}"
- next
- end
+# unless line.include? "\n"
+# @buffer = "#{line}"
+# next
+# end
- line.gsub!(/\n\n/, "\n")
- line.gsub!(/\n\n/, "\n")
+# line.gsub!(/\n\n/, "\n")
+# line.gsub!(/\n\n/, "\n")
puts "#{host}[#{user}]: #{line}" if $DBG > 0
@@ -81,18 +81,14 @@ def do_tail( file, command )
puts "Channel opened on #{@session.host}...\n" if($VRB > 0 || $DBG > 0)
@buffer = ""
- channel.request_pty :want_reply => true
+# channel.request_pty :want_reply => true
channel.on_data do |ch, data|
@buffer << data
parse_line(data)
end
- channel.on_success do |ch|
- channel.exec "#{command} #{file} "
- end
-
- channel.on_failure do |ch|
+ channel.on_open_failed do |ch|
ch.close
end
@@ -104,6 +100,8 @@ def do_tail( file, command )
ch[:closed] = true
end
+ channel.exec "#{command} #{file} "
+
puts "Pushing #{host}\n" if($VRB > 0 || $DBG > 0)
@channels.push(channel)
end
Please sign in to comment.
Something went wrong with that request. Please try again.