added regex for netmask

minor changes in language file
This commit is contained in:
lars 2007-01-30 09:12:54 +00:00
parent 14188be2ab
commit b789fec8ad
3 changed files with 39 additions and 24 deletions

View file

@ -5,14 +5,16 @@
<fieldset> <fieldset>
<legend><?cs var:html_escape(Lang.Plugins.network.Title.IP) ?></legend> <legend><?cs var:html_escape(Lang.Plugins.network.Title.IP) ?></legend>
<?cs call:print_form_header("static", "network") ?> <?cs call:print_form_header("network_address", "network") ?>
<?cs call:show_help(Lang.Plugins.network.Help.Network) ?> <?cs call:show_help(Lang.Plugins.network.Help.Network) ?>
<table> <table>
<tr><td> <tr><td>
<?cs var:html_escape(Lang.Plugins.network.Text.IP) ?>: <?cs var:html_escape(Lang.Plugins.network.Text.IP) ?>:
</td><td> </td><td>
<!-- maybe display the used network interface? <!-- maybe display the used network interface?
but users will not really know what this is about
admins will know anyway, which interface it is (because of the IP)
<tr><td> <tr><td>
<?cs var:html_escape(Lang.Plugins.network.Interface) ?>: <?cs var:html_escape(Lang.Plugins.network.Interface) ?>:
</td><td> </td><td>
@ -30,19 +32,20 @@
<tr><td> <tr><td>
<?cs var:html_escape(Lang.Plugins.network.Text.NM) ?>: <?cs var:html_escape(Lang.Plugins.network.Text.NM) ?>:
</td><td> </td><td>
<input class="ipnum" type="text" tabindex="1" name="nm1" size="3" id="nm" <input class="ipnum" type="text" tabindex="5" name="nm1" size="3" id="nm"
value="<?cs var:Data.Plugins.network.nm.oc1 value="<?cs var:Data.Plugins.network.nm.oc1
?>" />.<input class="ipnum" type="text" tabindex="2" name="nm2" size="3" ?>" />.<input class="ipnum" type="text" tabindex="6" name="nm2" size="3"
value="<?cs var:Data.Plugins.network.nm.oc2 value="<?cs var:Data.Plugins.network.nm.oc2
?>" />.<input class="ipnum" type="text" tabindex="3" name="nm3" size="3" ?>" />.<input class="ipnum" type="text" tabindex="7" name="nm3" size="3"
value="<?cs var:Data.Plugins.network.nm.oc3 value="<?cs var:Data.Plugins.network.nm.oc3
?>" />.<input class="ipnum" type="text" tabindex="4" name="nm4" size="3" ?>" />.<input class="ipnum" type="text" tabindex="8" name="nm4" size="3"
value="<?cs var:Data.Plugins.network.nm.oc4 ?>" /> value="<?cs var:Data.Plugins.network.nm.oc4 ?>" />
</td></tr><tr><td> </td></tr><tr><td>
</table> </table>
<p> <p>
<input type="hidden" name="store" value="set_ip" /> <input type="hidden" name="store" value="set_ip" />
<button type="submit"><?cs var:html_escape(Lang.Plugins.network.Button.Network) ?></button> <button type="submit" tabindex="9"><?cs
var:html_escape(Lang.Plugins.network.Button.Network) ?></button>
</p> </p>
</form> </form>
</fieldset> </fieldset>
@ -50,26 +53,27 @@
<fieldset> <fieldset>
<legend><?cs var:html_escape(Lang.Plugins.network.Title.GW) ?></legend> <legend><?cs var:html_escape(Lang.Plugins.network.Title.GW) ?></legend>
<?cs call:print_form_header("static", "network") ?> <?cs call:print_form_header("network_gateway", "network") ?>
<?cs call:show_help(Lang.Plugins.network.Help.Gateway) ?> <?cs call:show_help(Lang.Plugins.network.Help.Gateway) ?>
<table> <table>
<tr><td> <tr><td>
<?cs var:html_escape(Lang.Plugins.network.Text.GW) ?>: <?cs var:html_escape(Lang.Plugins.network.Text.GW) ?>:
</td><td> </td><td>
<input class="ipnum" type="text" tabindex="1" name="ip1" size="3" id="ip" <input class="ipnum" type="text" tabindex="20" name="ip1" size="3" id="ip"
value="<?cs var:Data.Plugins.network.gw.oc1 value="<?cs var:Data.Plugins.network.gw.oc1
?>" />.<input class="ipnum" type="text" tabindex="2" name="ip2" size="3" ?>" />.<input class="ipnum" type="text" tabindex="21" name="ip2" size="3"
value="<?cs var:Data.Plugins.network.gw.oc2 value="<?cs var:Data.Plugins.network.gw.oc2
?>" />.<input class="ipnum" type="text" tabindex="3" name="ip3" size="3" ?>" />.<input class="ipnum" type="text" tabindex="22" name="ip3" size="3"
value="<?cs var:Data.Plugins.network.gw.oc3 value="<?cs var:Data.Plugins.network.gw.oc3
?>" />.<input class="ipnum" type="text" tabindex="4" name="ip4" size="3" ?>" />.<input class="ipnum" type="text" tabindex="23" name="ip4" size="3"
value="<?cs var:Data.Plugins.network.gw.oc4 ?>" /> value="<?cs var:Data.Plugins.network.gw.oc4 ?>" />
</td></tr> </td></tr>
</table> </table>
<p> <p>
<input type="hidden" name="store" value="set_gateway" /> <input type="hidden" name="store" value="set_gateway" />
<button type="submit"><?cs var:html_escape(Lang.Plugins.network.Button.Gateway) ?></button> <button type="submit" tabindex="24"><?cs
var:html_escape(Lang.Plugins.network.Button.Gateway) ?></button>
</p> </p>
</form> </form>

