Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
eb06343
Delete mac_reg.cfg.org
Geekcrowds Jul 5, 2017
4fa3f97
Delete mac.cfg.org
Geekcrowds Jul 5, 2017
d0fe408
Delete config.json
Jul 5, 2017
cbcf48e
Update README.md
Jul 5, 2017
b7316e2
Small fixes/additions
grahamsnz Jul 5, 2017
a01d535
Update README.md
grahamsnz Jul 6, 2017
ce2677e
Update README.md
grahamsnz Jul 6, 2017
a7b099a
Update README.md
grahamsnz Jul 6, 2017
7aaba43
Update README.md
Jul 6, 2017
9b7bea2
Update README.md
Jul 6, 2017
8107f01
Update README.md
Jul 6, 2017
c933482
Update README.md
Jul 6, 2017
870788c
Update PROVISIONER_LICENSE.txt
Jul 6, 2017
1214f0b
Update README.md
Jul 7, 2017
5613cf2
fix multiline for vvx
Geekcrowds Jul 10, 2017
a628c8f
add fail2ban doc
Geekcrowds Jul 10, 2017
498ba62
add access list function
Geekcrowds Jul 11, 2017
d365ef2
edit setup db script
Geekcrowds Jul 11, 2017
990d60d
edit readme add api script
Geekcrowds Jul 11, 2017
592183a
Update README.md
Jul 12, 2017
2df078a
Update README.md
Jul 12, 2017
2e305a6
Update README.md
Jul 12, 2017
5705b68
setup_db.php
amanzella Jul 21, 2017
29b5e8f
Fixed providers design view
amanzella Jul 21, 2017
51dbdf0
Merge pull request #1 from amanzella/master
Jul 24, 2017
7f294e2
add grandstream gxp2170
Geekcrowds Aug 2, 2017
c9a5aca
Update README.md
Aug 2, 2017
ae611f2
Update README.md
Aug 2, 2017
1ba19e5
new grandstream thing
Geekcrowds Aug 3, 2017
b518099
Merge pull request #1 from OpenTelecom/master
amanzella Aug 3, 2017
9d2be55
Added Grandstream Brand Curl
amanzella Aug 3, 2017
18b49f8
add grandstream DB setting
Geekcrowds Aug 4, 2017
4918215
add img overwrite at README.md
Geekcrowds Aug 7, 2017
b5efdd2
add newthings for grandstream
Geekcrowds Aug 7, 2017
175b988
Update README.md
Aug 7, 2017
bf09b9b
fix access list
Geekcrowds Aug 8, 2017
ec0e32e
fix grandstream apk 13 problem
Geekcrowds Aug 18, 2017
76282ad
fix access list multiple line
Geekcrowds Aug 23, 2017
f7d4ff7
add muti line support for ACL
Geekcrowds Oct 10, 2017
3fe7479
Merge pull request #2 from OpenTelecom/master
amanzella Oct 31, 2017
1614261
Added VPK 33-48 for GS
amanzella Oct 31, 2017
ac9c3ac
Added device level wallpaper.
amanzella Nov 17, 2017
997fa9d
Added support for GXP2130
amanzella Nov 30, 2017
049a45b
Added MPK support for GXP2130/2160
amanzella Nov 30, 2017
bdb9959
Added Grandstream Info
amanzella Nov 30, 2017
3235f04
Fixed VPK 36
amanzella Dec 1, 2017
624878b
Added GAC2500
amanzella Dec 7, 2017
c43275a
Grandstream GAC Support
amanzella Dec 7, 2017
a580b84
Delete gac
amanzella Dec 7, 2017
b7cf647
Grandstream GAC Support
amanzella Dec 7, 2017
fb4a439
Grandstream GAC Support
amanzella Dec 7, 2017
ca27c2c
Grandstream GAC Support
amanzella Dec 7, 2017
2fbdd62
Added Grandstream GAC Support
amanzella Dec 7, 2017
0d2d01d
Added Grandstream GAC Support
amanzella Dec 7, 2017
5be3ce0
Update PROVISIONER_LICENSE.txt
amanzella Dec 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion PROVISIONER_LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ The Initial Developer of the Original Code is Andrew Nagy.
Portions created by the Initial Developer are Copyright (C) 2010
the Initial Developer. All Rights Reserved.

