Giter Club home page Giter Club logo

astmanproxy's People

Contributors

abstractdrift avatar augcampos avatar danieldbower avatar davies147 avatar nud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

astmanproxy's Issues

Send-Q Back Logged

Having an odd issue where the Send-Q for the TCP Socket is back-logged, and astmanproxy crashes. This happens when the client connected to the proxy loses internet connectivity unexpectedly, the proxy doesn't know how to handle that sudden disconnect. Any ideas on how we can address this?

Segmentation fault on drop server

Hi!
I've configured 2 ami hosts (both are works well)
When I try to Drop one of them, using ProxyAction=DropServer, astmanproxy fails on Segmentation fault

astmanproxy: Version 1.30.0, (C) David C. Troy 2005-2008

Here gdb log:

[root@MYHOST services]# gdb -args astmanproxy -ddddddddd
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-119.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/sbin/astmanproxy...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/local/sbin/astmanproxy -ddddddddd
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Oct 26 14:14:51: config: parsing configuration file: /etc/asterisk/astmanproxy.conf
Oct 26 14:14:51: config: host, AMI_HOST_TO_DROP,5038,admin,AMI_1ST_PASS,off,off
Oct 26 14:14:51: config: host, AMI_HOST_SECOND,5038,admin,AMI_2ND_PASS,off,off
Oct 26 14:14:51: config: retryinterval, 2
Oct 26 14:14:51: config: maxretries, 0
Oct 26 14:14:51: config: sslclienthellotimeout, 200
Oct 26 14:14:51: config: acceptencryptedconnection, yes
Oct 26 14:14:51: config: acceptunencryptedconnection, yes
Oct 26 14:14:51: config: asteriskwritetimeout, 100
Oct 26 14:14:51: config: clientwritetimeout, 200
Oct 26 14:14:51: config: listenaddress, *
Oct 26 14:14:51: config: listenport, 5039
Oct 26 14:14:51: config: authrequired, no
Oct 26 14:14:51: config: proc_user, asterisk
Oct 26 14:14:51: config: proc_group, asterisk
Oct 26 14:14:51: config: inputformat, http
Oct 26 14:14:51: config: outputformat, standard
Oct 26 14:14:51: config: autofilter, on
Oct 26 14:14:51: config: logfile, /var/log/asterisk/astmanproxy.log
Oct 26 14:14:51: SSL critical error: Failed to use the certificate file!
Oct 26 14:14:51: loading handlers
Oct 26 14:14:51: loading: module xml (/usr/lib/astmanproxy/modules/xml.so)
Oct 26 14:14:51: loading: note, xml_onconnect does not exist; ignoring
Oct 26 14:14:51: loading: module standard (/usr/lib/astmanproxy/modules/standard.so)
Oct 26 14:14:51: loading: module csv (/usr/lib/astmanproxy/modules/csv.so)
Oct 26 14:14:51: loading: note, csv_read does not exist; ignoring
Oct 26 14:14:51: loading: note, csv_onconnect does not exist; ignoring
Oct 26 14:14:51: loading: module http (/usr/lib/astmanproxy/modules/http.so)
Oct 26 14:14:51: loading: note, http_write does not exist; ignoring
Oct 26 14:14:51: loading: note, http_onconnect does not exist; ignoring
Oct 26 14:14:51: loaded handlers
Oct 26 14:14:51: config: parsing configuration file: /etc/asterisk/astmanproxy.users
Oct 26 14:14:51: Client SSL Context Initialized
Oct 26 14:14:51: asterisk@AMI_HOST_SECOND: Allocated server session
Oct 26 14:14:51: Set AMI_HOST_SECOND input format to standard
Oct 26 14:14:51: Set AMI_HOST_SECOND output format to standard
[New Thread 0x7ffff4abf700 (LWP 11478)]
Oct 26 14:14:51: launched ast AMI_HOST_SECOND thread!
Oct 26 14:14:51: asterisk@AMI_HOST_SECOND: Connecting (u=admin, p=AMI_2ND_PASS, ssl=off)
Oct 26 14:14:51: returning ast_connect with 9
Oct 26 14:14:51: Transmitting standard block of 4 lines, fd 9
Oct 26 14:14:51: asterisk@AMI_HOST_SECOND: attempting read...
Oct 26 14:14:51: get_input returned line 1, res 0, 
Oct 26 14:14:51: get_input returned line 1, res 1, Asterisk Call Manager/2.10.4
Oct 26 14:14:51: get_input returned line 2, res 0, 
Oct 26 14:14:51: get_input returned line 2, res 1, Response: Success
Oct 26 14:14:51: get_input returned line 3, res 1, Message: Authentication accepted
Oct 26 14:14:51: get_input returned line 4, res 1, 
Oct 26 14:14:51: Returning standard block of 3 lines, res 1
Oct 26 14:14:51: asterisk@AMI_HOST_SECOND got: Asterisk Call Manager/2.10.4
Oct 26 14:14:51: asterisk@AMI_HOST_SECOND got: Response: Success
Oct 26 14:14:51: asterisk@AMI_HOST_SECOND got: Message: Authentication accepted
Oct 26 14:14:51: asterisk@AMI_HOST_SECOND: connected successfully!
Oct 26 14:14:51: asterisk@AMI_HOST_SECOND: connected successfully (No Fullybooted)!
Oct 26 14:14:51: asterisk@AMI_HOST_SECOND: attempting read...
Oct 26 14:14:51: asterisk@AMI_HOST_TO_DROP: Allocated server session
Oct 26 14:14:51: Set AMI_HOST_TO_DROP input format to standard
Oct 26 14:14:51: Set AMI_HOST_TO_DROP output format to standard
[New Thread 0x7ffff3ebd700 (LWP 11480)]
Oct 26 14:14:51: launched ast AMI_HOST_TO_DROP thread!
Oct 26 14:14:51: Listening for connections
Oct 26 14:14:51: asterisk@AMI_HOST_TO_DROP: Connecting (u=admin, p=AMI_1ST_PASS, ssl=off)
Oct 26 14:14:51: returning ast_connect with 10
Oct 26 14:14:51: Transmitting standard block of 4 lines, fd 10
Oct 26 14:14:51: asterisk@AMI_HOST_TO_DROP: attempting read...
Oct 26 14:14:51: get_input returned line 1, res 0, 
Oct 26 14:14:51: get_input returned line 1, res 1, Asterisk Call Manager/2.10.4
Oct 26 14:14:51: get_input returned line 2, res 0, 
Oct 26 14:14:51: get_input returned line 2, res 1, Response: Success
Oct 26 14:14:51: get_input returned line 3, res 1, Message: Authentication accepted
Oct 26 14:14:51: get_input returned line 4, res 1, 
Oct 26 14:14:51: Returning standard block of 3 lines, res 1
Oct 26 14:14:51: asterisk@AMI_HOST_TO_DROP got: Asterisk Call Manager/2.10.4
Oct 26 14:14:51: asterisk@AMI_HOST_TO_DROP got: Response: Success
Oct 26 14:14:51: asterisk@AMI_HOST_TO_DROP got: Message: Authentication accepted
Oct 26 14:14:51: asterisk@AMI_HOST_TO_DROP: connected successfully!
Oct 26 14:14:51: asterisk@AMI_HOST_TO_DROP: connected successfully (No Fullybooted)!
Oct 26 14:14:51: asterisk@AMI_HOST_TO_DROP: attempting read...
Oct 26 14:14:56: is_encrypted: 0
Oct 26 14:14:56: Connection received from CLIENT_HOST
Oct 26 14:14:56: Set CLIENT_HOST input format to http
Oct 26 14:14:56: Set CLIENT_HOST output format to standard
[New Thread 0x7ffff32bb700 (LWP 11711)]
Oct 26 14:14:56: calling http_read...
Oct 26 14:14:56: res=0, line: 
Oct 26 14:14:56: res=1, line: GET /?ProxyAction=DropServer&Server=AMI_HOST_TO_DROP HTTP/1.1
Oct 26 14:14:56: Got http: GET /?ProxyAction=DropServer&Server=AMI_HOST_TO_DROP HTTP/1.1 (57 bytes)
Oct 26 14:14:56: res=1, line: Host: MYHOST:5039
Oct 26 14:14:56: Got http: Host: MYHOST:5039 (53 bytes)
Oct 26 14:14:56: res=1, line: Connection: keep-alive
Oct 26 14:14:56: Got http: Connection: keep-alive (22 bytes)
Oct 26 14:14:56: res=1, line: Cache-Control: max-age=0
Oct 26 14:14:56: Got http: Cache-Control: max-age=0 (24 bytes)
Oct 26 14:14:56: res=1, line: Upgrade-Insecure-Requests: 1
Oct 26 14:14:56: Got http: Upgrade-Insecure-Requests: 1 (28 bytes)
Oct 26 14:14:56: res=1, line: User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Oct 26 14:14:56: Got http: User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 (117 bytes)
Oct 26 14:14:56: res=1, line: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Oct 26 14:14:56: Got http: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 (143 bytes)
Oct 26 14:14:56: res=1, line: Accept-Encoding: gzip, deflate
Oct 26 14:14:56: Got http: Accept-Encoding: gzip, deflate (30 bytes)
Oct 26 14:14:56: res=1, line: Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
Oct 26 14:14:56: Got http: Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7 (52 bytes)
Oct 26 14:14:56: res=1, line: 
Oct 26 14:14:56: http header: HTTP/1.1 200 OK
Date: Mon, 26 Oct 2020 14:14:56 +0300
Content-Type: text/plain
Connection: close
Server: Asterisk Call Manager Proxy/1.30.0

