完善文档和配置流程
This commit is contained in:
49
steps.py
49
steps.py
@@ -120,6 +120,7 @@ def configJhMixOuts(conn: Api, config):
|
||||
except Exception as e:
|
||||
raise RuntimeError("删除 PPP 失败: {}".format(e))
|
||||
|
||||
index = (int(config["index"]) - 1) * 10
|
||||
for i in range(30):
|
||||
for j in range(10):
|
||||
n = j * 30 + i
|
||||
@@ -127,9 +128,9 @@ def configJhMixOuts(conn: Api, config):
|
||||
|
||||
ppps.add(
|
||||
**{
|
||||
"name": f"l2tp-out{n+1}",
|
||||
"name": f"l2tp-out{n + 1}",
|
||||
"connect-to": f"192.168.25{k}.25{k}",
|
||||
"user": f"jdzz{j+11}dt{i+221}",
|
||||
"user": f"jdzz{j + 1 + index}dt{i + 221}",
|
||||
"password": "123231",
|
||||
"disabled": "no",
|
||||
}
|
||||
@@ -144,8 +145,8 @@ def configJhMixOuts(conn: Api, config):
|
||||
raise RuntimeError("删除路由表失败: {}".format(e))
|
||||
|
||||
for i in range(300):
|
||||
routeName = f"r{i+1}"
|
||||
routeOut = f"l2tp-out{i+1}"
|
||||
routeName = f"r{i + 1}"
|
||||
routeOut = f"l2tp-out{i + 1}"
|
||||
try:
|
||||
routes.add(
|
||||
**{
|
||||
@@ -355,7 +356,7 @@ def configJhDrop(conn: Api, config):
|
||||
layer7.add(
|
||||
**{
|
||||
"name": "illegal",
|
||||
"regexp": f'({"|".join([re.escape(domain) for domain in domains])})[/:]?.*',
|
||||
"regexp": f"({'|'.join([re.escape(domain) for domain in domains])})[/:]?.*",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -425,7 +426,7 @@ def configJgAuth(conn: Api, config):
|
||||
|
||||
try:
|
||||
l2tp = conn.path("interface", "l2tp-server", "server")
|
||||
l2tp.update(**{"enabled": "yes", "use-ipsec": "yes", "ipsec-secret": "byjd231"})
|
||||
l2tp.update(**{"enabled": "yes", "use-ipsec": "yes", "ipsec-secret": "1234"})
|
||||
except Exception as e:
|
||||
raise RuntimeError(f"配置 l2tp 服务器失败: {e}")
|
||||
|
||||
@@ -451,7 +452,8 @@ def configJgOuts(conn: Api, config):
|
||||
"""
|
||||
|
||||
try:
|
||||
count = 20
|
||||
count = 10
|
||||
window = 20
|
||||
|
||||
# 配置 ppp
|
||||
try:
|
||||
@@ -468,8 +470,8 @@ def configJgOuts(conn: Api, config):
|
||||
ppps.add(
|
||||
**{
|
||||
"name": f"l2tp-out{i}",
|
||||
"connect-to": f"192.168.0.{int(config['gate'])+1}",
|
||||
"user": f"bydj{config['gate']}api{(int(config['index'])-1) * count + i}",
|
||||
"connect-to": f"192.168.0.{int(config['gate']) + 1}",
|
||||
"user": f"byjd{config['gate']}api{(int(config['index']) - 1) * window + i}",
|
||||
"password": "byjd231",
|
||||
"disabled": "no",
|
||||
}
|
||||
@@ -528,8 +530,8 @@ def configJgMixOuts(conn: Api, config):
|
||||
ppps.add(
|
||||
**{
|
||||
"name": f"l2tp-out{i}",
|
||||
"connect-to": f"192.168.0.{int(config['gate'])+1}",
|
||||
"user": f"bydj{config['gate']}api{(int(config['index'])-1) * count + i}",
|
||||
"connect-to": f"192.168.0.{int(config['gate']) + 1}",
|
||||
"user": f"byjd{config['gate']}api{(int(config['index']) - 1) * count + i}",
|
||||
"password": "byjd231",
|
||||
"disabled": "no",
|
||||
}
|
||||
@@ -737,3 +739,28 @@ def configJgLogs(conn: Api, config):
|
||||
# ====================
|
||||
# 临时
|
||||
# ====================
|
||||
|
||||
|
||||
def temp(conn: Api, config):
|
||||
ppps = conn.path("interface", "l2tp-client")
|
||||
|
||||
count = 0
|
||||
for ppp in ppps:
|
||||
count += 1
|
||||
if ppp["name"].startswith("l2tp-out") and ppp["running"] != True:
|
||||
break
|
||||
|
||||
if count < 20:
|
||||
raise RuntimeError(f"有未运行的 PPP,count={count}")
|
||||
|
||||
# file = open(f"outs/{config['code']}.csv", "w", encoding="utf-8")
|
||||
# file.write("ros,name,connect-to,user,running\n")
|
||||
# for ppp in ppps:
|
||||
# file.write("{},{},{},{},{}\n".format(
|
||||
# config["name"],
|
||||
# ppp["name"],
|
||||
# ppp["connect-to"],
|
||||
# ppp["user"],
|
||||
# ppp["running"],
|
||||
# ))
|
||||
# file.close()
|
||||
|
||||
Reference in New Issue
Block a user