|
@ -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, '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)) |
|
|
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: |
|
|
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: |
|
|
except: |
|
|
logger.notifyChannel('asterisk_click2dial', netsvc.LOG_DEBUG, "Can't resolve the DNS of the Asterisk server : " + str(ast_server.ip_address)) |
|
|
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)) |
|
|
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: |
|
|
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('Action: login\r\n') |
|
|
sock.send('Events: off\r\n') |
|
|
sock.send('Events: off\r\n') |
|
|
sock.send('Username: '+str(ast_server.login)+'\r\n') |
|
|
sock.send('Username: '+str(ast_server.login)+'\r\n') |
|
|