Skip to content

Commit

Permalink
Merge branch 'patch-1' of git://github.com/CupIvan/cjdns into crashey
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdelisle committed May 29, 2016
2 parents afe2c2f + 2b20945 commit 5f66095
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contrib/php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A simple PHP API for the cjdns admin interface.
Usage
-------------
```php
<?
<?php
// Include the two files
require "Bencode.php";
require "Cjdns.php";
Expand All @@ -17,7 +17,7 @@ $cjdns = new Cjdns("password", "127.0.0.1", 11234);
print_r($cjdns->functions);

// Call one of them:
$ping = $cjdns->call("RouterModule_pingNode",array("path"=>"fc72:6c3b:8c74:68a7:d8c3:b4e0:6cbd:9588")));
$ping = $cjdns->call("RouterModule_pingNode",array("path"=>"fc72:6c3b:8c74:68a7:d8c3:b4e0:6cbd:9588"));

// Display the result:
print_r($ping);
Expand Down
24 changes: 24 additions & 0 deletions contrib/php/peerStats
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env php
<?php

require "Bencode.php";
require "Cjdns.php";

define('PASSWORD', 'NONE');

$cjdns = new Cjdns(PASSWORD, "127.0.0.1", 11234);
$res = $cjdns->call("InterfaceController_peerStats", 0);
$pattern = "| %13s | %11s | %17s | %10s | %10s | %5s | %3s | %2s |\n";
$br="+---------------+-------------+-------------------+------------+------------+-------+-----+----+\n";
printf($br);
printf($pattern, 'Public Key ', 'State ', 'Last ', 'Bytes In', 'Bytes Out', 'Lost', 'Ver', 'In');
printf($br);
foreach ($res['peers'] as $a)
{
$pK = $a['publicKey']; $pK = preg_replace('/^(.{4}).+?(.{6})$/', '$1...$2', $pK);
printf($pattern, $pK, $a['state'],
date('H:i:s d.m.y', $a['last']/1000),
$a['bytesIn'], $a['bytesOut'], $a['lostPackets'],
$a['version'], $a['isIncoming']);
}
printf($br);

0 comments on commit 5f66095

Please sign in to comment.