Oct 26 14:14:56: n: ProxyAction=DropServer&Server=AMI_HOST_TO_DROP, v: DropServer&Server=AMI_HOST_TO_DROP
Oct 26 14:14:56: got hdr: ProxyAction: DropServer
Oct 26 14:14:56: n: Server=AMI_HOST_TO_DROP, v: AMI_HOST_TO_DROP
Oct 26 14:14:56: got hdr: Server: AMI_HOST_TO_DROP
Oct 26 14:14:56: http_read result = 1
Oct 26 14:14:56: client@CLIENT_HOST got: ProxyAction: DropServer
Oct 26 14:14:56: client@CLIENT_HOST got: Server: AMI_HOST_TO_DROP
Oct 26 14:14:56: Connection closed: AMI_HOST_TO_DROP
Oct 26 14:14:56: Freed entire stack.
Oct 26 14:14:56: Dropping Server AMI_HOST_TO_DROP
Oct 26 14:14:56: Transmitting standard block of 2 lines, fd 12
Oct 26 14:14:56: calling http_read...
Oct 26 14:14:57: http_read result = -1
Oct 26 14:14:57: Connection closed: CLIENT_HOST
Oct 26 14:14:57: Freed entire stack.
Oct 26 14:14:57: --- exiting session_do thread ---
Oct 26 14:14:57: get_input returned line 1, res -1, 
Oct 26 14:14:57: Read error -1 getting line
Oct 26 14:14:57: Returning standard block of 0 lines, res -1

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff3ebd700 (LWP 11480)]
0x0000000000405dab in HandleAsterisk ()
(gdb) 