Further development by Open Telecom Foundation.

Contributor(s):
Andrew Nagy
Darren Schreiber
Jort Bloem
K Anderson
Raymond Chandler
Andrew Miffleton
Francis Genet
Francis Genet
Cameron Beattie
Yang Chen
Graham Nelson-Zutter
Anthony Manzella

Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
Expand Down
544 changes: 542 additions & 2 deletions README.md

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions adapter/2600hz/adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@

require_once LIB_BASE . 'KLogger.php';

function cidr_match($ip, $cidr)
{
list($subnet, $mask) = explode('/', $cidr);
if ((ip2long($ip) & ~((1 << (32 - $mask)) - 1) ) == ip2long($subnet))
{
return true;
}
return false;
}

function is_ip_allowed($ip, $account_doc, $log)
{
// allow,deny means allow only ips in the list
// deny,allow means deny only ips in the list
$allow_deny = $account_doc['access_lists']['order'] == "allow,deny";
$cidrs = $account_doc['access_lists']['cidrs'];
for ($i = 0; $i < count($cidrs); $i++) {
$log->logInfo('Checking IP ' . $ip . ' against CIDR ' . $cidrs[$i]);
if (cidr_match($ip, $cidrs[$i])) {
$log->logInfo('Matches CIDR ' . $cidrs[$i]);
return $allow_deny;
}
}
$log->logInfo('IP doesn\'t match any CIDR');
return !$allow_deny;
}

class adapter_2600hz_adapter {
private $account_id = null;
private $needs_manual_provisioning = false;
Expand Down Expand Up @@ -122,6 +149,17 @@ public function get_config_manager($uri, $ua, $http_host, $Clientip, $settings)
$phone_doc = $db->load_settings($account_db, $this->mac_address, false);

//$log->logInfo('phone_doc: ', $phone_doc);
$account_doc = $db->load_settings($account_db, $this->account_id, true);

// Check ACLs
$log->logInfo('Checking IP ' . $Clientip . ' in access list');
if (!is_ip_allowed($Clientip, $account_doc, $log)) {
// We want to block the request
$log->logInfo('IP is disallowed '.$account_doc['access_lists']['order'].' blocking request :'.$Clientip);
return false;
} else {
$log->logInfo('IP is allowed '.$account_doc['access_lists']['order'].' allowing request :'.$Clientip);
}

// If we have the doc for this phone but there are no brand or no family
if (!$phone_doc['brand'] or !$phone_doc['family'] or !$phone_doc['model']) {
Expand Down
10 changes: 10 additions & 0 deletions adapter/2600hz/master.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
"port": "{{ outbound_proxy.backup.port }}"
}
},
"wallpapersource": "{{ wallpapersource }}",
"wallpaperserverpath": "{{ wallpaperserverpath }}",
"hideblfremotestatus": "{{ hideblfremotestatus }}",
"acceptincomsipfromproxyonly1": "{{ acceptincomsipfromproxyonly1 }}",
"acceptincomsipfromproxyonly2": "{{ acceptincomsipfromproxyonly2 }}",
"acceptincomsipfromproxyonly3": "{{ acceptincomsipfromproxyonly3 }}",
"acceptincomsipfromproxyonly4": "{{ acceptincomsipfromproxyonly4 }}",
"acceptincomsipfromproxyonly5": "{{ acceptincomsipfromproxyonly5 }}",
"acceptincomsipfromproxyonly6": "{{ acceptincomsipfromproxyonly6 }}",
"userandomport": "{{ userandomport }}",
"siptrustctrl73": "{{ siptrustctrl73 }}",
"siptrustctrl80": "{{ siptrustctrl80 }}"
}
Expand Down
25 changes: 0 additions & 25 deletions config.json

