bei mir läuft der Trunk der Telekom erfolgreich mit folgenden Einstellungen.
<?php
define( 'GS_VALID', true ); /// this is a parent file
ini_set('implicit_flush', 1);
ob_implicit_flush(1);
error_reporting(0);
require_once( dirName(__FILE__) .'/../../inc/conf.php' );
require_once( GS_DIR .'inc/util.php' );
require_once( GS_DIR .'inc/log.php' );
set_error_handler('err_handler_quiet');
if (! gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
require_once( GS_DIR .'inc/get-listen-to-ids.php' );
require_once( GS_DIR .'inc/gs-lib.php' );
include_once( GS_DIR .'inc/gs-fns/gs_hosts_get.php' );
$our_ids = @ gs_get_listen_to_ids();
if (! is_array($our_ids)) $our_ids = array();
//echo 'OUR IDS: ', implode(', ', $our_ids), "\n";
$hosts = @ gs_hosts_get();
if (isGsError( $hosts )) $hosts = array();
if (! $hosts) $hosts = array();
//echo "HOSTS:\n"; print_r($hosts);
$min_our_ids = (count($our_ids) > 0) ? min($our_ids) : 0;
if ($min_our_ids < 1) {
gs_log(GS_LOG_WARNING, 'This server is not configured to be a Gemeinschaft node. Not registering to other nodes.');
} else {
$outUser = 'gs-'. str_pad( $min_our_ids, 4, '0', STR_PAD_LEFT );
$out = '';
foreach ($hosts as $host) {
if (in_array( (int)$host['id'], $our_ids )) {
//echo "SKIPPING ", $host['id'], "\n";
continue;
} else {
//echo "DOING ", $host['id'], "\n";
}
# it's one of the other nodes
$inUser = 'gs-'. str_pad( $host['id'], 4, '0', STR_PAD_LEFT );
$inPass = 'thiS is rEally seCret.';
$inPass = subStr( str_replace(
array( '+', '/', '=' ),
array( '', '', '' ),
base64_encode( $inPass )
), 0, 25 );
$outPass = $inPass;
$name = str_pad( $host['id'], 4, '0', STR_PAD_LEFT );
$out .= 'register => '. $outUser .'@gs-'. $name .'/'. $inUser ."\n";
}
echo "\n", $out;
}
}
echo "\n";
# get gateways from DB
#
require_once( GS_DIR .'inc/db_connect.php' );
$DB = gs_db_master_connect();
if (! $DB) {
exit(1);
}
$rs = $DB->execute(
'SELECT
`g`.`name`, `g`.`host`, `g`.`proxy`, `g`.`user`, `g`.`authuser`, `g`.`pwd`,
`gg`.`name` `gg_name`
FROM
`gates` `g` JOIN
`gate_grps` `gg` ON (`gg`.`id`=`g`.`grp_id`)
WHERE
`g`.`type`=\'sip\' AND
`g`.`host` IS NOT NULL AND
`g`.`register`= 1
ORDER BY `g`.`id`'
);
while ($gw = $rs->fetchRow()) {
if ($gw['host'] != '' && $gw['user'] != '') {
if ($gw['host'] == '
sip-trunk.telekom.de') {
echo 'register => tcp://';
echo $gw['user'];
echo '@';
echo $gw['host'];
echo ':';
echo $gw['pwd'];
echo ':';
echo $gw['authuser'];
echo '@';
echo $gw['proxy'];
echo ':5060/';
echo $gw['user'];
echo "\n";
} else {
if ($gw['proxy'] == null || $gw['proxy'] === $gw['host']) {
$gw['proxy'] = null;
}
// Format for registration is user[:secret[:authuser]]@host[:port][/contact]
if (preg_match('/@([^@]*)$/', $gw['user'], $m)) {
$gw['fromdomain'] = $m[1]; # domain for the From header. like
# setting fromdomain in the peer definition
$gw['user'] = subStr($gw['user'], 0, -(strLen($gw['fromdomain'])+1) );
} else {
$gw['fromdomain'] = '';
}
echo 'register => ', $gw['user']; # user
if ($gw['fromdomain'] != '') {
echo '@', $gw['fromdomain']; # domain
}
if ($gw['pwd'] != '') {
echo ':', $gw['pwd']; # password
if ($gw['user'] != '') {
echo ':', $gw['user']; # authuser
}
}
echo '@';
//echo $gw['name']; # peer definition
if ($gw['proxy'] == null) {
echo $gw['host']; # host
} else {
echo $gw['proxy']; # proxy
}
if ($gw['user'] != '') {
echo '/', $gw['user']; # contact
}
echo "\n";
}
}
}
echo "\n";
?>
#!/usr/bin/php -q
<?php
define( 'GS_VALID', true ); /// this is a parent file
ini_set('implicit_flush', 1);
ob_implicit_flush(1);
error_reporting(0);
require_once( dirName(__FILE__) .'/../../inc/conf.php' );
require_once( GS_DIR .'inc/util.php' );
set_error_handler('err_handler_quiet');
require_once( GS_DIR .'inc/log.php' );
require_once( GS_DIR .'inc/langhelper.php' );
if (! gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
require_once( GS_DIR .'inc/get-listen-to-ids.php' );
require_once( GS_DIR .'inc/gs-lib.php' );
include_once( GS_DIR .'inc/gs-fns/gs_hosts_get.php' );
$our_ids = @ gs_get_listen_to_ids();
if (! is_array($our_ids)) $our_ids = array();
//echo 'OUR IDS: ', implode(', ', $our_ids), "\n";
$hosts = @ gs_hosts_get();
if (isGsError( $hosts )) $hosts = array();
if (! $hosts) $hosts = array();
//echo "HOSTS:\n"; print_r($hosts);
$min_our_ids = (count($our_ids) > 0) ? min($our_ids) : 0;
$outUser = 'gs-'. str_pad( $min_our_ids, 4, '0', STR_PAD_LEFT );
$out = '';
foreach ($hosts as $host) {
if (in_array( (int)$host['id'], $our_ids )) {
//echo "SKIPPING ", $host['id'], "\n";
continue;
} else
//echo "DOING ", $host['id'], "\n";
# it's one of the other nodes
$inUser = 'gs-'. str_pad( $host['id'], 4, '0', STR_PAD_LEFT );
$inPass = 'thiS is rEally seCret.';
$inPass = subStr( str_replace(
array( '+', '/', '=' ),
array( '', '', '' ),
base64_encode( $inPass )
), 0, 25 );
$outPass = $inPass;
$name = str_pad( $host['id'], 4, '0', STR_PAD_LEFT );
$out .= '
[gs-'. $name .'](node-user)
host='. $host['host'] .'
defaultip='. $host['host'] .'
username='. $inUser .'
secret='. $inPass .'
setvar=__from_node=yes
[gs-'. $name .'](node-peer)
host='. 'dynamic' .'
defaultip='. $host['host'] .'
username='. $outUser .'
fromuser='. $outUser .'
secret='. $outPass .'
setvar=__from_node=yes
';
}
echo $out;
}
echo "\n";
# get gateways from DB
#
require_once( GS_DIR .'inc/db_connect.php' );
$DB = gs_db_master_connect();
if (! $DB) {
exit(1);
}
$rs = $DB->execute(
'SELECT
`g`.`id`, `g`.`name`, `g`.`host`, `g`.`proxy`, `g`.`user`, `g`.`authuser`, `g`.`pwd`,
`gg`.`name` `gg_name`
FROM
`gates` `g` JOIN
`gate_grps` `gg` ON (`gg`.`id`=`g`.`grp_id`)
WHERE
`g`.`type`=\'sip\' AND
`g`.`host` IS NOT NULL
ORDER BY `g`.`id`'
);
while ($gw = $rs->fetchRow()) {
if ($gw['name'] == '') continue;
if ($gw['host'] == '') continue;
$params = array();
$params['transport' ] = 'tcp';
$params['nat' ] = 'force_rport,comedia';
$params['canreinvite' ] = 'no';
$params['defaultuser' ] = $gw['authuser'];
$params['fromdomain' ] = $gw['host'];
$params['secret' ] = $gw['pwd'];
$params['insecure' ] = 'port,invite';
$params['directmedia' ] = 'no';
$params['port' ] = 5060;
$params['call-limit' ] = 0;
$params['qualify' ] = 'yes';
$params['dtmfmode' ] = 'rfc2833';
$params['session-timers'] = 'refuse';
// $params['registertimeout'] = '60';
$params['registertimeout'] = '480';
$params['maxexpiry' ] = 185;
$params['defaultexpiry' ] = 145;
$params['permit' ] = null;
$codecs_allow = array();
$codecs_allow['g722' ] = true;
$codecs_allow['alaw' ] = true;
$codecs_allow['ulaw' ] = false;
if ($gw['proxy'] == null || $gw['proxy'] === $gw['host']) {
$gw['proxy'] = null;
}
$params_override = array();
$params_rs = $DB->execute( 'SELECT `param`, `value` FROM `gate_params` WHERE `gate_id`='.$gw['id'] );
while ($param = $params_rs->fetchRow()) {
$params_override[$param['param']] = $param['value'];
}
if (array_key_exists('port' , $params_override)) {
//&& (int)$params_override['port' ] != 0) {
$params['port' ] = $params_override['port' ];
}
if (array_key_exists('canreinvite' , $params_override)) {
$params['canreinvite' ] = $params_override['canreinvite' ];
}
if (array_key_exists('qualify' , $params_override)) {
$params['qualify' ] = $params_override['qualify' ];
}
if (array_key_exists('call-limit' , $params_override)) {
$params['call-limit' ] = $params_override['call-limit' ];
}
if (array_key_exists('dtmfmode' , $params_override)) {
$params['dtmfmode' ] = $params_override['dtmfmode' ];
}
if (array_key_exists('allow' , $params_override)) {
foreach ($codecs_allow as $codec => $allow) {
$codecs_allow[$codec] = false;
}
$params_override_codecs = preg_split('/\s*,\s*/', trim($params_override['allow']));
foreach ($params_override_codecs as $codec) {
$codecs_allow[$codec] = true;
}
$num_allowed_codecs = 0;
foreach ($codecs_allow as $codec => $allow) {
if ($allow) ++$num_allowed_codecs;
}
if ($num_allowed_codecs < 1) {
gs_log( GS_LOG_WARNING, 'You did not allow any codecs for gateway '. $gw['name'] .'. Allowing G.711a by default.' );
$codecs_allow['alaw' ] = true;
}
}
if (array_key_exists('permit' , $params_override)
&& 'x'.$params_override['permit' ] != 'x'.'
0.0.0.0/0') {
$params['permit' ] = $params_override['permit' ];
}
echo '[', $gw['name'] ,']' ,"\n";
echo 'context = ' , 'from-gg-'.$gw['gg_name' ] ,"\n";
echo 'type = ' , 'peer' ,"\n";
echo 'host = ' , $gw['proxy' ] ,"\n";
echo 'transport = ' , $params['transport' ] ,"\n";
echo 'sendrpid = ' , 'no' ,"\n";
echo 'nat = ' , $params['nat' ] ,"\n";
echo 'defaultuser = ' , $params['defaultuser' ] ,"\n";
echo 'fromdomain = ' , $params['fromdomain' ] ,"\n";
echo 'secret = ' , $gw['pwd' ] ,"\n";
echo 'insecure = ' , $params['insecure' ] ,"\n";
echo 'directmedia = ' , 'no' ,"\n";
echo 'videosupport = ' , 'no' ,"\n";
echo 'usereqphone = ' , 'yes' ,"\n";
echo 'srvlookup = ' , 'yes' ,"\n";
echo 'canreinvite = ' , $params['canreinvite' ] ,"\n";
echo 'dtmfmode = ' , $params['dtmfmode' ] ,"\n";
echo 'call-limit = ' , $params['call-limit' ] ,"\n";
echo 'session-timers = ' , $params['session-timers' ] ,"\n";
echo 'registertimeout = ' , $params['registertimeout'] ,"\n";
echo 'maxexpiry = ' , $params['maxexpiry'] ,"\n";
echo 'defaultexpiry = ' , $params['defaultexpiry'] ,"\n";
echo 'setvar=__is_from_gateway=1' ,"\n";
echo 'qualify = ' , $params['qualify' ] ,"\n";
echo 'disallow = ' , 'all' ,"\n";
echo 'language = ' , 'de' ,"\n";
foreach ($codecs_allow as $codec => $allowed) {
if ($allowed) {
echo 'allow = ', $codec ,"\n";
}
}
if ($params['permit' ] != null
&& 'x'.$params['permit' ] != 'x'.'
0.0.0.0/0') {
echo 'deny = ' ,'
0.0.0.0/0.0.0.0' ,"\n"; # deny all
echo 'permit = ' , $params['permit' ] ,"\n";
}
echo "\n";
}
?>