forked from Fudge/gltail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relating to main issue Fudge#21, adding in a tshark source. Currently…
… only parses DNS requests
- Loading branch information
Showing
5 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'pty' | ||
module GlTail | ||
module Source | ||
|
||
class TShark < Base | ||
config_attribute :source, "The type of Source" | ||
|
||
def init | ||
@lines = [] | ||
Thread.new do #start thread | ||
begin | ||
PTY.spawn( "tshark" ) do |stdin, stdout, pid| | ||
begin | ||
# Do stuff with the output here. Just printing to show it works | ||
stdin.each { |line| | ||
if(line.include?('DNS Standard query A')) | ||
@lines.push(line) | ||
end | ||
} | ||
rescue Errno::EIO | ||
# puts "Errno:EIO error, but this probably just means " + | ||
# "that the process has finished giving output" | ||
end | ||
end | ||
rescue PTY::ChildExited | ||
puts "Tshark has exited!" | ||
end | ||
end #end thread | ||
end | ||
|
||
def process | ||
unless @lines.length == 0 | ||
parser.parse(@lines[0]) | ||
@lines.delete_at(0) | ||
end | ||
end | ||
|
||
def update | ||
end | ||
|
||
end | ||
end | ||
end |