-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
39 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
- ~~完善设置选项~~ | ||
- ~~侧边栏左右切换~~ | ||
- ~~灵敏度调整~~ | ||
- 关闭服务端按键 | ||
|
||
## v0.5.x | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import psutil | ||
|
||
|
||
def portchecker(port): | ||
""" | ||
使用psutil检查端口是否可用 | ||
- 如果端口是一个数字且在合法范围内(1-65534) | ||
- 并且没有被别的程序使用,则返回True | ||
""" | ||
# 确保端口号是整数且在合法范围内 | ||
if isinstance(port, int) and 0 < port < 65535: | ||
# 获取当前所有的网络连接 | ||
connections = psutil.net_connections() | ||
# 遍历所有连接,检查端口是否被占用 | ||
for conn in connections: | ||
if conn.laddr.port == port: | ||
return False # 端口已被占用 | ||
return True # 端口未被占用,可用 | ||
else: | ||
return False # 端口号不合法 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters