Skip to content

Commit 3a1d7db

Browse files
committed
yes
1 parent 6751e39 commit 3a1d7db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+821
-1958
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
!.github
22
!.git
3-
__pycache__
3+
__pycache__
4+
build
5+
.spec

README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
1-
# IP地址规划器
1+
# 多功能IP地址计算器
22

33
## 简介
44

55
当前多数在线IP计算器虽然功能全面,但往往界面设计太过零散,使得功能在查找和使用不够便捷。为了提供一个更直观、更高效的使用体验,所以决定改进设计,进行有效功能整合,重做一款IP计算工具软件。
66

77
这是一款界面简洁、功能强大的网络计算工具,它不仅涵盖了网络和IP地址计算、基于主机数的子网划分、IP及掩码地址的进制转换等核心功能,还提供了便捷的历史记录操作,且计算结果的准确性与[清华大学交叉信息研究院 - ip地址在线计算器](https://iiis.tsinghua.edu.cn/ip/)相一致。
88

9-
## 功能展示
9+
## 核心功能
1010

11-
### 计算功能
11+
**子网运算**
1212

1313
网络和IP地址计算,以及主机数与子网掩码换算。
1414

1515
![pAohKS0.png](https://s21.ax1x.com/2024/12/04/pAohKS0.png)
1616

17+
**进制转换**
18+
1719
考虑到学习IP地址知识的过程必然会涉及点分十进制、二进制、十六进制的转换,为此特别增加了IP地址和子网掩码的进制转换功能,以满足用户在不同场景下的应急需求。
1820

1921
![pAoh5nS.png](https://s21.ax1x.com/2024/12/04/pAoh5nS.png)
2022

23+
**路由聚合与超网拆分**
24+
25+
路由聚合
26+
27+
![PixPin_2025-01-21_19-14-31](https://img.yonrd.com/i/2025/01/21/vpkksc.png)
28+
29+
超网拆分
30+
31+
![PixPin_2025-01-23_11-31-33](https://img.yonrd.com/i/2025/01/23/iqqdqr.png)
32+
33+
以及额外的IP包含检测
34+
35+
![PixPin_2025-01-23_11-39-45](https://img.yonrd.com/i/2025/01/23/iw43fu.png)
36+
2137
### 辅助功能
2238

2339
为了进一步提升用户体验,精心设计了辅助功能,包括精选的网络教程,帮助用户深入浅出了解IP相关知识;提供在线工具链接,便于用户进行结果验证和学习总结。
@@ -32,15 +48,15 @@
3248

3349
![pAo4Ac6.png](https://s21.ax1x.com/2024/12/04/pAo4Ac6.png)
3450

35-
## ***Take your heart***
51+
## ***Take your heart***
3652

37-
<a href="https://github.com/hoochanlon/Network-Calculator/releases/download/v1.3.2/Network-Calculator.v1.3.2.exe">
53+
<a href="https://wwxm.lanzouo.com/iFSv92lpw0gh">
3854
<img align="right" src="https://img.yonrd.com/i/2024/12/04/xans5s.png" alt="download" width="320" height="120"/>
3955
</a>
4056

4157
应用程序下载地址:
4258

43-
* 蓝奏云:https://wwxm.lanzouo.com/i8dW92hhjtuf
59+
* 蓝奏云:https://wwxm.lanzouo.com/iFSv92lpw0gh
4460
* GitHub:https://github.com/hoochanlon/Network-Calculator/releases
4561

4662
也可下载源码运行,目录结构规则如下:
@@ -65,11 +81,8 @@ pip install -r requirements.txt
6581
<img src="https://img.picui.cn/free/2024/12/04/67507c422c62d.png" alt="github.png" title="github.png" width="50" height="50" />
6682
</a>
6783
<a href="mailto:[email protected]">
68-
<img src="https://img.yonrd.com/i/2024/12/04/uoim5m.png" alt="p5r" width="70" height="50"/>
84+
<img src="https://img.yonrd.com/i/2025/01/23/iyj6af.png" alt="email" width="50" height="50"/>
6985
</a>
70-
<a href="https://hoochanlon.github.io/assets/qr/wx.png">
71-
<img src="https://img.yonrd.com/i/2024/12/04/uoishh.png" alt="wechat" width="50" height="50"/>
72-
</a>
7386
</div>
7487

7588
<!---

core/base_supernet.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# base_supernet.py
2+
import ipaddress
3+
4+
def ip_to_bin(ip):
5+
"""将IP地址转换为32位二进制字符串"""
6+
return ''.join([bin(int(x)+256)[3:] for x in ip.split('.')])
7+
8+
def get_supernet(ips):
9+
"""计算超网"""
10+
# 转换所有IP地址为二进制
11+
bins = [ip_to_bin(ip) for ip in ips]
12+
13+
# 找到公共前缀
14+
common_prefix = ''
15+
for bits in zip(*bins):
16+
if len(set(bits)) == 1:
17+
common_prefix += bits[0] # 只有一个不同的bit,保留这个bit
18+
else:
19+
break # 如果出现不同的bit,停止
20+
21+
# 计算前缀长度
22+
prefix_len = len(common_prefix)
23+
24+
# 填充剩余的位数为0,得到完整的32位二进制
25+
supernet_bin = common_prefix + '0' * (32 - prefix_len)
26+
27+
# 将二进制转换回点分十进制
28+
supernet_ip = '.'.join(str(int(supernet_bin[i:i+8], 2)) for i in range(0, 32, 8))
29+
30+
return f'{supernet_ip}/{prefix_len}'
31+
32+
# 示例网络
33+
# ips = ['192.168.1.0', '192.168.2.0', '192.168.3.0', '192.168.4.0']
34+
35+
# 计算超网
36+
# supernet = get_supernet(ips)
37+
# print("超网:", supernet)

core/calc_history_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# calc_history_manager.py
12
import json
23
import os
34
import sys

core/network_class_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# network_class_utils.py
12
import re
23
import ipaddress
34

docs/Agilent_Netzwerk.pdf

536 KB
Binary file not shown.

docs/开发日志.txt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,36 @@
2121
2.增加历史记录查看、搜索、记录导出与删除。
2222
3.只有正确的操作记录被保存,减少无效输出干扰。
2323

24-
v1.3.1
24+
v1.3.1
2525
1. 历史记录相关计算器名称同一规范
2626
2. 调整历史记录GUI布局宽高布局
27-
3. 项目根目录由“IP规划计算器”调整为“Network-Calculator”,方便GitHub上传源码
28-
4. 源码上增加项目输出打包命令脚本,方便一键打包调试
27+
3. 源码上增加项目输出打包命令脚本,方便一键打包调试
2928

29+
v1.3.2:
30+
1. 知识库新增本地 IP子网速查表。
31+
2. 优化网络类别判断逻辑。
32+
33+
v1.4:
34+
1. 新增网段合并计算器
35+
2. 新增超网拆分计算器
36+
3. 修复历史记录查看器不显示输入值的问题
37+
38+
v1.5:
39+
1. 新增IP包含检测器
40+
2. 移除部分在线工具链接,新增网络协议图
41+
3. 软件命名调整
3042

3143
二、附录
3244

3345
开发所用到的素材以及在线工具
3446
工具类:
3547
1.https://iiis.tsinghua.edu.cn/IP/
3648
2.https://www.calculator.io
49+
3.http://tools.bugscaner.com/ipjuhe.html
3750
图标类:
3851
1.https://www.freepik.com
3952
2.https://yesicon.app
40-
3.https://www.acon vert.com/cn/icon/png-to-ico/
53+
3.https://www.aconvert.com/cn/icon/png-to-ico/
4154
4.https://www.iloveimg.com/zh-cn/crop-image/crop-png
4255
文档类:
4356
1.文档压缩:https://www.youcompress.com/zh-cn

gui/gui_base_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def convert_ip_gui():
4040
result_text.insert(tk.END, result, "big_font") # 显示转换结果,应用自定义字体样式
4141

4242
# 保存历史记录
43-
save_to_history("IP及掩码进制转换器", {"symbol": ip_input}, result)
43+
save_to_history("IP进制转换器", {"symbol": ip_input}, result)
4444

4545
# 更新状态字典中的输入内容
4646
ip_base_converter_state["symbol"] = ip_input

gui/gui_calc_history_manager.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ def look_record():
9494
mask = selected_record['inputs'].get('mask', None)
9595
hosts = selected_record['inputs'].get('hosts', None)
9696
subnet_input = selected_record['inputs'].get('subnet_input', None)
97+
symbol = selected_record['inputs'].get('symbol', None)
98+
network_merge_input = selected_record['inputs'].get('network_merge_input', None)
99+
supernet_split_input = selected_record['inputs'].get('supernet_split_input', None)
100+
checker_cidr_1 = selected_record['inputs'].get('checker_cidr_1', None)
101+
checker_cidr_2 = selected_record['inputs'].get('checker_cidr_2', None)
97102

98103
# 动态检查是否有值,若没有则跳过该字段
99104
inputs_str = ""
@@ -105,6 +110,16 @@ def look_record():
105110
inputs_str += f"主机数: {hosts}\n"
106111
if subnet_input:
107112
inputs_str += f"子网输入: {subnet_input}\n"
113+
if symbol:
114+
inputs_str += f"输入字符: {symbol}\n"
115+
if network_merge_input:
116+
inputs_str += f"需要合并的网段:\n{network_merge_input}\n"
117+
if supernet_split_input:
118+
inputs_str += f"需要拆分的超网及目标长度:\n{supernet_split_input}\n"
119+
if checker_cidr_1:
120+
inputs_str += f"需要验证的CIDR或IP:\n{checker_cidr_1}\n"
121+
if checker_cidr_2:
122+
inputs_str += f"目标CIDR网段: \n{checker_cidr_2}\n"
108123

109124
# 如果没有任何输入信息,显示默认提示
110125
if not inputs_str:
@@ -174,6 +189,11 @@ def copy_record():
174189
mask = selected_record['inputs'].get('mask', None)
175190
hosts = selected_record['inputs'].get('hosts', None)
176191
subnet_input = selected_record['inputs'].get('subnet_input', None)
192+
symbol = selected_record['inputs'].get('symbol', None)
193+
network_merge_input = selected_record['inputs'].get('network_merge_input', None)
194+
supernet_split_input = selected_record['inputs'].get('supernet_split_input', None)
195+
checker_cidr_1 = selected_record['inputs'].get('checker_cidr_1', None)
196+
checker_cidr_2 = selected_record['inputs'].get('checker_cidr_2', None)
177197

178198
inputs_str = ""
179199
if ip:
@@ -184,6 +204,16 @@ def copy_record():
184204
inputs_str += f"主机数: {hosts}\n"
185205
if subnet_input:
186206
inputs_str += f"子网输入: {subnet_input}\n"
207+
if symbol:
208+
inputs_str += f"输入字符: {symbol}\n"
209+
if network_merge_input:
210+
inputs_str += f"需要合并的网段:\n{network_merge_input}\n"
211+
if supernet_split_input:
212+
inputs_str += f"需要拆分的超网及目标长度:\n{supernet_split_input}\n"
213+
if checker_cidr_1:
214+
inputs_str += f"需要验证的CIDR或IP:\n{checker_cidr_1}\n"
215+
if checker_cidr_2:
216+
inputs_str += f"目标CIDR网段: \n{checker_cidr_2}\n"
187217

188218
if not inputs_str:
189219
inputs_str = "没有输入信息"

gui/gui_ip_calc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def on_calculate():
8282
ip_calc_state["result"] = output # 保存输出结果
8383

8484
# 保存历史记录
85-
save_to_history("网络和IP地址计算器", {"ip": ip_address, "mask": subnet_mask}, output)
85+
save_to_history("IP地址计算器", {"ip": ip_address, "mask": subnet_mask}, output)
8686

8787
# 更新状态字典中的输入内容
8888
ip_calc_state["ip_address"] = ip_address

0 commit comments

Comments
 (0)