Browse Source

Networking code is now IPv6-ready

6.0
Alexis de Lattre 14 years ago
parent
commit
b8d0baa473
  1. 10
      asterisk_click2dial/asterisk_click2dial.py

10
asterisk_click2dial/asterisk_click2dial.py

@ -230,15 +230,17 @@ class asterisk_server(osv.osv):
logger.notifyChannel('asterisk_click2dial', netsvc.LOG_DEBUG, 'User dialing : channel = ' + user.asterisk_chan_type + '/' + user.internal_number + ' - Callerid = ' + user.callerid)
logger.notifyChannel('asterisk_click2dial', netsvc.LOG_DEBUG, 'Asterisk server = ' + ast_server.ip_address + ':' + str(ast_server.port))
# Connect to the Asterisk Manager Interface
# Connect to the Asterisk Manager Interface, using IPv6-ready code
try:
ast_ip = socket.gethostbyname(str(ast_server.ip_address))
res = socket.getaddrinfo(str(ast_server.ip_address), ast_server.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
except:
logger.notifyChannel('asterisk_click2dial', netsvc.LOG_DEBUG, "Can't resolve the DNS of the Asterisk server : " + str(ast_server.ip_address))
raise osv.except_osv(_('Error :'), _("Can't resolve the DNS of the Asterisk server : ") + str(ast_server.ip_address))
for result in res:
af, socktype, proto, canonname, sockaddr = result
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((ast_ip, ast_server.port))
sock = socket.socket(af, socktype, proto)
sock.connect(sockaddr)
sock.send('Action: login\r\n')
sock.send('Events: off\r\n')
sock.send('Username: '+str(ast_server.login)+'\r\n')

Loading…
Cancel
Save