diff --git a/.gitignore b/.gitignore index 460bd52..0600ed5 100644 --- a/.gitignore +++ b/.gitignore @@ -203,4 +203,5 @@ __marimo__/ .streamlit/secrets.toml # 业务文件 -*.crt \ No newline at end of file +*.crt +config.csv \ No newline at end of file diff --git a/config.bak.csv b/config.bak.csv index 98f9d7d..887e1b7 100644 --- a/config.bak.csv +++ b/config.bak.csv @@ -1,5 +1,6 @@ index,name,code,gateway,public,mask,private,domain,cert -0,混拨1,hh1,43.226.58.1,43.226.58.9,24,192.168.98.1,hh,server.9.crt +0,混拨1,hh1,43.226.58.1,43.226.58.7,24,192.168.98.3,hh,server.7.crt +0,混拨2,hh2,43.226.58.1,43.226.58.8,24,192.168.98.2,hh,server.crt 1,宣城,ahxc215,43.226.58.1,43.226.58.10,24,192.168.99.1,ahxc,server.crt 2,宿州,ahsz216,43.226.58.1,43.226.58.11,24,192.168.99.2,ahsz,server.crt 3,阜阳,ahfy225,43.226.58.1,43.226.58.12,24,192.168.99.3,ahfy,server.crt diff --git a/config.csv b/config.csv deleted file mode 100644 index 8e780ac..0000000 --- a/config.csv +++ /dev/null @@ -1,2 +0,0 @@ -index,name,code,gateway,public,mask,private,domain,cert -0,混拨1,hh1,43.226.58.1,43.226.58.9,24,192.168.98.1,hh,server.9.crt \ No newline at end of file diff --git a/main.py b/main.py index 1e858ca..c85fb03 100644 --- a/main.py +++ b/main.py @@ -30,7 +30,11 @@ failed = [] # 配置执行步骤 steps = [ - configLogs + configNet, + configOutsMix, + configScripts, + configLogs, + configDrop ] diff --git a/steps.py b/steps.py index 4739c47..1514c28 100644 --- a/steps.py +++ b/steps.py @@ -101,11 +101,58 @@ def configOuts(conn:Api,config): print('添加路由表失败: {}'.format(e)) continue +def configOutsMix(conn:Api,config): + ppps = conn.path('interface', 'l2tp-client') + for ppp in ppps: + if ppp['name'].startswith('l2tp-out'): + try: + ppps.remove(ppp['.id']) + except Exception as e: + print('删除 PPP 失败: {}'.format(e)) + continue + + for i in range(30): + for j in range(10): + n = j*30 + i + k = n%3 + 1 + + ppps.add(**{ + 'name':f'l2tp-out{n+1}', + 'connect-to':f'192.168.25{k}.25{k}', + 'user':f'jdzz{j+11}dt{i+221}', + 'password':'123231', + 'disabled':'no', + }) + + routes = conn.path('ip', 'route') + for route in routes: + if str(route['routing-table']).startswith('r'): + try: + routes.remove(route['.id']) + except Exception as e: + print('删除路由表失败: {}'.format(e)) + continue + + for i in range(300): + routeName = f'r{i+1}' + routeOut = f'l2tp-out{i+1}' + try: + routes.add(**{ + 'dst-address': '0.0.0.0/0', + 'gateway': routeOut, + 'routing-table': routeName, + }) + except Exception as e: + print('添加路由表失败: {}'.format(e)) + continue + + def configScripts(conn:Api,config): ''' 配置脚本 ''' + # 配置脚本 scripts = conn.path('system', 'script') for script in scripts: if script['name'] == 'up': @@ -137,6 +184,8 @@ def configScripts(conn:Api,config): 'source': pppoeStatusScript.replace('', config['public']) }) + # todo 配置计划任务 + def configLogs(conn:Api,config): ''' 配置日志处理 @@ -222,7 +271,7 @@ def configLogs(conn:Api,config): 'action': 'logremoteidc', }) -def addDrop(conn:Api, config): +def configDrop(conn:Api, config): ''' 添加丢弃规则 ''' diff --git a/templates/ros-58.10-宣城-0.vmdk b/templates/ros-58.10-宣城-0.vmdk new file mode 100644 index 0000000..2d459cf Binary files /dev/null and b/templates/ros-58.10-宣城-0.vmdk differ diff --git a/templates/ros-58.10-宣城.mf b/templates/ros-58.10-宣城.mf new file mode 100644 index 0000000..8d0a329 --- /dev/null +++ b/templates/ros-58.10-宣城.mf @@ -0,0 +1,2 @@ +SHA1(ros-test.nvram)= f9f46745698c658f483adcb0dc7a9d30144fc452 +SHA1(ros-58.10-宣城-0.vmdk)= 4b0f4ea68dc8b56bd7af112e593227324919c58a diff --git a/templates/ros-58.10-宣城.ovf b/templates/ros-58.10-宣城.ovf new file mode 100644 index 0000000..2b1540a --- /dev/null +++ b/templates/ros-58.10-宣城.ovf @@ -0,0 +1,219 @@ + + + + + + + + + Virtual disk information + + + + The list of logical networks + + The VM Network network + + + The address network + + + + A virtual machine + ros-58.10-宣城 + + The kind of installed guest operating system + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + ros-58.10-宣城 + vmx-08 + + + hertz * 10^6 + Number of Virtual CPUs + 2 virtual CPU(s) + 1 + 3 + 2 + 1 + + + byte * 2^20 + Memory Size + 1024MB of memory + 2 + 4 + 1024 + 1 + + + 1 + IDE Controller + VirtualIDEController 1 + 3 + 5 + 1 + + + 0 + IDE Controller + VirtualIDEController 0 + 4 + 5 + 1 + + + false + VirtualVideoCard + 5 + 24 + + + + + + 1 + + + false + VirtualVMCIDevice + 6 + vmware.vmci + 1 + + + 1 + + + 0 + Hard Disk 1 + ovf:/disk/vmdisk1 + 7 + 4 + 17 + + + 1 + + + 7 + true + VM Network + VmxNet3 ethernet adapter on "VM Network" + Ethernet 1 + 8 + VmxNet3 + 10 + + + + + + 1 + + + 8 + true + address + VmxNet3 ethernet adapter on "address" + Ethernet 2 + 9 + VmxNet3 + 10 + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A human-readable annotation + User: admin +Password: admin + + + diff --git a/templates/ros-test.nvram b/templates/ros-test.nvram new file mode 100644 index 0000000..4724682 Binary files /dev/null and b/templates/ros-test.nvram differ