Tuesday, February 23, 2016

Install asterisk 1.8.* in Ubuntu 14.04

Get the latest version of 1.8 * from asterisk download

Install dependencies
apt-get install build-essential libxml2-dev ncurses-dev libssl-dev subversion

--prefix is optional if you want to install asterisk in particular source directory
./configure CFLAGS=-pg LDFLAGS=-pg --prefix=/usr/local/

To do minimum or selected installation
make menuconfig 

make && make install
make samples && make config

To start asterisk
asterisk -i  or  /etc/init.d/asterisk start

connect to cli
asterisk -rvvvvvvvv

Sunday, February 7, 2016

Adding/pasting your HTML codes on Google blogger.

Thanks to http://hilite.me/

Paste your code here http://hilite.me/, it just converts your code to html highlighted format. Then you can copy paste it in compose mode and click on preview to see the magic!

<?php
    require_once __DIR__.'/google-api-php-client-2.1.1/vendor/autoload.php';
    date_default_timezone_set('asia/kolkata');
    session_start();

    // to find localhost and production server https
    if ($_SERVER['SERVER_NAME'] == "localhost") {
        $protocol = "http://";
    }else{
        $protocol = "https://";
    }
    $redirect_uri = $protocol . $_SERVER['HTTP_HOST'] . "/index.php";
    $client = new Google_Client();
    $client->setAuthConfigFile('key.json');
    $client->setRedirectUri($protocol . $_SERVER['HTTP_HOST'] . "/index.php");
    $client->setScopes('email'); // You want to retrieve email and domain name
    

// on logout
    if (isset($_REQUEST['logout'])) {
      unset($_SESSION['id_token_token']);
    }

// once you get code after auth success
    if (isset($_GET['code'])) {
      $token = $client->fetchAccessTokenWithAuthCode($_GET['code']);
      $client->setAccessToken($token);
      $_SESSION['id_token_token'] = $token;
      header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
    }
    if ( !empty($_SESSION['id_token_token']) && isset($_SESSION['id_token_token']['id_token']) ) {
      $client->setAccessToken($_SESSION['id_token_token']);
    } else {
      $authUrl = $client->createAuthUrl();
    }
    // success
    if ($client->getAccessToken()) {
      $token_data = $client->verifyIdToken();

// print all the data related after auth
      print_r($token_data)
    }
?>

 

Thursday, February 4, 2016

PHP asynchronous Http call using curl,shell_exec


?>php

for ($i = 0; $i &lt; 100; $i++){

  $cmd = 'nohup curl -H "Authorization: Basic yourRandomIOhere==" -H "Content-Type:        application/json" -X POST -d "{yourjson: "value"}" https://example.com/Message/ &gt; status.out &amp;';

  shell_exec($cmd);

}

print 'job done!';

?>


here:
100 : No of times you want to make this call
nohup:  to run in background
POST: http method, POST or GET
Authorization and content type is your option.

SIP,RTP capture with tshark and TCPdump

Tshark command to capture both SIP and RTP on media servers

This is useful if you don't know on which port SIP and UDP packetes comes from and can dump in pcap

tshark -i eth0 -w capture.pcap -f "(udp port sip) or (udp[1] & 1 != 1 && udp[3] & 1 != 1 && udp[8] & 0x80 == 0x80 && length < 250)"

-i  : specify your interface, If not use "any" to capture on all interfaces
-w : file to save


TCPdump to capture SIP on specific port! 
tcpdump -nqt -s 0 -A -i eth0 port 5060

Grep both SIP and UDP at same time.
tcpdump -n -i eth0 | grep 'SIP\|UDP'

CSS tricks

Mixed paint in background: background: linear-gradient(to right, #b6e358, #38b143) Grid view: display: grid; grid-template-columns: a...