(gdb) 
(gdb) 
(gdb) 
(gdb) thread apply all bt

Thread 4 (Thread 0x7ffff32bb700 (LWP 11711)):
#0  read_sleb128 (p=0x7ffff40bc215 "x\020\001\033\f\a\b\220\001", val=val@entry=0x7ffff327a950) at ../../../libgcc/unwind-pe.h:154
#1  0x00007ffff40b7dad in extract_cie_info (fs=0x7ffff327a9b0, context=0x7ffff327ab60, cie=0x7ffff40bc208) at ../../../libgcc/unwind-dw2.c:443
#2  uw_frame_state_for (context=context@entry=0x7ffff327ab60, fs=fs@entry=0x7ffff327a9b0) at ../../../libgcc/unwind-dw2.c:1262
#3  0x00007ffff40b86ed in uw_init_context_1 (context=context@entry=0x7ffff327ab60, outer_cfa=outer_cfa@entry=0x7ffff327ad90, outer_ra=0x7ffff7757322 <__GI___pthread_unwind+66>)
    at ../../../libgcc/unwind-dw2.c:1566
#4  0x00007ffff40b8cd6 in _Unwind_ForcedUnwind (exc=0x7ffff32bbd70, stop=stop@entry=0x7ffff77571a0 <unwind_stop>, stop_argument=0x7ffff32bae30) at ../../../libgcc/unwind.inc:201
#5  0x00007ffff7757322 in __GI___pthread_unwind (buf=<optimized out>) at unwind.c:129
#6  0x00007ffff7751eb7 in __do_cancel () at pthreadP.h:285
#7  __pthread_exit (value=<optimized out>) at pthread_exit.c:28
#8  0x0000000000405496 in session_do ()
#9  0x00007ffff7750e65 in start_thread (arg=0x7ffff32bb700) at pthread_create.c:307
#10 0x00007ffff747988d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 3 (Thread 0x7ffff3ebd700 (LWP 11480)):
#0  0x0000000000405dab in HandleAsterisk ()
#1  0x00007ffff7750e65 in start_thread (arg=0x7ffff3ebd700) at pthread_create.c:307
#2  0x00007ffff747988d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 2 (Thread 0x7ffff4abf700 (LWP 11478)):
#0  0x00007ffff746ebed in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x000000000040790e in get_input ()
#2  0x00007ffff54d9a34 in _read () from /usr/lib/astmanproxy/modules/standard.so
#3  0x0000000000405af2 in HandleAsterisk ()
#4  0x00007ffff7750e65 in start_thread (arg=0x7ffff4abf700) at pthread_create.c:307
#5  0x00007ffff747988d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 1 (Thread 0x7ffff7fe4840 (LWP 11473)):
#0  0x00007ffff7470953 in select () at ../sysdeps/unix/syscall-template.S:81
#1  0x000000000040aa5d in is_encrypt_request ()
#2  0x0000000000403ee3 in main ()

Maybe I'm doing something wrong with proxy action?

Segmentation fault

Hi!

Trying to execute Action=COMMAND&COMMAND=pjsip show endpoints, astmanproxy returns 200 OK with empty text and crashes on error Segmentation fault on http GET request

url = "http://ASTMANPROXY_HOST:PROXY_PORT?Action=COMMAND&COMMAND=pjsip show endpoints"
response = requests.get(url)

OS CentOS 7
Asterisk certified/13.21-cert4

astmanproxy.log

[[email protected]]# astmanproxy -dddddddddd
Oct 15 13:11:15: config: parsing configuration file: /etc/asterisk/astmanproxy.conf
Oct 15 13:11:15: config: host, AMI_HOST,5038,ami_user,ami_pass,off,off
Oct 15 13:11:15: config: retryinterval, 2
Oct 15 13:11:15: config: maxretries, 10
Oct 15 13:11:15: config: sslclienthellotimeout, 200
Oct 15 13:11:15: config: acceptencryptedconnection, yes
Oct 15 13:11:15: config: acceptunencryptedconnection, yes
Oct 15 13:11:15: config: asteriskwritetimeout, 100
Oct 15 13:11:15: config: clientwritetimeout, 200
Oct 15 13:11:15: config: listenaddress, *
Oct 15 13:11:15: config: listenport, 5039
Oct 15 13:11:15: config: authrequired, no
Oct 15 13:11:15: config: proc_user, asterisk
Oct 15 13:11:15: config: proc_group, asterisk
Oct 15 13:11:15: config: inputformat, http
Oct 15 13:11:15: config: outputfomat, standard
Oct 15 13:11:15: config: autofilter, on
Oct 15 13:11:15: config: logfile, /var/log/asterisk/astmanproxy.log
Oct 15 13:11:15: SSL critical error: Failed to use the certificate file!
Oct 15 13:11:15: loading handlers
Oct 15 13:11:15: loading: module xml (/usr/lib/astmanproxy/modules/xml.so)
Oct 15 13:11:15: loading: note, xml_onconnect does not exist; ignoring
Oct 15 13:11:15: loading: module standard (/usr/lib/astmanproxy/modules/standard.so)
Oct 15 13:11:15: loading: module csv (/usr/lib/astmanproxy/modules/csv.so)
Oct 15 13:11:15: loading: note, csv_read does not exist; ignoring
Oct 15 13:11:15: loading: note, csv_onconnect does not exist; ignoring
Oct 15 13:11:15: loading: module http (/usr/lib/astmanproxy/modules/http.so)
Oct 15 13:11:15: loading: note, http_write does not exist; ignoring
Oct 15 13:11:15: loading: note, http_onconnect does not exist; ignoring
Oct 15 13:11:15: loaded handlers
Oct 15 13:11:15: config: parsing configuration file: /etc/asterisk/astmanproxy.users
Oct 15 13:11:15: Client SSL Context Initialized
Oct 15 13:11:15: asterisk@AMI_HOST: Allocated server session
Oct 15 13:11:15: Set AMI_HOST input format to standard
Oct 15 13:11:15: Set AMI_HOST output format to standard
Oct 15 13:11:15: launched ast AMI_HOST thread!
Oct 15 13:11:15: Listening for connections
Oct 15 13:11:15: asterisk@AMI_HOST: Connecting (u=ami_user, p=ami_pass, ssl=off)
Oct 15 13:11:15: returning ast_connect with 4
Oct 15 13:11:15: Transmitting standard block of 4 lines, fd 4
Oct 15 13:11:15: asterisk@AMI_HOST: attempting read...
Oct 15 13:11:15: Returning standard block of 3 lines, res 1
Oct 15 13:11:15: asterisk@AMI_HOST got: Asterisk Call Manager/2.10.4
Oct 15 13:11:15: asterisk@AMI_HOST got: Response: Success
Oct 15 13:11:15: asterisk@AMI_HOST got: Message: Authentication accepted
Oct 15 13:11:15: asterisk@AMI_HOST: connected successfully!
Oct 15 13:11:15: Not sending server message back to a server
Oct 15 13:11:15: asterisk@AMI_HOST: attempting read...




-----here I sent my request------

Oct 15 13:12:45: is_encrypted: 0
Oct 15 13:12:45: Connection received from MY_HOST
Oct 15 13:12:45: Set MY_HOST input format to http
Oct 15 13:12:45: Set MY_HOST output format to http
Oct 15 13:12:45: calling http_read...
Oct 15 13:12:45: res=0, line:
Oct 15 13:12:45: res=1, line: GET /?Action=COMMAND&COMMAND=pjsip%20show%20endpoints&ActionID=queue HTTP/1.1
Oct 15 13:12:45: Got http: GET /?Action=COMMAND&COMMAND=pjsip%20show%20endpoints&ActionID=queue HTTP/1.1 (77 bytes)
Oct 15 13:12:45: res=1, line: Host: tel-pbx2-platforma-pre-test.unix.tensor.ru:5039
Oct 15 13:12:45: Got http: Host: tel-pbx2-platforma-pre-test.unix.tensor.ru:5039 (53 bytes)
Oct 15 13:12:45: res=1, line: Accept: */*
Oct 15 13:12:45: Got http: Accept: */* (11 bytes)
Oct 15 13:12:45: res=1, line: User-Agent: python-requests/2.22.0
Oct 15 13:12:45: Got http: User-Agent: python-requests/2.22.0 (34 bytes)
Oct 15 13:12:45: res=1, line: Connection: keep-alive
Oct 15 13:12:45: Got http: Connection: keep-alive (22 bytes)
Oct 15 13:12:45: res=1, line: Accept-Encoding: gzip, deflate
Oct 15 13:12:45: Got http: Accept-Encoding: gzip, deflate (30 bytes)
Oct 15 13:12:45: res=1, line: Content-Type: text/plain
Oct 15 13:12:45: Got http: Content-Type: text/plain (24 bytes)
Oct 15 13:12:45: res=1, line: Server: AMI_HOST
Oct 15 13:12:45: Got http: Server: AMI_HOST (20 bytes)
Oct 15 13:12:45: res=1, line:
Oct 15 13:12:45: http header: HTTP/1.1 200 OK
Date: Thu, 15 Oct 2020 13:12:45 +0300
Content-Type: text/plain
Connection: close
Server: Asterisk Call Manager Proxy/1.28.3

Oct 15 13:12:45: n: Action=COMMAND&COMMAND=pjsip show endpoints&ActionID=queue, v: COMMAND&COMMAND=pjsip show endpoints&ActionID=queue
Oct 15 13:12:45: got hdr: Action: COMMAND
Oct 15 13:12:45: n: COMMAND=pjsip show endpoints&ActionID=queue, v: pjsip show endpoints&ActionID=queue
Oct 15 13:12:45: got hdr: COMMAND: pjsip show endpoints
Oct 15 13:12:45: n: ActionID=queue, v: queue
Oct 15 13:12:45: got hdr: ActionID: queue
Oct 15 13:12:45: http_read result = 1
Oct 15 13:12:45: ValidateAction called for fd: 6, outbound
Oct 15 13:12:45: Message validated - no filtering
Oct 15 13:12:45: writing block to AMI_HOST
Oct 15 13:12:45: Transmitting standard block of 3 lines, fd 4
Oct 15 13:12:45: calling http_read...
Oct 15 13:12:45: Found Response Follows
Oct 15 13:12:45: Found END COMMAND
Oct 15 13:12:45: Returning standard block of 238 lines, res 1
Oct 15 13:12:45: asterisk@AMI_HOST got: Response: Follows
Oct 15 13:12:45: asterisk@AMI_HOST got: Privilege: Command
Oct 15 13:12:45: asterisk@AMI_HOST got: ActionID: queue
Oct 15 13:12:45: asterisk@AMI_HOST got:
Oct 15 13:12:45: asterisk@AMI_HOST got:  Endpoint:  <Endpoint/CID.....................................>  <State.....>  <Channels.>
Oct 15 13:12:45: asterisk@AMI_HOST got:     I/OAuth:  <AuthId/UserName...........................................................>
Oct 15 13:12:45: asterisk@AMI_HOST got:         Aor:  <Aor............................................>  <MaxContact>
Oct 15 13:12:45: asterisk@AMI_HOST got:       Contact:  <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..>
Oct 15 13:12:45: asterisk@AMI_HOST got:   Transport:  <TransportId........>  <Type>  <cos>  <tos>  <BindAddress..................>
Oct 15 13:12:45: asterisk@AMI_HOST got:    Identify:  <Identify/Endpoint.........................................................>
Oct 15 13:12:45: asterisk@AMI_HOST got:         Match:  <criteria.........................>
Oct 15 13:12:45: asterisk@AMI_HOST got:     Channel:  <ChannelId......................................>  <State.....>  <Time.....>
Oct 15 13:12:45: asterisk@AMI_HOST got:         Exten: <DialedExten...........>  CLCID: <ConnectedLineCID.......>
Oct 15 13:12:45: asterisk@AMI_HOST got: ==========================================================================================
Oct 15 13:12:45: asterisk@AMI_HOST got:
...
Oct 15 13:12:45: asterisk@AMI_HOST got:  Endpoint:  5902/5902                                            Unavailable   0 of 1
Oct 15 13:12:45: asterisk@AMI_HOST got:      InAuth:  5902/5902
Oct 15 13:12:45: asterisk@AMI_HOST got:         Aor:  5902                                              10
Oct 15 13:12:45: asterisk@AMI_HOST got:
Oct 15 13:12:45: asterisk@AMI_HOST got:  Endpoint:  5905/5905                                            Unavailable   0 of 1
Oct 15 13:12:45: asterisk@AMI_HOST got:      InAuth:  5905/5905
Oct 15 13:12:45: asterisk@AMI_HOST got:         Aor:  5905                                              10
Oct 15 13:12:45: asterisk@AMI_HOST got:
Oct 15 13:12:45: asterisk@AMI_HOST got:  Endpoint:  5907/5907                                            Unavailable   0 of inf
Oct 15 13:12:45: asterisk@AMI_HOST got:      InAuth:  5907/5907
Oct 15 13:12:45: asterisk@AMI_HOST got:         Aor:  5907                                              10
Oct 15 13:12:45: asterisk@AMI_HOST got:   Transport:  udp-transport             udp      0     96  0.0.0.0:5060
...
Oct 15 13:12:45: asterisk@AMI_HOST got:
Oct 15 13:12:45: asterisk@AMI_HOST got:
Oct 15 13:12:45: asterisk@AMI_HOST got: Objects found: 45
Oct 15 13:12:45: asterisk@AMI_HOST got:
Oct 15 13:12:45: asterisk@AMI_HOST got: --END COMMAND--
Oct 15 13:12:45: Autofilter = 1, ActionID = queue
Oct 15 13:12:45: Checking ActionID filtering
Oct 15 13:12:45: ValidateAction called for fd: 6, inbound
Oct 15 13:12:45: Message validated - no filtering
Oct 15 13:12:45: Validate allowed a message to a client, ret=1
Segmentation fault
You have mail in /var/spool/mail/root
[[email protected]]#

