index.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. </tr>
  175. </thead>
  176. <tbody>
  177. <tr>
  178. <td colspan="6" style="text-align:center;color:#999;">暂无客户端</td>
  179. </tr>
  180. </tbody>
  181. </table>
  182. </div>
  183. <div class="panel">
  184. <h3>IP 地址池使用情况</h3>
  185. <div class="pool-stats">
  186. <div class="stat-item">
  187. <span class="stat-label">地址池范围</span>
  188. <span class="stat-value" id="poolRange">--</span>
  189. </div>
  190. <div class="stat-item">
  191. <span class="stat-label">已分配</span>
  192. <span class="stat-value" id="poolUsed">0</span>
  193. </div>
  194. <div class="stat-item">
  195. <span class="stat-label">可用</span>
  196. <span class="stat-value" id="poolAvailable">0</span>
  197. </div>
  198. <div class="stat-item">
  199. <span class="stat-label">使用率</span>
  200. <span class="stat-value" id="poolUsage">0%</span>
  201. </div>
  202. </div>
  203. <div class="pool-bar">
  204. <div class="pool-bar-fill" id="poolBarFill" style="width: 0%;"></div>
  205. </div>
  206. </div>
  207. </section>
  208. <!-- DNS Configuration -->
  209. <section id="dns" style="display:none;">
  210. <h2>DNS 配置</h2>
  211. <div class="panel">
  212. <h3>基础配置</h3>
  213. <form id="dnsBasicForm">
  214. <div class="form-row">
  215. <label>启用 DNS</label>
  216. <input type="checkbox" id="dnsEnabled" checked>
  217. </div>
  218. <div class="form-row">
  219. <label>监听地址</label>
  220. <input type="text" id="dnsListenAddr" placeholder="0.0.0.0" value="0.0.0.0">
  221. </div>
  222. <div class="form-row">
  223. <label>监听端口</label>
  224. <input type="number" id="dnsListenPort" placeholder="53" value="53">
  225. </div>
  226. <div class="form-row">
  227. <label>启用递归查询</label>
  228. <input type="checkbox" id="dnsRecursion" checked>
  229. </div>
  230. <button type="submit">保存基础配置</button>
  231. </form>
  232. </div>
  233. <div class="panel">
  234. <h3>上游 DNS 服务器</h3>
  235. <form id="dnsUpstreamForm">
  236. <div class="form-row">
  237. <label>上游 DNS(逗号分隔)</label>
  238. <input type="text" id="dnsUpstream" placeholder="8.8.8.8,1.1.1.1,114.114.114.114">
  239. </div>
  240. <button type="submit">保存上游 DNS</button>
  241. </form>
  242. </div>
  243. <div class="panel">
  244. <h3>DNS 区域 (Zone)</h3>
  245. <button onclick="showAddZoneForm()">+ 新增区域</button>
  246. <table id="zonesTable">
  247. <thead>
  248. <tr>
  249. <th>区域名称</th>
  250. <th>类型</th>
  251. <th>记录数</th>
  252. <th>操作</th>
  253. </tr>
  254. </thead>
  255. <tbody></tbody>
  256. </table>
  257. </div>
  258. <div class="panel">
  259. <h3>DNS 记录</h3>
  260. <button onclick="showAddRecordForm()">+ 新增记录</button>
  261. <table id="recordsTable">
  262. <thead>
  263. <tr>
  264. <th>域名</th>
  265. <th>类型</th>
  266. <th>值</th>
  267. <th>TTL</th>
  268. <th>操作</th>
  269. </tr>
  270. </thead>
  271. <tbody></tbody>
  272. </table>
  273. </div>
  274. <div class="panel">
  275. <h3>查询日志</h3>
  276. <button onclick="loadLogs()">刷新</button>
  277. <table id="logsTable">
  278. <thead>
  279. <tr>
  280. <th>时间</th>
  281. <th>客户端 IP</th>
  282. <th>查询域名</th>
  283. <th>类型</th>
  284. <th>响应</th>
  285. </tr>
  286. </thead>
  287. <tbody></tbody>
  288. </table>
  289. </div>
  290. </section>
  291. <!-- Settings -->
  292. <section id="settings" style="display:none;">
  293. <h2>系统设置</h2>
  294. <div class="panel">
  295. <h3>Web 设置</h3>
  296. <form id="webSettingsForm">
  297. <div class="form-row">
  298. <label>监听地址</label>
  299. <input type="text" id="webHost" placeholder="0.0.0.0" value="0.0.0.0">
  300. </div>
  301. <div class="form-row">
  302. <label>监听端口</label>
  303. <input type="number" id="webPort" placeholder="8080" value="8080">
  304. </div>
  305. <button type="submit">保存 Web 设置</button>
  306. </form>
  307. </div>
  308. <div class="panel">
  309. <h3>配置管理</h3>
  310. <button onclick="exportConfig()">导出配置</button>
  311. <button onclick="importConfig()">导入配置</button>
  312. <button onclick="restartService()">重启服务</button>
  313. </div>
  314. <div class="panel">
  315. <h3>系统信息</h3>
  316. <div class="info-grid">
  317. <div class="info-item">
  318. <span class="info-label">版本</span>
  319. <span class="info-value">v0.1.1</span>
  320. </div>
  321. <div class="info-item">
  322. <span class="info-label">运行时间</span>
  323. <span class="info-value" id="uptime">--</span>
  324. </div>
  325. <div class="info-item">
  326. <span class="info-label">数据库大小</span>
  327. <span class="info-value" id="dbSize">--</span>
  328. </div>
  329. </div>
  330. </div>
  331. </section>
  332. </div>
  333. <script src="/static/js/app.js"></script>
  334. </body>
  335. </html>