Ver Fonte

allow for internal or external ip search

Chris Mague há 7 anos atrás
pai
commit
bfae0e21fb
2 ficheiros alterados com 5 adições e 2 exclusões
  1. 5 1
      lib/neoinfra/nodes.rb
  2. 0 1
      web/controllers/search.rb

+ 5 - 1
lib/neoinfra/nodes.rb

@@ -37,7 +37,11 @@ module NeoInfra
     end
 
     def search_nodes_by_ip(ip)
-      display_node(Node.where(ip: ip).first.node_id)
+      if Node.where(ip: ip).length > 0
+	display_node(Node.where(ip: ip).first.node_id)
+      else
+	display_node(Node.where(public_ip: ip).first.node_id)
+      end
     end
 
     def search_nodes_by_node_id(node_id)

+ 0 - 1
web/controllers/search.rb

@@ -16,7 +16,6 @@ class Search < Sinatra::Base
   set :views, File.join(File.dirname(__FILE__), '..', '/views')
 
   post '/all' do
-    puts params.to_s
     if params['search'] =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/
       n = NeoInfra::Nodes.new
       respond_to do |wants|