Few fix on ikap implementation

parent cafdb270
......@@ -88,8 +88,8 @@ class DomIkaBaseProtocol(object):
self.initializated = False
def retriveMemKey(self):
if len(self.core.configGet('protocol', 'netpwd'))>4:
memkey=dmcrypt.DMHash256(self.core.configGet('protocol', 'netpwd'))
if len(self.core.configGet('ikap', 'netpwd'))>4:
memkey=dmcrypt.DMHash256(self.core.configGet('ikap', 'netpwd'))
log.info("Protocol password is configured")
else:
log.info("Protocol password is DEFAULT")
......@@ -99,8 +99,8 @@ class DomIkaBaseProtocol(object):
def checkTimeLimits(self, epoch):
# check if we are out of time limits
now=int(time.time())
if isTrue(self.core.configGet('protocol','timecheck')):
tollerance=int(self.core.configGet('protocol','tollerance'))
if isTrue(self.core.configGet('ikap','timecheck')):
tollerance=int(self.core.configGet('ikap','tollerance'))
if(int(epoch)<now-tollerance or int(epoch)>now+tollerance):
return False
return True
......@@ -115,7 +115,7 @@ class DomIkaBaseProtocol(object):
self.aesdata=AES256(struct.unpack('<8L', self.memkey), struct.unpack('<4L', self.memiv))
self.debugmode=False
if self.core.configGet('protocol','loglevel').lower()=='debug':
if self.core.configGet('ikap','loglevel').lower()=='debug':
self.debugmode=True
self.ikahdr=proto.IkaPacketHeader()
......@@ -292,8 +292,8 @@ class DomIkaUDP(DatagramProtocol, DomIkaBaseProtocol):
def retrivePort(self, msgtype):
if msgtype in [C.IKAP_BROADCAST, C.IKAP_MSG_REQUEST, C.IKAP_MSG_REQUESTCONF,
C.IKAP_MSG_SETCONF, C.IKAP_MSG_ACK]:
return int(self.core.configGet('ikapserver', 'port'))
return int(self.core.configGet('ikapserver', 'notifyport'))
return int(self.core.configGet('ikap', 'port'))
return int(self.core.configGet('ikap', 'notifyport'))
def startProtocol(self):
......@@ -301,7 +301,7 @@ class DomIkaUDP(DatagramProtocol, DomIkaBaseProtocol):
self.transport.socket.setsockopt(SOL_SOCKET, SO_BROADCAST, True)
try:
self.transport.socket.setsockopt(SOL_SOCKET, IN.SO_BINDTODEVICE,
self.core.configGet('ikapserver', 'ethdev'))
self.core.configGet('ikap', 'ethdev'))
except:
self.transport.socket.setsockopt(SOL_SOCKET, IN.SO_BINDTODEVICE, "eth0")
......@@ -310,7 +310,7 @@ class DomIkaUDP(DatagramProtocol, DomIkaBaseProtocol):
self.transport.socket.setsockopt(SOL_SOCKET, SO_BROADCAST, True)
try:
self.transport.socket.setsockopt(SOL_SOCKET, IN.SO_BINDTODEVICE,
self.core.configGet('ikapserver', 'ethdev'))
self.core.configGet('ikap', 'ethdev'))
except:
self.transport.socket.setsockopt(SOL_SOCKET, IN.SO_BINDTODEVICE, "eth0")
self.initializated = True
......@@ -323,7 +323,7 @@ class DomIkaUDP(DatagramProtocol, DomIkaBaseProtocol):
self.transport.socket.setsockopt(SOL_SOCKET, SO_BROADCAST, True)
try:
self.transport.socket.setsockopt(SOL_SOCKET, IN.SO_BINDTODEVICE,
self.core.configGet('ikapserver', 'ethdev'))
self.core.configGet('ikap', 'ethdev'))
except:
self.transport.socket.setsockopt(SOL_SOCKET, IN.SO_BINDTODEVICE, "eth0")
......@@ -334,7 +334,7 @@ class DomIkaUDP(DatagramProtocol, DomIkaBaseProtocol):
log.debug('SEND UDP PACKET: %r' % p.cleanpacket())
def datagramReceived(self, data, (host, port)):
return self.ikapPacketReceived(data, (host, int(self.core.configGet('ikapserver', 'port'))), 'UDP4')
return self.ikapPacketReceived(data, (host, int(self.core.configGet('ikap', 'port'))), 'UDP4')
......@@ -420,6 +420,6 @@ class DomIkaServerFactory(ServerFactory):
if __name__ == '__main__':
from twisted.internet import reactor
reactor.listenUDP(6654, DomIkaUDP(), self.core.configGet('ikapserver', 'interface'))
reactor.listenUDP(6654, DomIkaUDP(), self.core.configGet('ikap', 'interface'))
reactor.run()
......@@ -83,8 +83,11 @@ class penguidomService(service.Service):
to the instance of the higher level object initialization or by
setting it using the abstraction of the ConvenienceCaller metaclass
"""
try:
try:
f=getattr(self, who+'_on_'+cmd)
except:
f=getattr(self, 'on_'+cmd)
if f and callable(f):
return f
except:
......@@ -110,5 +113,6 @@ class penguidomService(service.Service):
self.tcp = ikap.DomIkaServerFactory(caller)
return self.tcp
def on_configGet(self, section, var):
return self.config.get(section, var)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment