diff --git a/lib/NGCP/Panel/Controller/Customer.pm b/lib/NGCP/Panel/Controller/Customer.pm index 26c71b7c4f..c2217deedb 100644 --- a/lib/NGCP/Panel/Controller/Customer.pm +++ b/lib/NGCP/Panel/Controller/Customer.pm @@ -1236,6 +1236,10 @@ sub pbx_device_sync :Chained('pbx_device_base') :PathPart('sync') :Args(0) { } my $dev = $c->stash->{pbx_device}; + my $schema = $c->config->{deviceprovisioning}->{secure} ? 'https' : 'http'; + my $host = $c->config->{deviceprovisioning}->{host} // $c->req->uri->host; + my $port = $c->config->{deviceprovisioning}->{port} // 1444; + my $t = Template->new; my $conf = { client => { @@ -1243,7 +1247,7 @@ sub pbx_device_sync :Chained('pbx_device_base') :PathPart('sync') :Args(0) { }, server => { - uri => 'http://' . $c->req->uri->host . ':' . ($c->config->{web}->{autoprov_plain_port} // '1444') . '/device/autoprov/config', + uri => "$schema://$host:$port/device/autoprov/config", }, }; my ($sync_uri, $real_sync_uri) = ("", ""); diff --git a/lib/NGCP/Panel/Controller/Device.pm b/lib/NGCP/Panel/Controller/Device.pm index a06ddd147b..f5b9e9f521 100644 --- a/lib/NGCP/Panel/Controller/Device.pm +++ b/lib/NGCP/Panel/Controller/Device.pm @@ -946,6 +946,10 @@ sub dev_field_config :Chained('/') :PathPart('device/autoprov/config') :Args() { return; } + my $schema = $c->config->{deviceprovisioning}->{secure} ? 'https' : 'http'; + my $host = $c->config->{deviceprovisioning}->{host} // $c->req->uri->host; + my $port = $c->config->{deviceprovisioning}->{port} // 1444; + if($id =~ /^[a-fA-F0-9]{12}\.cfg$/ && $c->req->user_agent =~ /PolycomVVX/ ) { @@ -985,7 +989,7 @@ sub dev_field_config :Chained('/') :PathPart('device/autoprov/config') :Args() { my $vars = { config => { - url => 'http://' . $c->req->uri->host . ':' . ($c->config->{web}->{autoprov_plain_port} // '1444') . '/device/autoprov/config/' . $id, + url => "$schema://$host:$port/device/autoprov/config/$id", }, firmware => { }, @@ -994,14 +998,12 @@ sub dev_field_config :Chained('/') :PathPart('device/autoprov/config') :Args() { lineranges => [], }, directory => { - spaurl => 'http://' . $c->req->uri->host . ':' . ($c->config->{web}->{autoprov_plain_port} // '1444') . '/pbx/directory/spa/' . $id, + spaurl => "$schema://$host:$port/pbx/directory/spa/$id", name => 'PBX Address Book', } }; - $vars->{firmware}->{baseurl} = 'http://' . $c->req->uri->host . ':' . - ($c->config->{web}->{autoprov_plain_port} // '1444') . - '/device/autoprov/firmware'; + $vars->{firmware}->{baseurl} = "$schema://$host:$port/device/autoprov/firmware"; my $latest_fw = $c->model('DB')->resultset('autoprov_firmwares')->search({ device_id => $model->id, }, { diff --git a/lib/NGCP/Panel/Controller/Pbx.pm b/lib/NGCP/Panel/Controller/Pbx.pm index 5b3c60821b..1ccd26e404 100644 --- a/lib/NGCP/Panel/Controller/Pbx.pm +++ b/lib/NGCP/Panel/Controller/Pbx.pm @@ -16,10 +16,22 @@ sub auto :Private { return 1; } -sub spa_directory_getsearch :Chained('/') :PathPart('pbx/directory/spasearch') :Args(1) { +sub base :Chained('/') :PathPart('') :CaptureArgs(0) { + my ($self, $c) = @_; + + $c->stash->{schema} = $c->config->{deviceprovisioning}->{secure} ? 'https' : 'http'; + $c->stash->{host} = $c->config->{deviceprovisioning}->{host} // $c->req->uri->host; + $c->stash->{port} = $c->config->{deviceprovisioning}->{port} // 1444; +} + +sub spa_directory_getsearch :Chained('base') :PathPart('pbx/directory/spasearch') :Args(1) { my ($self, $c, $id) = @_; - my $baseuri = 'http://' . $c->req->uri->host . ':' . ($c->config->{web}->{autoprov_plain_port} // '1444') . '/pbx/directory/spa/' . $id; + my $schema = $c->stash->{schema}; + my $host = $c->stash->{host}; + my $port = $c->stash->{port}; + + my $baseuri = "$schema://$host:$port/pbx/directory/spa/$id"; my $data = ''; $data = <req->uri->host . ':' . ($c->config->{web}->{autoprov_plain_port} // '1444') . '/pbx/directory/spa/' . $id; + my $schema = $c->stash->{schema}; + my $host = $c->stash->{host}; + my $port = $c->stash->{port}; + + my $baseuri = "$schema://$host:$port/pbx/directory/spa/$id"; my $data = ''; my $delim = '?'; @@ -124,7 +140,8 @@ sub spa_directory_list :Chained('/') :PathPart('pbx/directory/spa') :Args(1) { my $nexturi = $baseuri . $delim . 'page='.($nextpage//0); my $prevuri = $baseuri . $delim . 'page='.($prevpage//0); - my $searchuri = 'http://' . $c->req->uri->host . ':' . ($c->config->{web}->{autoprov_plain_port} // '1444') . '/pbx/directory/spasearch/' . $id; + + my $searchuri = "$schema://$host:$port/pbx/directory/spasearch/$id"; $data = "PBX Address Book$dirsuffixSelect the User"; $data .= join '', map {"$$_{name}$$_{ext}"} @entries; diff --git a/ngcp_panel.conf b/ngcp_panel.conf index 2f41db58b9..f3ee4c203a 100644 --- a/ngcp_panel.conf +++ b/ngcp_panel.conf @@ -100,3 +100,9 @@ log4perl.appender.Default.layout.ConversionPattern=%d{ISO8601} [%p] [%F +%L] %m{ rest_api_certfile /etc/ngcp-panel/api_ssl/api_ca.crt server_certfile /etc/ngcp-panel/api_ssl/api_ca.crt + + + secure 0 + host agranig-office.sipwise.com + port 1444 +