index.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>DHCP & DNS 管理器</title>
  7. <link rel="stylesheet" href="/static/css/style.css">
  8. </head>
  9. <body>
  10. <div class="container">
  11. <header>
  12. <h1>🌐 DHCP & DNS 管理器</h1>
  13. <nav>
  14. <a href="#dashboard">仪表盘</a>
  15. <a href="#clients">DHCP 客户端</a>
  16. <a href="#dhcp">DHCP 配置</a>
  17. <a href="#dns">DNS 配置</a>
  18. <a href="#settings">系统设置</a>
  19. <button id="logoutBtn" style="display:none;">退出</button>
  20. </nav>
  21. </header>
  22. <!-- Login Section -->
  23. <section id="loginSection">
  24. <h2>登录</h2>
  25. <form id="loginForm">
  26. <input type="text" id="username" placeholder="用户名" required>
  27. <input type="password" id="password" placeholder="密码" required>
  28. <button type="submit">登录</button>
  29. </form>
  30. </section>
  31. <!-- Dashboard -->
  32. <section id="dashboard" style="display:none;">
  33. <h2>仪表盘</h2>
  34. <div class="stats">
  35. <div class="stat-card" onclick="document.querySelector('a[href=\'#clients\']').click()" style="cursor:pointer;">
  36. <h3>活跃租约</h3>
  37. <p id="activeLeases">0</p>
  38. </div>
  39. <div class="stat-card">
  40. <h3>静态绑定</h3>
  41. <p id="staticBindings">0</p>
  42. </div>
  43. <div class="stat-card">
  44. <h3>DNS 记录</h3>
  45. <p id="dnsRecords">0</p>
  46. </div>
  47. <div class="stat-card">
  48. <h3>在线设备</h3>
  49. <p id="onlineDevices">0</p>
  50. </div>
  51. </div>
  52. <div class="panel">
  53. <h3>系统状态</h3>
  54. <div class="status-grid">
  55. <div class="status-item">
  56. <span class="status-label">DHCP 服务</span>
  57. <span class="status-value" id="dhcpStatus">运行中</span>
  58. </div>
  59. <div class="status-item">
  60. <span class="status-label">DNS 服务</span>
  61. <span class="status-value" id="dnsStatus">运行中</span>
  62. </div>
  63. <div class="status-item">
  64. <span class="status-label">Web 服务</span>
  65. <span class="status-value" id="webStatus">运行中</span>
  66. </div>
  67. </div>
  68. </div>
  69. </section>
  70. <!-- DHCP Configuration -->
  71. <section id="dhcp" style="display:none;">
  72. <h2>DHCP 配置</h2>
  73. <div class="panel">
  74. <h3>基础配置</h3>
  75. <form id="dhcpBasicForm">
  76. <div class="form-row">
  77. <label>启用 DHCP</label>
  78. <input type="checkbox" id="dhcpEnabled" checked>
  79. </div>
  80. <div class="form-row">
  81. <label>网络接口</label>
  82. <input type="text" id="dhcpInterface" placeholder="eth0" required>
  83. </div>
  84. <div class="form-row">
  85. <label>网段地址</label>
  86. <input type="text" id="dhcpNetwork" placeholder="192.168.1.0" required>
  87. </div>
  88. <div class="form-row">
  89. <label>子网掩码</label>
  90. <input type="text" id="dhcpNetmask" placeholder="255.255.255.0" required>
  91. </div>
  92. <div class="form-row">
  93. <label>网关地址</label>
  94. <input type="text" id="dhcpGateway" placeholder="192.168.1.1" required>
  95. </div>
  96. <div class="form-row">
  97. <label>域名</label>
  98. <input type="text" id="dhcpDomain" placeholder="local">
  99. </div>
  100. <button type="submit">保存基础配置</button>
  101. </form>
  102. </div>
  103. <div class="panel">
  104. <h3>IP 地址池</h3>
  105. <form id="dhcpPoolForm">
  106. <div class="form-row">
  107. <label>起始 IP</label>
  108. <input type="text" id="dhcpPoolStart" placeholder="192.168.1.100" required>
  109. </div>
  110. <div class="form-row">
  111. <label>结束 IP</label>
  112. <input type="text" id="dhcpPoolEnd" placeholder="192.168.1.200" required>
  113. </div>
  114. <div class="form-row">
  115. <label>租约时间(秒)</label>
  116. <input type="number" id="dhcpLeaseTime" placeholder="86400" value="86400">
  117. </div>
  118. <button type="submit">保存地址池配置</button>
  119. </form>
  120. </div>
  121. <div class="panel">
  122. <h3>DNS 服务器</h3>
  123. <form id="dhcpDnsForm">
  124. <div class="form-row">
  125. <label>DNS 服务器列表(逗号分隔)</label>
  126. <input type="text" id="dhcpDnsServers" placeholder="192.168.1.1,114.114.114.114,8.8.8.8">
  127. </div>
  128. <button type="submit">保存 DNS 配置</button>
  129. </form>
  130. </div>
  131. <div class="panel">
  132. <h3>排除 IP 列表</h3>
  133. <form id="dhcpExcludedForm">
  134. <div class="form-row">
  135. <label>排除的 IP(逗号分隔)</label>
  136. <input type="text" id="dhcpExcludedIps" placeholder="192.168.1.1,192.168.1.2,192.168.1.3">
  137. </div>
  138. <button type="submit">保存排除列表</button>
  139. </form>
  140. </div>
  141. <div class="panel">
  142. <h3>静态 IP 绑定</h3>
  143. <button onclick="showAddBindingForm()">+ 新增绑定</button>
  144. <table id="bindingsTable">
  145. <thead>
  146. <tr>
  147. <th>MAC 地址</th>
  148. <th>IP 地址</th>
  149. <th>主机名</th>
  150. <th>描述</th>
  151. <th>操作</th>
  152. </tr>
  153. </thead>
  154. <tbody></tbody>
  155. </table>
  156. </div>
  157. </section>
  158. <!-- DHCP Clients -->
  159. <section id="clients" style="display:none;">
  160. <h2>DHCP 客户端列表</h2>
  161. <div class="panel">
  162. <h3>已分配 IP 的客户端</h3>
  163. <button onclick="loadClients()">🔄 刷新</button>
  164. <button onclick="toggleAutoRefresh()" id="autoRefreshBtn">⏸️ 自动刷新: 关</button>
  165. <table id="clientsTable">
  166. <thead>
  167. <tr>
  168. <th>MAC 地址</th>
  169. <th>IP 地址</th>
  170. <th>主机名</th>
  171. <th>租约剩余</th>
  172. <th>过期时间</th>
  173. <th>状态</th>
  174. <th>操作</th>
  175. </tr>
  176. </thead>
  177. <tbody>
  178. <tr>
  179. <td colspan="7" style="text-align:center;color:#999;">暂无客户端</td>
  180. </tr>
  181. </tbody>
  182. </table>
  183. </div>
  184. <div class="panel">
  185. <h3>IP 地址池使用情况</h3>
  186. <div class="pool-stats">
  187. <div class="stat-item">
  188. <span class="stat-label">地址池范围</span>
  189. <span class="stat-value" id="poolRange">--</span>
  190. </div>
  191. <div class="stat-item">
  192. <span class="stat-label">已分配</span>
  193. <span class="stat-value" id="poolUsed">0</span>
  194. </div>
  195. <div class="stat-item">
  196. <span class="stat-label">可用</span>
  197. <span class="stat-value" id="poolAvailable">0</span>
  198. </div>
  199. <div class="stat-item">
  200. <span class="stat-label">使用率</span>
  201. <span class="stat-value" id="poolUsage">0%</span>
  202. </div>
  203. </div>
  204. <div class="pool-bar">
  205. <div class="pool-bar-fill" id="poolBarFill" style="width: 0%;"></div>
  206. </div>
  207. </div>
  208. </section>
  209. <!-- DNS Configuration -->
  210. <section id="dns" style="display:none;">
  211. <h2>DNS 配置</h2>
  212. <div class="panel">
  213. <h3>基础配置</h3>
  214. <form id="dnsBasicForm">
  215. <div class="form-row">
  216. <label>启用 DNS</label>
  217. <input type="checkbox" id="dnsEnabled" checked>
  218. </div>
  219. <div class="form-row">
  220. <label>监听地址</label>
  221. <input type="text" id="dnsListenAddr" placeholder="0.0.0.0" value="0.0.0.0">
  222. </div>
  223. <div class="form-row">
  224. <label>监听端口</label>
  225. <input type="number" id="dnsListenPort" placeholder="53" value="53">
  226. </div>
  227. <div class="form-row">
  228. <label>启用递归查询</label>
  229. <input type="checkbox" id="dnsRecursion" checked>
  230. </div>
  231. <button type="submit">保存基础配置</button>
  232. </form>
  233. </div>
  234. <div class="panel">
  235. <h3>上游 DNS 服务器</h3>
  236. <form id="dnsUpstreamForm">
  237. <div class="form-row">
  238. <label>上游 DNS(逗号分隔)</label>
  239. <input type="text" id="dnsUpstream" placeholder="8.8.8.8,1.1.1.1,114.114.114.114">
  240. </div>
  241. <button type="submit">保存上游 DNS</button>
  242. </form>
  243. </div>
  244. <div class="panel">
  245. <h3>DNS 区域 (Zone)</h3>
  246. <button onclick="showAddZoneForm()">+ 新增区域</button>
  247. <table id="zonesTable">
  248. <thead>
  249. <tr>
  250. <th>区域名称</th>
  251. <th>类型</th>
  252. <th>记录数</th>
  253. <th>操作</th>
  254. </tr>
  255. </thead>
  256. <tbody></tbody>
  257. </table>
  258. </div>
  259. <div class="panel">
  260. <h3>DNS 记录</h3>
  261. <button onclick="showAddRecordForm()">+ 新增记录</button>
  262. <table id="recordsTable">
  263. <thead>
  264. <tr>
  265. <th>域名</th>
  266. <th>类型</th>
  267. <th>值</th>
  268. <th>TTL</th>
  269. <th>操作</th>
  270. </tr>
  271. </thead>
  272. <tbody></tbody>
  273. </table>
  274. </div>
  275. <div class="panel">
  276. <h3>查询日志</h3>
  277. <button onclick="loadLogs()">刷新</button>
  278. <table id="logsTable">
  279. <thead>
  280. <tr>
  281. <th>时间</th>
  282. <th>客户端 IP</th>
  283. <th>查询域名</th>
  284. <th>类型</th>
  285. <th>响应</th>
  286. </tr>
  287. </thead>
  288. <tbody></tbody>
  289. </table>
  290. </div>
  291. </section>
  292. <!-- Settings -->
  293. <section id="settings" style="display:none;">
  294. <h2>系统设置</h2>
  295. <div class="panel">
  296. <h3>Web 设置</h3>
  297. <form id="webSettingsForm">
  298. <div class="form-row">
  299. <label>监听地址</label>
  300. <input type="text" id="webHost" placeholder="0.0.0.0" value="0.0.0.0">
  301. </div>
  302. <div class="form-row">
  303. <label>监听端口</label>
  304. <input type="number" id="webPort" placeholder="8080" value="8080">
  305. </div>
  306. <button type="submit">保存 Web 设置</button>
  307. </form>
  308. </div>
  309. <div class="panel">
  310. <h3>配置管理</h3>
  311. <button onclick="exportConfig()">导出配置</button>
  312. <button onclick="importConfig()">导入配置</button>
  313. <button onclick="restartService()">重启服务</button>
  314. </div>
  315. <div class="panel">
  316. <h3>系统信息</h3>
  317. <div class="info-grid">
  318. <div class="info-item">
  319. <span class="info-label">版本</span>
  320. <span class="info-value">v0.1.1</span>
  321. </div>
  322. <div class="info-item">
  323. <span class="info-label">运行时间</span>
  324. <span class="info-value" id="uptime">--</span>
  325. </div>
  326. <div class="info-item">
  327. <span class="info-label">数据库大小</span>
  328. <span class="info-value" id="dbSize">--</span>
  329. </div>
  330. </div>
  331. </div>
  332. </section>
  333. </div>
  334. <script src="/static/js/app.js"></script>
  335. </body>
  336. </html>