summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--dhcp-controller.lua35
-rw-r--r--dhcp-createnet-html.lsp35
-rw-r--r--dhcp-home-html.lsp23
4 files changed, 85 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index eb2fb69..2d83fcb 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ VERSION=1.0_alpha1
APP_DIST=dhcp-controller.lua \
dhcp-editnet-html.lsp \
dhcp-home-html.lsp \
+ dhcp-createnet-html.lsp \
dhcp-view-html.lsp \
dhcp-model.lua \
dhcp.menu
diff --git a/dhcp-controller.lua b/dhcp-controller.lua
index 8811e86..671e0b3 100644
--- a/dhcp-controller.lua
+++ b/dhcp-controller.lua
@@ -76,6 +76,41 @@ editnet = function ( self )
return ( cfe({ option = option, value = net, error = { value=nil, fields=nil }}) )
end
+createnet = function ( self )
+
+ if not self.clientdata.cmd then
+ list_redir(self)
+ end
+
+ local option = { script = ENV["SCRIPT_NAME"],
+ prefix = self.conf.prefix,
+ controller = self.conf.controller,
+ action = self.conf.action,
+ extra = ""
+ }
+
+ net = { name = { label="Name", value=self.model.nonil(self.clientdata.name), type="message" },
+ defleasetime = { label="Default Lease Time", value=self.model.nonil(self.clientdata.defleasetime), type="text" },
+ maxleasetime = { label="Maximum Lease Time", value=self.model.nonil(self.clientdata.maxleasetime), type="text" },
+ gateway = { label="Gateway", value=self.model.nonil(self.clientdata.gateway), type="text" },
+ domainname = { label="Domainname", value=self.model.nonil(self.clientdata.domainname), type="text" },
+ dnssrv1 = { label="DNS Server 1", value=self.model.nonil(self.clientdata.dnssrv1), type="text" },
+ dnssrv2 = { label="DNS Server 2", value=self.model.nonil(self.clientdata.dnssrv2), type="text" },
+ subnet = { label="Subnet", value=self.model.nonil(self.clientdata.subnet), type="text" },
+ netmask = { label="Netmask", value=self.model.nonil(self.clientdata.netmask), type="text" },
+ leaserangestart = { label="Lease Range Start", value=self.model.nonil(self.clientdata.leaserangestart), type="text" },
+ leaserangeend = { label="Lease Range End", value=self.model.nonil(self.clientdata.leaserangeend), type="text" },
+ wpad = { label="Web Proxy Auto Discovery", value=self.model.nonil(self.clientdata.wpad),
+ type="select", option = { "yes", "no"} }
+ }
+
+ if self.clientdata.cmd == "new" then
+ return ( cfe({ option = option, value = net, error = { value = nil, fields = nil }}) )
+ elseif self.clientdata.cmd == "create" then
+ return ( cfe({ option = option, value = net, error = { value = nil, fields = nil }}) )
+ end
+end
+
home = function ( self )
local srvctrl = ""
diff --git a/dhcp-createnet-html.lsp b/dhcp-createnet-html.lsp
new file mode 100644
index 0000000..aadc2c8
--- /dev/null
+++ b/dhcp-createnet-html.lsp
@@ -0,0 +1,35 @@
+<?
+ local form = ...
+ local option = form.option;
+ local net = form.value
+?>
+<h1>Create New Subnet</h1>
+<h2>Subnet: new</h2>
+
+<form action="<? io.write(option.script .. option.prefix ..
+ option.controller .. "/" .. option.action .. option.extra) ?>" method="POST">
+<table>
+ <tr><td><nobr>Name:</nobr></td><td><input type="text" name="name" value="<? io.write(net.name.value) ?>"></td></tr>
+ <tr><td><nobr>Subnet:</nobr></td><td><input type="text" name="subnet" value="<? io.write(net.subnet.value) ?>"></td></tr>
+ <tr><td><nobr>Netmask:</nobr></td><td><input type="text" name="netmask" value="<? io.write(net.netmask.value) ?>"></td></tr>
+ <tr><td><nobr>Gateway:</nobr></td><td><input type="text" name="gateway" value="<? io.write(net.gateway.value) ?>"></td></tr>
+ <tr><td><nobr>DNS Server 1:</nobr></td><td><input type="text" name="dnssrv1" value="<? io.write(net.dnssrv1.value) ?>"></td></tr>
+ <tr><td><nobr>DNS Server 2:</nobr></td><td><input type="text" name="dnssrv2" value="<? io.write(net.dnssrv2.value) ?>"></td></tr>
+ <tr><td><nobr>Default Lease Time:</nobr></td><td><input type="text" name="defleasetime" value="<? io.write(net.defleasetime.value) ?>"></td></tr>
+ <tr><td><nobr>Maximum Lease Time:</nobr></td><td><input type="text" name="maxleasetime" value="<? io.write(net.maxleasetime.value) ?>"></td></tr>
+ <tr><td><nobr>Domain Name:</nobr></td><td><input type="text" name="domainname" value="<? io.write(net.domainname.value) ?>"></td></tr>
+ <tr><td><nobr>WPAD:</nobr></td><td>
+ <select name="wpad" size="1">
+<?
+ for k,v in ipairs(net.wpad.option) do
+ if (v == net.wpad.value) then
+ io.write("<option selected>" .. v .."</option>")
+ else
+ io.write("<option>" .. v .. "</option>")
+ end
+ end
+?>
+ </select>
+ </td></tr>
+ <tr><td></td><td><input type=submit name=cmd value="create" style="width:300px"></form><form action="<? io.write(option.script .. option.prefix .. option.controller .. "/home") ?> method="POST">
+<input type=submit name="cmd" value="back" style="width:300px"></form></td></tr></table>
diff --git a/dhcp-home-html.lsp b/dhcp-home-html.lsp
index a631233..e864c07 100644
--- a/dhcp-home-html.lsp
+++ b/dhcp-home-html.lsp
@@ -18,10 +18,17 @@
</table>
<pre><? io.write( form.info.srvctrl.value ) ?></pre><br>
-<h2>DHCPd - General</h2>
+<h2>DHCPd - Generate Configuration File</h2>
+<table>
+<form action="<? io.write(data.script .. data.prefix .. data.controller .. "/home") ?>" method="POST">
+<tr><td><input type=submit name="generate" value="generate" style="width:100px"></td></tr>
+</form>
+</table><br>
+
+<h2>DHCPd - Global Settings</h2>
<table>
<form action="<? io.write(data.script .. data.prefix .. data.controller .. "/settings") ?>" method="POST">
-<tr><td><input type=submit name="cmd" value="Edit Settings" style="width:200px"></td></tr>
+<tr><td><input type=submit name="cmd" value="edit" style="width:100px"></td></tr>
</form>
</table><br>
@@ -37,17 +44,15 @@
end
?>
</select></td>
-<td><input type=submit name="cmd" value="Edit" style="width:200px"></td>
+<td><input type=submit name="cmd" value="edit" style="width:100px"></td>
</form>
</table><br>
<h2>DHCPd - Add New Subnet</h2>
<table>
-<form action="" method="POST">
+<form action="<? io.write(data.script .. data.prefix .. data.controller .. "/createnet") ?>" method="POST">
<tr>
- <td>Network Name</td>
- <td><input type=text name="name" value="" style="width:300px"></td>
- <td><input type=submit name="cmd" value="Create" style="width:200px"></td>
+ <td><input type=submit name="cmd" value="new" style="width:100px"></td>
</tr>
</form>
</table>
@@ -56,8 +61,8 @@
<h2>DHCPd - View Files</h2>
<table>
<form action="<? io.write(data.script .. data.prefix .. data.controller .. "/view") ?>" method="POST">
-<tr><td><input type=submit name="conf" value="View dhcpd.conf" style="width:200px"></td></tr>
-<tr><td><input type=submit name="leases" value="View dhcpd.leases" style="width:200px"></td></tr>
+<tr><td><input type=submit name="conf" value="dhcpd.conf" style="width:200px"></td></tr>
+<tr><td><input type=submit name="leases" value="dhcpd.leases" style="width:200px"></td></tr>
</form>
</table><br>