rack-auth-ip 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (20) hide show
  1. data/ChangeLog +12 -0
  2. data/Rakefile +6 -1
  3. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html +1 -1
  4. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html +1 -1
  5. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html +1 -1
  6. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html +1 -1
  7. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html +1 -1
  8. data/doc/output/coverage/-Library-Ruby-Gems-gems-ipaddr_list-0_0_2-lib-ipaddr_list_rb.html +794 -0
  9. data/doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html +1 -1
  10. data/doc/output/coverage/index.html +33 -195
  11. data/doc/output/coverage/lib-rack-auth-ip_rb.html +63 -62
  12. data/lib/rack/auth/ip.rb +4 -3
  13. metadata +12 -9
  14. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-drb_rb.html +0 -2373
  15. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-eq_rb.html +0 -626
  16. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-invokemethod_rb.html +0 -646
  17. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-ipaddr_rb.html +0 -1139
  18. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-pp_rb.html +0 -1257
  19. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-prettyprint_rb.html +0 -1506
  20. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-timeout_rb.html +0 -715
@@ -553,7 +553,7 @@ span.run100 {
553
553
  </style>
554
554
  </head>
555
555
  <body><h3>C0 code coverage information</h3>
556
- <p>Generated on Sat Jun 28 12:48:55 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
556
+ <p>Generated on Sat Sep 13 07:41:03 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
557
557
  </p>
558
558
  <hr/>
559
559
  <pre><span class='marked0'>Code reported as executed by Ruby looks like this...
@@ -148,7 +148,7 @@ table.report tr.dark {
148
148
  </script>
149
149
  </head>
150
150
  <body><h3>C0 code coverage information</h3>
151
- <p>Generated on Sat Jun 28 12:48:53 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
151
+ <p>Generated on Sat Sep 13 07:41:00 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
152
152
  </p>
153
153
  <hr/>
154
154
  <table class='report'><thead><tr><td class='heading'>Name</td>
@@ -159,24 +159,24 @@ table.report tr.dark {
159
159
  </tr>
160
160
  </thead>
161
161
  <tbody><tr class='light'><td>TOTAL</td>
162
- <td class='lines_total'><tt>6940</tt>
162
+ <td class='lines_total'><tt>3133</tt>
163
163
  </td>
164
- <td class='lines_code'><tt>4082</tt>
164
+ <td class='lines_code'><tt>1724</tt>
165
165
  </td>
166
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>41.8%</tt>
166
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>37.4%</tt>
167
167
  &nbsp;</td>
168
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='42'/>
169
- <td class='uncovered' width='58'/>
168
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='37'/>
169
+ <td class='uncovered' width='63'/>
170
170
  </tr>
171
171
  </table>
172
172
  </td>
173
173
  </tr>
174
174
  </table>
175
175
  </td>
176
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>15.7%</tt>
176
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>14.9%</tt>
177
177
  &nbsp;</td>
178
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='16'/>
179
- <td class='uncovered' width='84'/>
178
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='15'/>
179
+ <td class='uncovered' width='85'/>
180
180
  </tr>
181
181
  </table>
182
182
  </td>
@@ -319,188 +319,26 @@ table.report tr.dark {
319
319
  </table>
320
320
  </td>
321
321
  </tr>
322
- <tr class='light'><td><a href='-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html'>/Library/Ruby/Gems/gems/rcov-0.8.1.2.0/lib/rcov.rb</a>
323
- </td>
324
- <td class='lines_total'><tt>988</tt>
325
- </td>
326
- <td class='lines_code'><tt>602</tt>
327
- </td>
328
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>3.3%</tt>
329
- &nbsp;</td>
330
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='3'/>
331
- <td class='uncovered' width='97'/>
332
- </tr>
333
- </table>
334
- </td>
335
- </tr>
336
- </table>
337
- </td>
338
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>2.8%</tt>
339
- &nbsp;</td>
340
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='3'/>
341
- <td class='uncovered' width='97'/>
342
- </tr>
343
- </table>
344
- </td>
345
- </tr>
346
- </table>
347
- </td>
348
- </tr>
349
- <tr class='dark'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-drb_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/drb/drb.rb</a>
322
+ <tr class='light'><td><a href='-Library-Ruby-Gems-gems-ipaddr_list-0_0_2-lib-ipaddr_list_rb.html'>/Library/Ruby/Gems/gems/ipaddr_list-0.0.2/lib/ipaddr_list.rb</a>
350
323
  </td>
351
- <td class='lines_total'><tt>1763</tt>
324
+ <td class='lines_total'><tt>184</tt>
352
325
  </td>
353
- <td class='lines_code'><tt>861</tt>
326
+ <td class='lines_code'><tt>138</tt>
354
327
  </td>
355
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>61.9%</tt>
328
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>64.1%</tt>
356
329
  &nbsp;</td>
357
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='62'/>
358
- <td class='uncovered' width='38'/>
330
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='64'/>
331
+ <td class='uncovered' width='36'/>
359
332
  </tr>
360
333
  </table>
361
334
  </td>
362
335
  </tr>
363
336
  </table>
364
337
  </td>
365
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>24.0%</tt>
338
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>52.9%</tt>
366
339
  &nbsp;</td>
367
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='24'/>
368
- <td class='uncovered' width='76'/>
369
- </tr>
370
- </table>
371
- </td>
372
- </tr>
373
- </table>
374
- </td>
375
- </tr>
376
- <tr class='light'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-eq_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/drb/eq.rb</a>
377
- </td>
378
- <td class='lines_total'><tt>16</tt>
379
- </td>
380
- <td class='lines_code'><tt>13</tt>
381
- </td>
382
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>68.8%</tt>
383
- &nbsp;</td>
384
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='69'/>
385
- <td class='uncovered' width='31'/>
386
- </tr>
387
- </table>
388
- </td>
389
- </tr>
390
- </table>
391
- </td>
392
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>61.5%</tt>
393
- &nbsp;</td>
394
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='62'/>
395
- <td class='uncovered' width='38'/>
396
- </tr>
397
- </table>
398
- </td>
399
- </tr>
400
- </table>
401
- </td>
402
- </tr>
403
- <tr class='dark'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-invokemethod_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/drb/invokemethod.rb</a>
404
- </td>
405
- <td class='lines_total'><tt>36</tt>
406
- </td>
407
- <td class='lines_code'><tt>33</tt>
408
- </td>
409
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>22.2%</tt>
410
- &nbsp;</td>
411
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='22'/>
412
- <td class='uncovered' width='78'/>
413
- </tr>
414
- </table>
415
- </td>
416
- </tr>
417
- </table>
418
- </td>
419
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>15.2%</tt>
420
- &nbsp;</td>
421
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='15'/>
422
- <td class='uncovered' width='85'/>
423
- </tr>
424
- </table>
425
- </td>
426
- </tr>
427
- </table>
428
- </td>
429
- </tr>
430
- <tr class='light'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-ipaddr_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/ipaddr.rb</a>
431
- </td>
432
- <td class='lines_total'><tt>529</tt>
433
- </td>
434
- <td class='lines_code'><tt>389</tt>
435
- </td>
436
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>47.4%</tt>
437
- &nbsp;</td>
438
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='47'/>
439
- <td class='uncovered' width='53'/>
440
- </tr>
441
- </table>
442
- </td>
443
- </tr>
444
- </table>
445
- </td>
446
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>31.1%</tt>
447
- &nbsp;</td>
448
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='31'/>
449
- <td class='uncovered' width='69'/>
450
- </tr>
451
- </table>
452
- </td>
453
- </tr>
454
- </table>
455
- </td>
456
- </tr>
457
- <tr class='dark'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-pp_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/pp.rb</a>
458
- </td>
459
- <td class='lines_total'><tt>647</tt>
460
- </td>
461
- <td class='lines_code'><tt>452</tt>
462
- </td>
463
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>34.8%</tt>
464
- &nbsp;</td>
465
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='35'/>
466
- <td class='uncovered' width='65'/>
467
- </tr>
468
- </table>
469
- </td>
470
- </tr>
471
- </table>
472
- </td>
473
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>13.7%</tt>
474
- &nbsp;</td>
475
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='14'/>
476
- <td class='uncovered' width='86'/>
477
- </tr>
478
- </table>
479
- </td>
480
- </tr>
481
- </table>
482
- </td>
483
- </tr>
484
- <tr class='light'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-prettyprint_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/prettyprint.rb</a>
485
- </td>
486
- <td class='lines_total'><tt>896</tt>
487
- </td>
488
- <td class='lines_code'><tt>706</tt>
489
- </td>
490
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>21.0%</tt>
491
- &nbsp;</td>
492
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='21'/>
493
- <td class='uncovered' width='79'/>
494
- </tr>
495
- </table>
496
- </td>
497
- </tr>
498
- </table>
499
- </td>
500
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>6.5%</tt>
501
- &nbsp;</td>
502
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='7'/>
503
- <td class='uncovered' width='93'/>
340
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='53'/>
341
+ <td class='uncovered' width='47'/>
504
342
  </tr>
505
343
  </table>
506
344
  </td>
@@ -508,26 +346,26 @@ table.report tr.dark {
508
346
  </table>
509
347
  </td>
510
348
  </tr>
511
- <tr class='dark'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-timeout_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb</a>
349
+ <tr class='dark'><td><a href='-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html'>/Library/Ruby/Gems/gems/rcov-0.8.1.2.0/lib/rcov.rb</a>
512
350
  </td>
513
- <td class='lines_total'><tt>105</tt>
351
+ <td class='lines_total'><tt>988</tt>
514
352
  </td>
515
- <td class='lines_code'><tt>43</tt>
353
+ <td class='lines_code'><tt>602</tt>
516
354
  </td>
517
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>67.6%</tt>
355
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>3.3%</tt>
518
356
  &nbsp;</td>
519
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='68'/>
520
- <td class='uncovered' width='32'/>
357
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='3'/>
358
+ <td class='uncovered' width='97'/>
521
359
  </tr>
522
360
  </table>
523
361
  </td>
524
362
  </tr>
525
363
  </table>
526
364
  </td>
527
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>23.3%</tt>
365
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>2.8%</tt>
528
366
  &nbsp;</td>
529
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='23'/>
530
- <td class='uncovered' width='77'/>
367
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='3'/>
368
+ <td class='uncovered' width='97'/>
531
369
  </tr>
532
370
  </table>
533
371
  </td>
@@ -537,11 +375,11 @@ table.report tr.dark {
537
375
  </tr>
538
376
  <tr class='light'><td><a href='lib-rack-auth-ip_rb.html'>lib/rack/auth/ip.rb</a>
539
377
  </td>
540
- <td class='lines_total'><tt>56</tt>
378
+ <td class='lines_total'><tt>57</tt>
541
379
  </td>
542
- <td class='lines_code'><tt>39</tt>
380
+ <td class='lines_code'><tt>40</tt>
543
381
  </td>
544
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>94.6%</tt>
382
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>94.7%</tt>
545
383
  &nbsp;</td>
546
384
  <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='95'/>
547
385
  <td class='uncovered' width='5'/>
@@ -551,10 +389,10 @@ table.report tr.dark {
551
389
  </tr>
552
390
  </table>
553
391
  </td>
554
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>92.3%</tt>
392
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>92.5%</tt>
555
393
  &nbsp;</td>
556
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='92'/>
557
- <td class='uncovered' width='8'/>
394
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='93'/>
395
+ <td class='uncovered' width='7'/>
558
396
  </tr>
559
397
  </table>
560
398
  </td>
@@ -553,7 +553,7 @@ span.run100 {
553
553
  </style>
554
554
  </head>
555
555
  <body><h3>C0 code coverage information</h3>
556
- <p>Generated on Sat Jun 28 12:48:58 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
556
+ <p>Generated on Sat Sep 13 07:41:03 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
557
557
  </p>
558
558
  <hr/>
559
559
  <pre><span class='marked0'>Code reported as executed by Ruby looks like this...
@@ -571,11 +571,11 @@ span.run100 {
571
571
  </thead>
572
572
  <tbody><tr class='light'><td><a href='lib-rack-auth-ip_rb.html'>lib/rack/auth/ip.rb</a>
573
573
  </td>
574
- <td class='lines_total'><tt>56</tt>
574
+ <td class='lines_total'><tt>57</tt>
575
575
  </td>
576
- <td class='lines_code'><tt>39</tt>
576
+ <td class='lines_code'><tt>40</tt>
577
577
  </td>
578
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>94.6%</tt>
578
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>94.7%</tt>
579
579
  &nbsp;</td>
580
580
  <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='95'/>
581
581
  <td class='uncovered' width='5'/>
@@ -585,10 +585,10 @@ span.run100 {
585
585
  </tr>
586
586
  </table>
587
587
  </td>
588
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>92.3%</tt>
588
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>92.5%</tt>
589
589
  &nbsp;</td>
590
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='92'/>
591
- <td class='uncovered' width='8'/>
590
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='93'/>
591
+ <td class='uncovered' width='7'/>
592
592
  </tr>
593
593
  </table>
594
594
  </td>
@@ -599,61 +599,62 @@ span.run100 {
599
599
  </tbody>
600
600
  </table>
601
601
  <pre><span class="marked1"><a name="line1"></a> 1 require 'ipaddr'
602
- </span><span class="marked0"><a name="line2"></a> 2 module Rack
603
- </span><span class="marked1"><a name="line3"></a> 3 module Auth
604
- </span><span class="inferred0"><a name="line4"></a> 4 # in your_app.ru
605
- </span><span class="inferred1"><a name="line5"></a> 5 # require 'rack/auth/ip'
606
- </span><span class="inferred0"><a name="line6"></a> 6 # # allow access only local network
607
- </span><span class="inferred1"><a name="line7"></a> 7 # use Rack::Auth::IP, %w( 192.168.0.0/24 )
608
- </span><span class="inferred0"><a name="line8"></a> 8
609
- </span><span class="inferred1"><a name="line9"></a> 9 # # you can use block
610
- </span><span class="inferred0"><a name="line10"></a>10 # # ip is IPAddr instance.
611
- </span><span class="inferred1"><a name="line11"></a>11 # use Rack::Auth::IP do |ip|
612
- </span><span class="inferred0"><a name="line12"></a>12 # Your::Model::IP.count({ :ip =&gt; ip.to_s }) != 0
613
- </span><span class="inferred1"><a name="line13"></a>13 # end
614
- </span><span class="marked0"><a name="line14"></a>14 class IP
615
- </span><span class="marked1"><a name="line15"></a>15 module Util
616
- </span><span class="inferred0"><a name="line16"></a>16 # consider using reverse proxy
617
- </span><span class="marked1"><a name="line17"></a>17 def detect_ip env
618
- </span><span class="marked0"><a name="line18"></a>18 if env['HTTP_X_FORWARDED_FOR']
619
- </span><span class="marked1"><a name="line19"></a>19 env['HTTP_X_FORWARDED_FOR'].split(',').pop
620
- </span><span class="inferred0"><a name="line20"></a>20 else
621
- </span><span class="marked1"><a name="line21"></a>21 env[&quot;REMOTE_ADDR&quot;]
622
- </span><span class="inferred0"><a name="line22"></a>22 end
623
- </span><span class="marked1"><a name="line23"></a>23 end
624
- </span><span class="inferred0"><a name="line24"></a>24
625
- </span><span class="marked1"><a name="line25"></a>25 module_function :detect_ip
626
- </span><span class="inferred0"><a name="line26"></a>26 end
627
- </span><span class="marked1"><a name="line27"></a>27 include Util
628
- </span><span class="inferred0"><a name="line28"></a>28
629
- </span><span class="marked1"><a name="line29"></a>29 def initialize app, ip_list=nil, &amp;block
630
- </span><span class="marked0"><a name="line30"></a>30 @app = app
631
- </span><span class="marked1"><a name="line31"></a>31 @ip_list = ip_list
632
- </span><span class="inferred0"><a name="line32"></a>32
633
- </span><span class="marked1"><a name="line33"></a>33 if @ip_list
634
- </span><span class="marked0"><a name="line34"></a>34 @ip_list = @ip_list.map {|ip| IPAddr.new(ip) }
635
- </span><span class="inferred1"><a name="line35"></a>35 end
636
- </span><span class="inferred0"><a name="line36"></a>36
637
- </span><span class="marked1"><a name="line37"></a>37 @cond = block
638
- </span><span class="inferred0"><a name="line38"></a>38 end
639
- </span><span class="inferred1"><a name="line39"></a>39
640
- </span><span class="marked0"><a name="line40"></a>40 def call env
641
- </span><span class="marked1"><a name="line41"></a>41 req_ip = IPAddr.new(detect_ip(env))
642
- </span><span class="inferred0"><a name="line42"></a>42
643
- </span><span class="marked1"><a name="line43"></a>43 if @ip_list
644
- </span><span class="marked0"><a name="line44"></a>44 if @ip_list.find {|ip| ip.include? req_ip }
645
- </span><span class="marked1"><a name="line45"></a>45 return @app.call(env)
646
- </span><span class="inferred0"><a name="line46"></a>46 end
647
- </span><span class="inferred1"><a name="line47"></a>47 else
648
- </span><span class="marked0"><a name="line48"></a>48 if @cond &amp;&amp; @cond.call(req_ip)
649
- </span><span class="uncovered1"><a name="line49"></a>49 return @app.call(env)
650
- </span><span class="uncovered0"><a name="line50"></a>50 end
651
- </span><span class="uncovered1"><a name="line51"></a>51 end
652
- </span><span class="marked0"><a name="line52"></a>52 return [403, {'Content-Type' =&gt; 'text/plain' }, 'Forbidden' ]
653
- </span><span class="inferred1"><a name="line53"></a>53 end
654
- </span><span class="inferred0"><a name="line54"></a>54 end
655
- </span><span class="inferred1"><a name="line55"></a>55 end
656
- </span><span class="inferred0"><a name="line56"></a>56 end
602
+ </span><span class="marked0"><a name="line2"></a> 2 require 'ipaddr_list'
603
+ </span><span class="marked1"><a name="line3"></a> 3 module Rack
604
+ </span><span class="marked0"><a name="line4"></a> 4 module Auth
605
+ </span><span class="inferred1"><a name="line5"></a> 5 # in your_app.ru
606
+ </span><span class="inferred0"><a name="line6"></a> 6 # require 'rack/auth/ip'
607
+ </span><span class="inferred1"><a name="line7"></a> 7 # # allow access only local network
608
+ </span><span class="inferred0"><a name="line8"></a> 8 # use Rack::Auth::IP, %w( 192.168.0.0/24 )
609
+ </span><span class="inferred1"><a name="line9"></a> 9
610
+ </span><span class="inferred0"><a name="line10"></a>10 # # you can use block
611
+ </span><span class="inferred1"><a name="line11"></a>11 # # ip is IPAddr instance.
612
+ </span><span class="inferred0"><a name="line12"></a>12 # use Rack::Auth::IP do |ip|
613
+ </span><span class="inferred1"><a name="line13"></a>13 # Your::Model::IP.count({ :ip =&gt; ip.to_s }) != 0
614
+ </span><span class="inferred0"><a name="line14"></a>14 # end
615
+ </span><span class="marked1"><a name="line15"></a>15 class IP
616
+ </span><span class="marked0"><a name="line16"></a>16 module Util
617
+ </span><span class="inferred1"><a name="line17"></a>17 # consider using reverse proxy
618
+ </span><span class="marked0"><a name="line18"></a>18 def detect_ip env
619
+ </span><span class="marked1"><a name="line19"></a>19 if env['HTTP_X_FORWARDED_FOR']
620
+ </span><span class="marked0"><a name="line20"></a>20 env['HTTP_X_FORWARDED_FOR'].split(',').pop
621
+ </span><span class="inferred1"><a name="line21"></a>21 else
622
+ </span><span class="marked0"><a name="line22"></a>22 env[&quot;REMOTE_ADDR&quot;]
623
+ </span><span class="inferred1"><a name="line23"></a>23 end
624
+ </span><span class="marked0"><a name="line24"></a>24 end
625
+ </span><span class="inferred1"><a name="line25"></a>25
626
+ </span><span class="marked0"><a name="line26"></a>26 module_function :detect_ip
627
+ </span><span class="inferred1"><a name="line27"></a>27 end
628
+ </span><span class="marked0"><a name="line28"></a>28 include Util
629
+ </span><span class="inferred1"><a name="line29"></a>29
630
+ </span><span class="marked0"><a name="line30"></a>30 def initialize app, ip_list=nil, &amp;block
631
+ </span><span class="marked1"><a name="line31"></a>31 @app = app
632
+ </span><span class="marked0"><a name="line32"></a>32 @ip_list = ip_list
633
+ </span><span class="inferred1"><a name="line33"></a>33
634
+ </span><span class="marked0"><a name="line34"></a>34 if @ip_list &amp;&amp; @ip_list.size &gt; 0
635
+ </span><span class="marked1"><a name="line35"></a>35 @ip_list = IPAddrList.new(@ip_list)
636
+ </span><span class="inferred0"><a name="line36"></a>36 end
637
+ </span><span class="inferred1"><a name="line37"></a>37
638
+ </span><span class="marked0"><a name="line38"></a>38 @cond = block
639
+ </span><span class="inferred1"><a name="line39"></a>39 end
640
+ </span><span class="inferred0"><a name="line40"></a>40
641
+ </span><span class="marked1"><a name="line41"></a>41 def call env
642
+ </span><span class="marked0"><a name="line42"></a>42 req_ip = IPAddr.new(detect_ip(env))
643
+ </span><span class="inferred1"><a name="line43"></a>43
644
+ </span><span class="marked0"><a name="line44"></a>44 if @ip_list
645
+ </span><span class="marked1"><a name="line45"></a>45 if @ip_list.include?(req_ip)
646
+ </span><span class="marked0"><a name="line46"></a>46 return @app.call(env)
647
+ </span><span class="inferred1"><a name="line47"></a>47 end
648
+ </span><span class="inferred0"><a name="line48"></a>48 else
649
+ </span><span class="marked1"><a name="line49"></a>49 if @cond &amp;&amp; @cond.call(req_ip)
650
+ </span><span class="uncovered0"><a name="line50"></a>50 return @app.call(env)
651
+ </span><span class="uncovered1"><a name="line51"></a>51 end
652
+ </span><span class="uncovered0"><a name="line52"></a>52 end
653
+ </span><span class="marked1"><a name="line53"></a>53 return [403, {'Content-Type' =&gt; 'text/plain' }, 'Forbidden' ]
654
+ </span><span class="inferred0"><a name="line54"></a>54 end
655
+ </span><span class="inferred1"><a name="line55"></a>55 end
656
+ </span><span class="inferred0"><a name="line56"></a>56 end
657
+ </span><span class="inferred1"><a name="line57"></a>57 end
657
658
  </span></pre><hr/>
658
659
  <p>Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'>rcov code coverage analysis tool for Ruby</a>
659
660
  version 0.8.1.2.</p>