Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions plugins/network/app/controllers/network_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@
# you may find current contact information at www.novell.com
#++

require 'socket'
def getCurrentIP
ip, orig, Socket.do_not_reverse_lookup = "", Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
ip = s.addr.last
end
ensure Socket.do_not_reverse_lookup = orig
return ip
end

class NetworkController < ApplicationController

before_filter :login_required
Expand Down Expand Up @@ -95,13 +84,7 @@ def index
@bootproto = ifc.bootproto
@bootproto = STATIC_BOOT_ID if @bootproto.blank?

if @bootproto == STATIC_BOOT_ID
ipaddr = ifc.ipaddr
else
ipaddr = "/"
end

@ip, @netmask = ipaddr.split "/"
@ip, @netmask = @bootproto == STATIC_BOOT_ID ? ifc.ipaddr.split("/"): ["", ""]
# when detect PREFIXLEN with leading "/"
if ifc.bootproto == STATIC_BOOT_ID && NETMASK_RANGE.include?(@netmask.to_i)
@netmask = "/"+@netmask
Expand All @@ -113,8 +96,9 @@ def index
@name = hn.name
@domain = hn.domain

@dhcp_ip = getCurrentIP;

if @bootproto == "dhcp"
@actual_ip, @actual_netmask = ifc.actual_ipaddr.split("/")
end
@dhcp_hostname_enabled = hn.attributes.include?("dhcp_hostname")
@dhcp_hostname = @dhcp_hostname_enabled && hn.dhcp_hostname=="1"
@nameservers = dns.nameservers
Expand Down
14 changes: 8 additions & 6 deletions plugins/network/app/views/network/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,14 @@
<%=text_field_tag :searchdomains, @searchdomains.join(" "), :class=>"searchdomains", :disabled => write_disabled %>
</div>

<div id="ip_sticker" class="right">
<span>
<span style="display:block; background:#eee; padding:2px 3px; font-size:11px;"><%=_("Current IP address (DHCP)")%></span>
<span style="font-size:20px; padding:5px 0px;"><%= @dhcp_ip %></span>
</span>
</div>
<% if @actual_ip %>
<div id="ip_sticker" class="right">
<span>
<span style="display:block; background:#eee; padding:2px 3px; font-size:11px;"><%=_("Current IP address (DHCP)")%></span>
<span style="font-size:20px; padding:5px 0px;"><%= @actual_ip %></span>
</span>
</div>
<% end %>

<div class="row manual">
<label><%=_("Change hostname by DHCP")%></label>
Expand Down