Subversion Repositories f9daq

Rev

Blame | Last modification | View Log | RSS feed

        location /get_tcpsocket_status {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
            
            default_type application/json;

            content_by_lua '
                local f = io.popen("systemctl is-active redpitaya_tcpsocket.service")
                local content = f:read("*all") 
                f:close() 
                ngx.say(content) 
            ';
        }

        location /start_tcpsocket_manager {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
            
            default_type application/json;

            content_by_lua '
                local f = io.popen("systemctl start redpitaya_tcpsocket.service")
                f:close() 
                ngx.say("OK") 
            ';
        }

        location /stop_tcpsocket_manager {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
            
            default_type application/json;

            content_by_lua '
                local f = io.popen("systemctl stop redpitaya_tcpsocket.service")
                f:close() 
                ngx.say("OK")  
            ';
        }





        location /get_rpip {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
            
            default_type application/json;

            content_by_lua '
                local eth = io.popen("ip -4 addr list eth0") 
                local wlan = io.popen("ip addr list wlan0wext") 
                local eth_content = eth:read("*all") 
                local wlan_content = wlan:read("*all") 
                eth:close() 
                wlan:close() 
                ngx.say(eth_content..";"..wlan_content)
            ';
        }