/etc/asterisk/astmanproxy.conf

; astmanproxy.conf
; Asterisk Manager Proxy Configuration Sample
; (C) 2005-2008 David C. Troy - [email protected]

host = ami_port,ami_port,ami_user, ami_pass,off,off

retryinterval = 2

maxretries = 10

sslclienthellotimeout = 200

acceptencryptedconnection = yes

acceptunencryptedconnection = yes

asteriskwritetimeout=100

clientwritetimeout=200

listenaddress = *

listenport = 5039
authrequired = no

proc_user = asterisk
proc_group = asterisk

inputformat = http
outputfomat = standard
autofilter = on

logfile = /var/log/asterisk/astmanproxy.log

The same error occurs when sending GET request http://ASTMANPROXY_HOST:PROXY_PORT/?Action=Ping


Oct 15 15:32:33: n: Action=Ping, v: Ping
Oct 15 15:32:33: got hdr: Action: Ping
Oct 15 15:32:33: http_read result = 1
Oct 15 15:32:33: client@MY_HOST got: Action: Ping
Oct 15 15:32:33: ValidateAction called for fd: 6, outbound
Oct 15 15:32:33: Message validated - no filtering
Oct 15 15:32:33: writing block to AMI_HOST
Oct 15 15:32:33: Transmitting standard block of 1 lines, fd 4
Oct 15 15:32:33: calling http_read...
Oct 15 15:32:33: Returning standard block of 3 lines, res 1
Oct 15 15:32:33: asterisk@AMI_HOST got: Response: Success
Oct 15 15:32:33: asterisk@AMI_HOST got: Ping: Pong
Oct 15 15:32:33: asterisk@AMI_HOST got: Timestamp: 1602765153.367440
Oct 15 15:32:33: Autofilter = 1, ActionID =
Oct 15 15:32:33: Checking ActionID filtering
Oct 15 15:32:33: ValidateAction called for fd: 6, inbound
Oct 15 15:32:33: Message validated - no filtering
Oct 15 15:32:33: Validate allowed a message to a client, ret=1
Segmentation fault
[root@... asterisk]#

Maybe I'm doing something wrong.
I would appreciate any help.

Segfault on linux alpine

Trying to get astmanproxy up&running within a Linux alpine docker container. Compilation performs perfectly, so does install, and actual launch but it segfault while trying to establish AMI connection to upstream.

Not clear what could be the issue at this stage but I could share my docker image if there's need to.

Events are getting through

Using autofilter = unique and asterisk 18.8.0, there are still events that "leaking through":

# telnet localhost 5039
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Asterisk Call Manager Proxy/1.30.0
action: login
username: xxxxx
secret: xxxxx
events: off

Response: Success
Message: Authentication accepted

Event: FullyBooted
Privilege: system,all
Status: Fully Booted

Response: Success
ActionID: 1663154460.2415
Message: Event Sent
Server: localhost

Response: Success
ActionID: amp6-1663154465.6838
EventList: start
Message: Queue status will follow
Server: localhost

Event: QueueStatusComplete
ActionID: amp6-1663154465.6838
EventList: Complete
ListItems: 0
Server: localhost

Response: Success
ActionID: amp6-1663154465.6853
EventList: start
Message: Queue status will follow
Server: localhost

action: logoff

Response: Goodbye
Message: Thanks for all the fish.

Connection closed by foreign host.

I presume it has to do with the EventList: start thing (added in ast 13 I think).

Poking around in the code (astmanproxy.c), but failing - where could this be fixed?

CR\LN

When the Action is Command. using asterisk-java is not working because the output is \r\n not \n

Server shuts down if none of the hosts from the configuration connect successfully

Hi!

My case is: I have some configuration file with ami servers list, which can be updated dynamically. It can't be guarantied that all of them working well at start. I use this config file to generate astmanproxy's one.

As far as I know from readme, astmanproxy supports proxy actions such as AddServer/DropServer/ListSessions to control connections.

Is it possible to update code in the way like follows?

  1. Host list in config is not a necessary option.
  2. After server start with no hosts in config, clients can manage connections via proxy actions.

Same problem arrives when I drop all connections via proxy action DropServer - server just shutdown when no any connections.

Thanks in advance!

Uppercase letters in ami_password became lowercase

Hi!
If my ami_password containts uppercase letters, when I try to start astmanproxy, it received "Authentication failed error".
Astmanproxy replaces all uppercase letters of the password with lowercase:

in astmanproxy.conf:
host = AMI_HOST,AMI_PORT,ami_user,MyAmiPassword,off,off

in log:

Oct 15 16:24:08: asterisk@AMI_HOST: Connecting (u=ami_user, p=myamipassword, ssl=off)

Segfault in ListSession proxy action

Hi,

I'm getting a segmentation fault whenever I try to do ProxyAction: ListSessions:

$ telnet localhost 1234
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Asterisk Call Manager Proxy/1.28.2
ProxyAction: ListSessions

Connection closed by foreign host.

