Top Level Namespace

Defined Under Namespace

Modules: Shadowserver

Instance Method Summary collapse

Instance Method Details

#lookup(item) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'bin/shadowserver_asn', line 6

def lookup(item)
	if item =~ /^AS(\d+)$/i
		Shadowserver::ASN.prefix($1.to_i)
	elsif item =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
		case $mode
		when 'origin'
			Shadowserver::ASN.origin(item)
		when 'peer'
			Shadowserver::ASN.peer(item)
		else
			"Unknown argument type: #{item}"
		end
	end
end

#usageObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'bin/shadowserver_asn', line 21

def usage
	puts "Usage: #{$0} [-h|-p|-o] [<ip or asn>] [<ip or asn> ...]"
	puts "-h usage information"
	puts "-p display peering information"
	puts "-o display origin information"
	puts
	puts "If no arguments are provided, then the tool reads from standard input."
	puts "If an ASN is provided, then the prefixes are listed"
	puts "Examples"
	puts "  #{$0} -p 4.2.2.5"
	puts "  #{$0} -o 4.2.2.5"
	puts "  #{$0} AS2637"
	exit
end