View file

@ -32,15 +32,15 @@ WarningMessage {
} }
InvalidServerIP { InvalidServerIP {
Title = Invalid value Title = Invalid value
Text = The server address is not a valid number. Text = The server address is not valid.
} }
InvalidNetmaskIP { InvalidNetmask {
Title = Invalid value Title = Invalid value
Text = The netmask address is not a valid number. Text = The netmask is not valid.
} }
InvalidGatewayIP { InvalidGatewayIP {
Title = Invalid value Title = Invalid value
Text = The gateway address is not a valid number. Text = The gateway address is not valid.
} }
} }
@ -61,6 +61,12 @@ EnvironmentWarning {
Text = The 'ifconfig' program is not installed. Please ask the administrator of the CryptoBox server to install it. Text = The 'ifconfig' program is not installed. Please ask the administrator of the CryptoBox server to install it.
} }
MissingProgramIfconfig {
Title = Missing program
Text = The 'ifconfig' program is not installed. Please ask the administrator of the CryptoBox server to configure it properly.
}
MissingProgramRoute { MissingProgramRoute {
Title = Missing program Title = Missing program
Text = The 'route' program is not installed. Please ask the administrator of the CryptoBox server to configure it properly. Text = The 'route' program is not installed. Please ask the administrator of the CryptoBox server to configure it properly.

View file

@ -74,7 +74,7 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
if self.__IP_is_valid(nm1, nm2, nm3, nm4): if self.__IP_is_valid(nm1, nm2, nm3, nm4):
new_nm = "%d.%d.%d.%d" % (int(nm1), int(nm2), int(nm3), int(nm4)) new_nm = "%d.%d.%d.%d" % (int(nm1), int(nm2), int(nm3), int(nm4))
else: else:
self.hdf["Data.Warning"] = "Plugins.network.InvalidNetmaskIP" self.hdf["Data.Warning"] = "Plugins.network.InvalidNetmask"
self.__prepare_form_data() self.__prepare_form_data()
return "form_network" return "form_network"
if self.__set_ip(new_ip, new_nm): if self.__set_ip(new_ip, new_nm):
@ -90,7 +90,7 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
self.__prepare_form_data() self.__prepare_form_data()
return "empty" return "empty"
else: else:
self.cbox.log.warn("failed to change IP address to: %s" % new_ip) self.cbox.log.warn("Failed to change IP address to: %s" % new_ip)
self.hdf["Data.Warning"] = "Plugins.network.Failure" self.hdf["Data.Warning"] = "Plugins.network.Failure"
self.__prepare_form_data() self.__prepare_form_data()
return "form_network" return "form_network"
@ -107,7 +107,7 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
self.hdf["Data.Success"] = "Plugins.network.GWChanged" self.hdf["Data.Success"] = "Plugins.network.GWChanged"
else: else:
self.cbox.log.warn("failed to change gateway address to: %s" % new_ip) self.cbox.log.warn("Failed to change gateway address to: %s" % new_ip)
self.hdf["Data.Warning"] = "Plugins.network.Failure" self.hdf["Data.Warning"] = "Plugins.network.Failure"
self.__prepare_form_data() self.__prepare_form_data()
return "form_network" return "form_network"
@ -139,7 +139,7 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
""" """
warnings = [] warnings = []
if not os.path.isfile(self.root_action.IFCONFIG_BIN): if not os.path.isfile(self.root_action.IFCONFIG_BIN):
warnings.append((55, "MissingProgramIfconfig")) warnings.append((55, "Plugins.%s.MissingProgramIfconfig" % self.get_name()))
if not os.path.isfile(self.root_action.GWCONFIG_BIN): if not os.path.isfile(self.root_action.GWCONFIG_BIN):
warnings.append((52, "Plugins.%s.MissingProgramRoute" % self.get_name())) warnings.append((52, "Plugins.%s.MissingProgramRoute" % self.get_name()))
return warnings return warnings
@ -171,6 +171,7 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
self.hdf[self.hdf_prefix + "nm.oc3"] = oc3 self.hdf[self.hdf_prefix + "nm.oc3"] = oc3
self.hdf[self.hdf_prefix + "nm.oc4"] = oc4 self.hdf[self.hdf_prefix + "nm.oc4"] = oc4
def __get_current_ip(self, type="ip"): def __get_current_ip(self, type="ip"):
"""Retrieve the current IP. """Retrieve the current IP.
""" """
@ -196,11 +197,15 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
elif type == "nm": elif type == "nm":
##TODO: Lars please leave a regex note for fetching the ##TODO: Lars please leave a regex note for fetching the
## netmask with ifconfig ## netmask with ifconfig
#match = re.search(r'inet [\w]+:(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\s', stdout) match = re.search(r'inet [\w]+:.*Mask:(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\s', stdout)
return ("L", "A", "3", "S") if match:
## use the previously matched numbers
return tuple([int(e) for e in match.groups()])
else:
return (0, 0, 0, 0)
def __set_ip(self, new_ip, new_nm="0"): def __set_ip(self, new_ip, new_nm="255.255.255.0"):
"""Change the IP, additionally a netmask can be applied """Change the IP, additionally a netmask can be applied
""" """
import threading import threading