links 0.20.0 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/links +16 -3
  2. data/lib/links/api.rb +13 -2
  3. data/lib/links/version.rb +1 -1
  4. metadata +15 -15
data/bin/links CHANGED
@@ -13,6 +13,7 @@ opts = GetoptLong.new(
13
13
  trap("INT") { puts '['+'INTERRUPTED'.color(:red)+']'; exit -1 }
14
14
  list=[]
15
15
  robots=false
16
+ bulk=false
16
17
 
17
18
  opts.each do |opt, arg|
18
19
  case opt
@@ -29,6 +30,7 @@ opts.each do |opt, arg|
29
30
  when '--robots'
30
31
  robots=true
31
32
  when '--bulk'
33
+ bulk=true
32
34
  if ! File.exists?(arg)
33
35
  puts "links: file not found (#{arg})".color(:red)
34
36
  exit 1
@@ -57,10 +59,21 @@ if robots
57
59
  end
58
60
 
59
61
  list.each do |l|
60
- print "#{l}:".color(:white)
61
- if robots
62
- code = Links::Api.human('http://'+target+l)
62
+ if robots or bulk
63
+ if ! l.start_with? '/'
64
+ l = '/'+l.chomp
65
+ end
66
+ if ! target.start_with? 'http://' and ! target.start_with? 'https://'
67
+ #defaulting to HTTP when no protocol has been supplied
68
+ target = "http://"+target
69
+ end
70
+
71
+ #puts "T: #{target}"
72
+ #puts "L: #{l}"
73
+ print "#{target}#{l}:".color(:white)
74
+ code = Links::Api.human(target+l)
63
75
  else
76
+ print "#{l}:".color(:white)
64
77
  code = Links::Api.human(l)
65
78
  end
66
79
  case code
data/lib/links/api.rb CHANGED
@@ -6,7 +6,7 @@ module Links
6
6
 
7
7
  def self.code(url)
8
8
  res = Links::Api.get(url)
9
- res.code ||= -1
9
+ (res.nil?)? -1 : res.code
10
10
  end
11
11
 
12
12
  def self.links(url)
@@ -67,6 +67,8 @@ module Links
67
67
  return "Closed"
68
68
  when 403
69
69
  return "Forbidden"
70
+ when -1
71
+ return "No answer"
70
72
  else
71
73
  return "Broken"
72
74
  end
@@ -75,7 +77,16 @@ module Links
75
77
  private
76
78
  def self.get(url)
77
79
  begin
78
- Net::HTTP.get_response(URI(url))
80
+ uri = URI(url)
81
+ if uri.scheme == 'http'
82
+ res = Net::HTTP.get_response(URI(url))
83
+ else
84
+ request=Net::HTTP.new(uri.host, uri.port)
85
+ request.use_ssl=true
86
+ request.verify_mode = OpenSSL::SSL::VERIFY_NONE
87
+ res = request.get(uri.request_uri)
88
+ end
89
+ return res
79
90
  rescue
80
91
  return nil
81
92
  end
data/lib/links/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Links
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 20
4
+ MINOR = 30
5
5
  PATCH = 0
6
6
  BUILD = ''
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: links
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.30.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-26 00:00:00.000000000 Z
12
+ date: 2012-02-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70178993924920 !ruby/object:Gem::Requirement
16
+ requirement: &70331248053140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70178993924920
24
+ version_requirements: *70331248053140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70178998811440 !ruby/object:Gem::Requirement
27
+ requirement: &70331248052400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70178998811440
35
+ version_requirements: *70331248052400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: nokogiri
38
- requirement: &70178998810960 !ruby/object:Gem::Requirement
38
+ requirement: &70331248051700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70178998810960
46
+ version_requirements: *70331248051700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rainbow
49
- requirement: &70178998810280 !ruby/object:Gem::Requirement
49
+ requirement: &70331248050860 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70178998810280
57
+ version_requirements: *70331248050860
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &70178998809620 !ruby/object:Gem::Requirement
60
+ requirement: &70331248050260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70178998809620
68
+ version_requirements: *70331248050260
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rainbow
71
- requirement: &70178998808840 !ruby/object:Gem::Requirement
71
+ requirement: &70331248049560 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70178998808840
79
+ version_requirements: *70331248049560
80
80
  description: During the first stage of a security test, it's useful to enumerate website
81
81
  urls without making too much noise. Links can help in this using robots.txt or link
82
82
  in a web page telling you the website contents.
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project: links
123
- rubygems_version: 1.8.17
123
+ rubygems_version: 1.8.10
124
124
  signing_key:
125
125
  specification_version: 3
126
126
  summary: Fetch, discover and crawl what's available in a website.