I've pined down the problem to proxyfunc.c line 53: I've changed the line to:
AddHeader(&m, "ProxyClientActionID: %s", c->actionid); and it seems to work now. I'm no C expert, but from my understanding there's no need for the ||"" expression since vsprintf will properly format even if c->actionid is full of \0 (as was my case).

Connection reset by peer in ver 1.30

Hi!
In WIP branch v.1.30 when I call http GET ?Action=Ping I receive "ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))"
Proxy actions not working too:
http://proxy_host:proxy_port?ProxyAction=ListSessions
returns same error

(gdb) run
Starting program: /root/astmanproxy_fork/astmanproxy -ddddddddd
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Oct 16 13:05:51: config: parsing configuration file: /etc/asterisk/astmanproxy.conf
Oct 16 13:05:51: config: host, ami_host,5038,ami_user,ami_pass,off,off
Oct 16 13:05:51: config: retryinterval, 2
Oct 16 13:05:51: config: maxretries, 10
Oct 16 13:05:51: config: sslclienthellotimeout, 200
Oct 16 13:05:51: config: acceptencryptedconnection, yes
Oct 16 13:05:51: config: acceptunencryptedconnection, yes
Oct 16 13:05:51: config: asteriskwritetimeout, 100
Oct 16 13:05:51: config: clientwritetimeout, 200
Oct 16 13:05:51: config: listenaddress, *
Oct 16 13:05:51: config: listenport, 1234
Oct 16 13:05:51: config: authrequired, no
Oct 16 13:05:51: config: proc_user, asterisk
Oct 16 13:05:51: config: proc_group, asterisk
Oct 16 13:05:51: config: inputformat, http
Oct 16 13:05:51: config: outputformat, standard
Oct 16 13:05:51: config: autofilter, on
Oct 16 13:05:51: config: logfile, /var/log/asterisk/astmanproxy.log
Oct 16 13:05:51: SSL critical error: Failed to use the certificate file!
Oct 16 13:05:51: loading handlers
Oct 16 13:05:51: loading: module xml (/usr/lib/astmanproxy/modules/xml.so)
Oct 16 13:05:51: loading: note, xml_onconnect does not exist; ignoring
Oct 16 13:05:51: loading: module standard (/usr/lib/astmanproxy/modules/standard.so)
Oct 16 13:05:51: loading: module csv (/usr/lib/astmanproxy/modules/csv.so)
Oct 16 13:05:51: loading: note, csv_read does not exist; ignoring
Oct 16 13:05:51: loading: note, csv_onconnect does not exist; ignoring
Oct 16 13:05:51: loading: module http (/usr/lib/astmanproxy/modules/http.so)
Oct 16 13:05:51: loading: note, http_write does not exist; ignoring
Oct 16 13:05:51: loading: note, http_onconnect does not exist; ignoring
Oct 16 13:05:51: loaded handlers
Oct 16 13:05:51: config: parsing configuration file: /etc/asterisk/astmanproxy.users
Oct 16 13:05:51: Client SSL Context Initialized
Oct 16 13:05:51: asterisk@ami_host: Allocated server session
Oct 16 13:05:51: Set ami_host input format to standard
Oct 16 13:05:51: Set ami_host output format to standard
[New Thread 0x7ffff4abf700 (LWP 27558)]
Oct 16 13:05:51: launched ast ami_host thread!
Oct 16 13:05:51: asterisk@ami_host: Connecting (u=ami_user, p=ami_pass, ssl=off)
Oct 16 13:05:51: Listening for connections
Oct 16 13:05:51: returning ast_connect with 9
Oct 16 13:05:51: Transmitting standard block of 4 lines, fd 9
Oct 16 13:05:51: asterisk@ami_host: attempting read...
Oct 16 13:05:51: get_input returned line 1, res 0,
Oct 16 13:05:51: get_input returned line 1, res 1, Asterisk Call Manager/2.10.4
Oct 16 13:05:51: get_input returned line 2, res 0,
Oct 16 13:05:51: get_input returned line 2, res 1, Response: Success
Oct 16 13:05:51: get_input returned line 3, res 1, Message: Authentication accepted
Oct 16 13:05:51: get_input returned line 4, res 1,
Oct 16 13:05:51: Returning standard block of 3 lines, res 1
Oct 16 13:05:51: asterisk@ami_host got: Asterisk Call Manager/2.10.4
Oct 16 13:05:51: asterisk@ami_host got: Response: Success
Oct 16 13:05:51: asterisk@ami_host got: Message: Authentication accepted
Oct 16 13:05:51: asterisk@ami_host: connected successfully!
Oct 16 13:05:51: asterisk@ami_host: attempting read...


Oct 16 13:06:07: is_encrypted: 0
Oct 16 13:06:07: Connection received from my_host
Oct 16 13:06:07: Set my_host input format to http
Oct 16 13:06:07: Set my_host output format to standard
[New Thread 0x7fffefbfe700 (LWP 30248)]
Oct 16 13:06:12: Connection closed: my_host
Oct 16 13:06:12: Freed entire stack.
Oct 16 13:06:12: --- exiting session_do thread ---
[Thread 0x7fffefbfe700 (LWP 30248) exited]



-----here I pressed Ctrl+C to get back access to console

