diff --git a/install.py b/install.py index c53f92a..c3ba3a0 100755 --- a/install.py +++ b/install.py @@ -12,7 +12,7 @@ from ipaddress import IPv4Interface from configparser import ConfigParser from os.path import join, getmtime, exists -os.chdir('to_system') +os.chdir('/root/aputools/to_system') DEL = '__to_delete__' CFGPATH = '/root/aputools/servercfg/%s.cfg' @@ -173,6 +173,8 @@ def network(doit): if doit: 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())) + os.system('ifdown %s' % ifname) + os.system('ifup %s' % ifname) else: dirty = 'dirty' print('%s changed:' % ifname) diff --git a/router.py b/router.py index e552632..545d173 100644 --- a/router.py +++ b/router.py @@ -1,3 +1,4 @@ +import sys import socket from select import select from serial import serial_for_url @@ -98,7 +99,7 @@ class AcceptHandler: :param: port offered port for routing :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 as a side effect, if the destination is a web server, the traffic are serialized (only one connection at a time), which helps for @@ -140,8 +141,13 @@ class AcceptHandler: if not self.available: self.pending += 1 return - client, addr = self.socket.accept() - handler = self.iocls(client, self) + try: + client, addr = self.socket.accept() + 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[handler.fno] = handler.reply self.available -= 1 diff --git a/servercfg/apumaster.cfg b/servercfg/apumaster.cfg index 525b36d..5ed07d3 100644 --- a/servercfg/apumaster.cfg +++ b/servercfg/apumaster.cfg @@ -1,9 +1,9 @@ [NETWORK] address=00:0d:b9:59:1f:ac enp1s0=dhcp -enp2s0=192.168.127.2/24 -enp3s0=192.168.2.3/24 -enp4s0=192.168.2.4/24 +enp2s0=192.168.2.1/24 +enp3s0=192.168.3.1/24 +enp4s0=192.168.127.1/24 [ROUTER] 3000=/dev/ttyUSB0