fixed an issue cuaisng router to die
- router should not die when an error happens when connecting to HW + install will restart changed network interfaces
This commit is contained in:
@ -12,7 +12,7 @@ from ipaddress import IPv4Interface
|
|||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
from os.path import join, getmtime, exists
|
from os.path import join, getmtime, exists
|
||||||
|
|
||||||
os.chdir('to_system')
|
os.chdir('/root/aputools/to_system')
|
||||||
|
|
||||||
DEL = '__to_delete__'
|
DEL = '__to_delete__'
|
||||||
CFGPATH = '/root/aputools/servercfg/%s.cfg'
|
CFGPATH = '/root/aputools/servercfg/%s.cfg'
|
||||||
@ -173,6 +173,8 @@ def network(doit):
|
|||||||
if doit:
|
if doit:
|
||||||
with open('/etc/sysconfig/network-scripts/ifcfg-%s' % ifname, 'w') as f:
|
with open('/etc/sysconfig/network-scripts/ifcfg-%s' % ifname, 'w') as f:
|
||||||
f.write('%s\n' % '\n'.join('%s=%s' % kv for kv in content.items()))
|
f.write('%s\n' % '\n'.join('%s=%s' % kv for kv in content.items()))
|
||||||
|
os.system('ifdown %s' % ifname)
|
||||||
|
os.system('ifup %s' % ifname)
|
||||||
else:
|
else:
|
||||||
dirty = 'dirty'
|
dirty = 'dirty'
|
||||||
print('%s changed:' % ifname)
|
print('%s changed:' % ifname)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import sys
|
||||||
import socket
|
import socket
|
||||||
from select import select
|
from select import select
|
||||||
from serial import serial_for_url
|
from serial import serial_for_url
|
||||||
@ -98,7 +99,7 @@ class AcceptHandler:
|
|||||||
|
|
||||||
:param: port offered port for routing
|
:param: port offered port for routing
|
||||||
:param: addr where to route
|
:param: addr where to route
|
||||||
:param: iocls the io ahndler class, currently TcpHandler or SerialHandler
|
:param: iocls the io handler class, currently TcpHandler or SerialHandler
|
||||||
:param: maxcount the maximal number of concurrent connections. defauls to 1
|
:param: maxcount the maximal number of concurrent connections. defauls to 1
|
||||||
as a side effect, if the destination is a web server, the traffic
|
as a side effect, if the destination is a web server, the traffic
|
||||||
are serialized (only one connection at a time), which helps for
|
are serialized (only one connection at a time), which helps for
|
||||||
@ -140,8 +141,13 @@ class AcceptHandler:
|
|||||||
if not self.available:
|
if not self.available:
|
||||||
self.pending += 1
|
self.pending += 1
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
client, addr = self.socket.accept()
|
client, addr = self.socket.accept()
|
||||||
handler = self.iocls(client, self)
|
handler = self.iocls(client, self)
|
||||||
|
except Exception as e:
|
||||||
|
print('ERROR creating %s(%r)' % (self.iocls.__name__, self.addr))
|
||||||
|
client.close()
|
||||||
|
return
|
||||||
self.readers[client.fileno()] = handler.request
|
self.readers[client.fileno()] = handler.request
|
||||||
self.readers[handler.fno] = handler.reply
|
self.readers[handler.fno] = handler.reply
|
||||||
self.available -= 1
|
self.available -= 1
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
[NETWORK]
|
[NETWORK]
|
||||||
address=00:0d:b9:59:1f:ac
|
address=00:0d:b9:59:1f:ac
|
||||||
enp1s0=dhcp
|
enp1s0=dhcp
|
||||||
enp2s0=192.168.127.2/24
|
enp2s0=192.168.2.1/24
|
||||||
enp3s0=192.168.2.3/24
|
enp3s0=192.168.3.1/24
|
||||||
enp4s0=192.168.2.4/24
|
enp4s0=192.168.127.1/24
|
||||||
|
|
||||||
[ROUTER]
|
[ROUTER]
|
||||||
3000=/dev/ttyUSB0
|
3000=/dev/ttyUSB0
|
||||||
|
Reference in New Issue
Block a user