^C
Program received signal SIGINT, Interrupt.
0x00007ffff775799d in accept () at ../sysdeps/unix/syscall-template.S:81
81      T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) thread apply all bt

Thread 2 (Thread 0x7ffff4abf700 (LWP 27558)):
#0  0x00007ffff746ebed in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x000000000040788e in get_input ()
#2  0x00007ffff54d9a34 in _read () from /usr/lib/astmanproxy/modules/standard.so
#3  0x0000000000405af2 in HandleAsterisk ()
#4  0x00007ffff7750e65 in start_thread (arg=0x7ffff4abf700) at pthread_create.c:307
#5  0x00007ffff747988d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 1 (Thread 0x7ffff7fe4840 (LWP 27554)):
#0  0x00007ffff775799d in accept () at ../sysdeps/unix/syscall-template.S:81
#1  0x0000000000403e99 in main ()
(gdb)

No authentication needed when autofilter == on

Hello,

Thank you for this proxy, it seems great !

  • When I set "autofilter = on" in astmanproxy.conf, and I connect to the proxy with telnet, the AMI events are displayed, event if I am not authenticated.
  • When I set "autofilter = off", no events are displayed before I authenticate.

Have you this problem, too ?

I checked out the proxy today (rev 4e37f98). I'll try to understand the code, but don't know C !

Thank you.

If server A is down, request is sent to server B

My request is like :

actionid: 1394553381.47397
action: QueuePause
Interface: SIP/300
Queue: zTest
Paused: false
ProxyKey: xxxxxxx
Server: 127.0.0.1

Astmanproxy logs :

Mar 11 12:01:10: connect_nonb: error 103, closing old fd and grabbing a new one...
Mar 11 12:01:10: [email protected]: Connect failed, Retrying (1) Software caused connection abort [103]
Mar 11 12:01:12: [email protected]: Connect failed, Retrying (1) Connection refused [111]
Mar 11 12:01:12: is_encrypted: 0
Mar 11 12:01:12: Connection received from 127.0.0.1
Mar 11 12:01:12: Set 127.0.0.1 input format to standard
Mar 11 12:01:12: Set 127.0.0.1 output format to standard
Mar 11 12:01:12: calling standard_read...
Mar 11 12:01:12: Returning standard block of 5 lines, res 1
Mar 11 12:01:12: standard_read result = 1
Mar 11 12:01:12: ValidateAction called for fd: 9, outbound
Mar 11 12:01:12: Message validated - no filtering
Mar 11 12:01:12: set destination: 127.0.0.1
Mar 11 12:01:12: writing block to 172.16.0.249
(...)

Config :

host = 127.0.0.1, 5038, ami_user, ami_password, off, off
host = 172.16.0.249, 5038, ami_user, ami_password, off, off

I think that if "Server" is not given in request, it could be OK to send it to the next server if the first one is down, but when "Server" is given, it should return an error, shouldn't it ?

PS : I use the master branch, up to date.

case sentitive ?

Hello Steve,

Your last version 1.24pre090304 presents problems with case sensitive with context.
my astmanproxy.users contains DLPN_DialPlan1 as context but astmanproxy considers dlpn_dialplan1

In the version 1.22pre081119, the problem does not occur.

Logs with 1.24pre
Aug 10 20:32:16: standard_read result = 1

Aug 10 20:32:16: Attempting filter using channel: sip/6001

Aug 10 20:32:16: Message not filtered (chan): SIP/6001 due to match

Aug 10 20:32:16: Message filtered (ctxt): DLPN_DialPlan1 != dlpn_dialplan1

Aug 10 20:32:16: calling standard_read..

Regards

100% cpu on raspberry pi

when starting astmanproxy on a raspberry pi, the cpu goes to 99% cpu . Astmanproxy never manages to connect to the asterisk instance

Anyone seen this ? What steps can I take to see where the problem may be ?

We do use astmanproxy on a centos installation with no problems at all

Long AMI Responses Timeout

Having some problems with receiving long responses from the AMI when going through the proxy.
By "long responses" I mean many lines of text, such as the result of the core show help AMI command which is 257 lines.

I made some tests using the AsterNET library in C#.

using AsterNET.Manager;
using AsterNET.Manager.Action;
using AsterNET.Manager.Response;

public string[] LongResponseTest()
{
    ManagerConnection myManagerConn = new ManagerConnection();
    myManagerConn.Hostname = _hostname;
    myManagerConn.Port = _port;
    myManagerConn.Username = _userName;
    myManagerConn.Password = _userSecret;
    try
    {
        myManagerConn.Login();
        CommandResponse commandActionResponse = (CommandResponse)myManagerConn.SendAction(new CommandAction("core show help"));
        return commandActionResponse.Result.ToArray();
    }
    catch (Exception ex)
    {
        throw;
    }
    finally
    {
        myManagerConn.Logoff();
    }
}

This code works when targeting the AMI directly, but timeout when using the proxy. Even setting SendAction's timeout property to 60000 results in a timeout.

I have found no settings in the proxy's configuration that could be causing this, but I could have missed something. The proxy is running mostly default configuration without SSL.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.