This file was deleted.

152 changes: 152 additions & 0 deletions endpoint/grandstream/base.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<?PHP

/**
* Grandstream Base File
*
* @author Andrew Nagy
* @license MPL / GPLv2 / LGPL
* @package Provisioner
*/
class endpoint_grandstream_base extends endpoint_base {

public $brand_name = 'grandstream';

function reboot() {
if (($this->engine == "asterisk") AND ($this->system == "unix")) {
exec($this->engine_location . " -rx 'sip show peers like " . $this->settings['line'][0]['username'] . "'", $output);
if (preg_match("/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/", $output[1], $matches)) {
$ip = $matches[0];
$pass = (isset($this->settings['admin_pass']) ? $this->settings['admin_pass'] : 'admin');

if (function_exists('curl_init')) {
$ckfile = tempnam($this->sys_get_temp_dir(), "GSCURLCOOKIE");
$ch = curl_init('http://' . $ip . '/dologin.htm');
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);

$data = array(
'P2' => $pass,
'Login' => 'Login',
'gnkey' => '0b82'
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

$ch = curl_init("http://" . $ip . "/rs.htm");
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
}
}
}
}

function create_encrypted_file($list) {
$temporary_directory_location = function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : '/tmp';

foreach ($list as $key => $data) {
file_put_contents($temporary_directory_location . "/" . $key, $data);

if (file_exists("/usr/src/GS_CFG_GEN/bin/encode.sh")) {
exec("/usr/src/GS_CFG_GEN/bin/encode.sh " . $this->mac . " " . $temporary_directory_location . "/" . $this->mac . ".cfg " . $temporary_directory_location . "/cfg" . $this->mac);
$contents = file_get_contents($temporary_directory_location . "/cfg" . $this->mac);
unlink($temporary_directory_location . "/cfg" . $this->mac);
} else {
$params = $this->parse_gs_config($temporary_directory_location . "/" . $key);
$contents = $this->gs_config_out($this->mac, $params);
}

$files["cfg" . $this->mac] = $contents;
unlink($temporary_directory_location . "/" . $key);
}
return($files);
}

function prepare_for_generateconfig() {
//Grandstream likes lower case letters in its mac address
$this->mac = strtolower($this->mac);
parent::prepare_for_generateconfig();
$this->options['gs_timezone'] = 720 + $this->timezone['gmtoffset'] / 60;
}

function generate_file($file, $extradata, $ignoredynamicmapping=FALSE, $prepare=FALSE) {
$data = parent::generate_file($file, $extradata, $ignoredynamicmapping);
if ($ignoredynamicmapping == FALSE) {
$data = array_values($this->create_encrypted_file(array($this->mac . ".cfg" => $data)));
$data = $data[0];
}
return $data;
}

//Functions below were fixed by Schmoozecom.
function parse_gs_config($filename) {
if (!($f = @fopen($filename, "r"))) {
echo ("Unable to open " . $filename . "\n");
return FALSE;
}
while ($str = fgets($f)) {
$url_encode = false;
if (($pos = strpos($str, "#")) !== FALSE) {
$str = substr($str, 0, $pos);
}
if (($pos = strpos($str, '+')) !== FALSE) {
$url_encode = true;
}
if (strlen($str)) {
if (preg_match("/(.+)=(.*)/", $str, $matches)) {
if ($url_encode === true) {
$params[trim($matches[1])] = urlencode(trim($matches[2]));
} else {
$params[trim($matches[1])] = trim($matches[2]);
}
}
}
}
fclose($f);
return $params;
}

// MAC : 12 hex digits string
// $params : array ("P01" => "something", ...)
function gs_config_out($mac, $params) {
$prev = 0;
//if (!preg_match ("/^[0-9a-fA-F]{12}$/", $mac))
// return FALSE;
$params["gnkey"] = "0b82";
$str = "";
foreach ($params as $key => $val) {
if ($prev)
$str .= "&";
else
$prev = 1;
$str .= $key . "=" . $val;
}
if (strlen($str) & 1)
$str .= chr(0);
// Insert the beginning
$new_str = chr(0) . chr(0) . chr((16 + strlen($str)) / 2 >> 8 & 0xff) . chr((16 + strlen($str)) / 2 & 0xff) . chr(0) . chr(0);
// Insert the MAC address
for ($i = 0; $i < 6; $i++) {
$new_str .= chr(hexdec(substr($mac, $i * 2, 2)));
}
// Insert the end of the first line
$new_str .= chr(13) . chr(10) . chr(13) . chr(10) . $str;
// Basic checksum
$k = 0;
for ($i = 0; $i < strlen($new_str) / 2; $i++) {
$k += ord($new_str[$i * 2]) << 8 & 0xff00;
$k += ord($new_str[$i * 2 + 1]) & 0xff;
$k &= 0xffff;
}
$k = 0x10000 - $k;
$new_str[4] = chr($k >> 8 & 0xff);
$new_str[5] = chr($k & 0xff);
return $new_str;
}

}
113 changes: 113 additions & 0 deletions endpoint/grandstream/brand_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"data": {
"brands": {
"name": "Grandstream",
"directory": "grandstream",
"brand_id": "2",
"package": "grandstream.tgz",
"md5sum": "2b4fd590c8193fb7c24663176d678a37",
"last_modified": 1395185865,
"family_list": [
{
"id": "2",
"name": "BudgeTone series [200,201]",
"directory": "bts",
"description": "Fixed Timezone Issues + Use Grandstream Encrypted Compiler By Default",
"changelog": "",
"last_modified": null
},
{
"id": "1",
"name": "GXP Enterprise IP series [280,1200,2000,2010,2020]",
"directory": "gxp",
"description": "Use Grandstream Encrypted Compiler By Default",
"changelog": "",
"last_modified": null
},
{
"id": "5",
"name": "GAC Conference series [2500]",
"directory": "gac",
"description": "Use Grandstream Encrypted Compiler By Default",
"changelog": "",
"last_modified": null
},
{
"id": "4",
"name": "GXP Enterprise HD series [2100,2110,2120,2130,2160,2170]",
"directory": "gxphd",
"description": "Use Grandstream Encrypted Compiler By Default",
"changelog": "",
"last_modified": null
},
{
"id": "3",
"name": "HandyTone [HT486 REV.2, HT286 REV.3]",
"directory": "htx86",
"description": "",
"changelog": "",
"last_modified": null
}
],
"oui_list": [
"000B82"
],
"changelog": "PACKAGER: "
}
},
"gac2500": {
"folder": "gac",
"config_files": [
"cfg$mac.xml",
"cfg$mac",
"directory.xml"
],
"regexs": [
"/cfg.*/i",
"/[a-z0-9]{12}\\.xml/i",
"/directory\\.xml/i"
]
},
"gxp2160": {
"folder": "gxphd",
"config_files": [
"cfg$mac.xml",
"cfg$mac",
"directory.xml"
],
"regexs": [
"/cfg.*/i",
"/[a-z0-9]{12}\\.xml/i",
"/directory\\.xml/i"
]
},

"gxp2130": {
"folder": "gxphd",
"config_files": [
"cfg$mac.xml",
"cfg$mac",
"directory.xml"
],
"regexs": [
"/cfg.*/i",
"/[a-z0-9]{12}\\.xml/i",
"/directory\\.xml/i"
]
},


"gxp2170": {
"folder": "gxphd",
"config_files": [
"cfg$mac.xml",
"cfg$mac",
"directory.xml"
],
"regexs": [
"/cfg.*/i",
"/[a-z0-9]{12}\\.xml/i",
"/directory\\.xml/i"
]
}
}
Loading