Skip to content

Commit

Permalink
Merge pull request #556 from dOpensource/fusion-hotfix
Browse files Browse the repository at this point in the history
Make FusionPBX Regex More Reliable
  • Loading branch information
mackhendricks authored Jan 31, 2024
2 parents 86f0006 + a593cfa commit df91f9f
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 73 deletions.
20 changes: 10 additions & 10 deletions gui/static/js/endpointgroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,37 +459,37 @@

/* listener for fusionPBX toggle */
$('.modal-body .toggleFusionPBXDomain').change(function() {
var modal = $(this).closest('div.modal');
var self = $(this);
var modal = self.closest('div.modal');
var modal_body = modal.find('.modal-body');

if ($(this).is(":checked") || $(this).prop("checked")) {
if (self.is(":checked") || self.prop("checked")) {
modal_body.find('.FusionPBXDomainOptions').removeClass("hidden");
modal_body.find('.fusionpbx_db_enabled').val(1);

/* uncheck other toggles */
//modal_body.find(".toggleFreePBXDomain").bootstrapToggle('off');
self.bootstrapToggle('on');
}
else {
modal_body.find('.FusionPBXDomainOptions').addClass("hidden");
modal_body.find('.fusionpbx_db_enabled').val(0);
self.bootstrapToggle('off');
}
});

/* listener for freePBX toggle */
$('.modal-body .toggleFreePBXDomain').change(function() {
var modal = $(this).closest('div.modal');
var self = $(this);
var modal = self.closest('div.modal');
var modal_body = modal.find('.modal-body');

if ($(this).is(":checked") || $(this).prop("checked")) {
if (self.is(":checked") || self.prop("checked")) {
modal_body.find('.FreePBXDomainOptions').removeClass("hidden");
modal_body.find('.freepbx_enabled').val(1);

/* uncheck other toggles */
modal_body.find(".toggleFusionPBXDomain").bootstrapToggle('off');
self.bootstrapToggle('on');
}
else {
modal_body.find('.FreePBXDomainOptions').addClass("hidden");
modal_body.find('.freepbx_enabled').val(0);
self.bootstrapToggle('off');
}
});

Expand Down
139 changes: 76 additions & 63 deletions gui/templates/endpointgroups.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ <h4 class="modal-title custom_align" id="Heading">Edit Endpoint Group Details
<th>Hostname/IP</th>
<th>Description</th>
<th>Weight</th>
<th><button class="btn btn-success btn-md" type="button" id="updateEndpointRow">Add Row</button></th>
<th>
<button class="btn btn-success btn-md" type="button" id="updateEndpointRow">Add Row</button>
</th>
</tr>
</thead>
<tbody id="endpoint-tablebody">
Expand Down Expand Up @@ -216,34 +218,34 @@ <h4 class="modal-title custom_align" id="Heading">Edit Endpoint Group Details
</div>
<input class="fusionpbx_db_enabled " type="hidden" name="fusionpbx_db_enabled" value="0">
</div>
<div class="alert alert-warning pre-scrollable">
<strong>
You need access to the FusionPBX database. Run these commands as root on the FusionPBX server.
Replace &lt;ip address&gt; with the ip address of this server.
</strong>
<pre><code class="bash">DSIPROUTER_IP={{dsiprouter_ip}}
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" /etc/postgresql/*/main/postgresql.conf
<div class="FusionPBXDomainOptions form-group hidden">
<div class="alert alert-warning pre-scrollable">
<strong>
You need access to the FusionPBX database. Run these commands as root on the FusionPBX server.
</strong>
<pre><code class="bash">DSIPROUTER_IP={{ dsiprouter_ip }}
sed -i -r "s/^#?listen_addresses[ \t]?=[ \t]?.*/listen_addresses = '*'/m" /etc/postgresql/*/main/postgresql.conf
iptables -A INPUT -p tcp -s $DSIPROUTER_IP/32 --dport 5432 -j ACCEPT
iptables-save > /etc/iptables/rules.v4
iptables-save &gt;/etc/iptables/rules.v4
# Run this command if your don't want to enter a password for the FusionPBX Database(DB) Password
echo -e "host all all $DSIPROUTER_IP/32 trust" >> /etc/postgresql/*/main/pg_hba.conf
/etc/init.d/postgresql restart
echo -e "host all all $DSIPROUTER_IP/32 trust" &gt;&gt;/etc/postgresql/*/main/pg_hba.conf
systemctl restart postgresql
# Run this command if your using fail2ban
sed -i -r "s|(ignoreip = .*)|\1 $DSIPROUTER_IP/32|" /etc/fail2ban/jail.conf
sed -i -r "s|#ignoreip|ignoreip|" /etc/fail2ban/jail.conf
sed -i -r "s|^#?(ignoreip = .*)|\1 $DSIPROUTER_IP/32|" /etc/fail2ban/jail.conf
systemctl restart fail2ban</code></pre>
</div>
<div class="form-group">
<input class="fusionpbx_db_server form-control" type="text" name="fusionpbx_db_server"
placeholder="FusionPBX Database IP or Hostname">
</div>
<div class="form-group">
<input class="fusionpbx_db_username form-control" type="text" name="fusionpbx_db_username"
placeholder="FusionPBX DB Username">
</div>
<div class="form-group">
<input class="fusionpbx_db_password form-control" type="password" name="fusionpbx_db_password"
placeholder="FusionPBX DB Password(Optional)">
</div>
<div class="form-group">
<input class="fusionpbx_db_server form-control" type="text" name="fusionpbx_db_server"
placeholder="FusionPBX Database IP or Hostname">
</div>
<div class="form-group">
<input class="fusionpbx_db_username form-control" type="text" name="fusionpbx_db_username"
placeholder="FusionPBX DB Username">
</div>
<div class="form-group">
<input class="fusionpbx_db_password form-control" type="password" name="fusionpbx_db_password"
placeholder="FusionPBX DB Password(Optional)">
</div>
</div>
</div> <!-- end of fusionpbx tab -->

Expand All @@ -253,10 +255,14 @@ <h4 class="modal-title custom_align" id="Heading">Edit Endpoint Group Details
Run these commands as root on the FreePBX server.
Replace values within angle brackets '&lt;value&gt;' with your own values.
</strong>
<pre><code class="bash">iptables -A INPUT -p udp -s &lt;dsip ip address&gt;/32 --dport &lt;pbx sip port&gt; -j ACCEPT
iptables-save
<pre><code class="bash">DSIPROUTER_IP={{ dsiprouter_ip }}
PBX_SIP_PORTS=(5060 5080)
for PORT in ${PBX_SIP_PORTS[@]}; do
iptables -A INPUT -p udp -s $DSIPROUTER_IP/32 --dport $PORT -j ACCEPT
done
iptables-save &gt;/etc/iptables/rules.v4
# Run this command if your using fail2ban
sed -i -r "s|(ignoreip = .*)|\1 {{dsiprouter_ip}}/32|" /etc/fail2ban/jail.conf
sed -i -r "s|(ignoreip = .*)|\1 $DSIPROUTER_IP/32|" /etc/fail2ban/jail.conf
systemctl restart fail2ban</code></pre>
</div>
</div> <!-- end of freepbx tab -->
Expand Down Expand Up @@ -362,7 +368,9 @@ <h4 class="modal-title custom_align" id="Heading">Add Endpoint Group Details</h4
<th>Hostname/IP</th>
<th>Description</th>
<th>Weight</th>
<th><button class="btn btn-success btn-md" type="button" id="addEndpointRow">Add Row</button></th>
<th>
<button class="btn btn-success btn-md" type="button" id="addEndpointRow">Add Row</button>
</th>
</tr>
</thead>
<tbody id="endpoint-tablebody2">
Expand Down Expand Up @@ -432,55 +440,60 @@ <h4 class="modal-title custom_align" id="Heading">Add Endpoint Group Details</h4
data-width="125px">
FusionPBX Domain Support
</label>
</div>
</div>
<div class="checkbox-inline">
<label class="checkbox-inline">
<input type="checkbox" class='fusionpbx_clustersupport' name="fusionpbx_clustersupport" value="0">Cluster Support
</label>
</div>
</div>
<input class="fusionpbx_db_enabled " type="hidden" name="fusionpbx_db_enabled" value="0">
<div class="alert alert-warning pre-scrollable">
<strong>
You need access to the FusionPBX database. Run these commands as root on the FusionPBX server.
Replace &lt;ip address&gt; with the ip address of this server.
</strong>
<pre><code class="bash">DSIPROUTER_IP={{dsiprouter_ip}}
<label class="checkbox-inline">
<input type="checkbox" class='fusionpbx_clustersupport' name="fusionpbx_clustersupport" value="0">Cluster
Support
</label>
</div>
</div>
<input class="fusionpbx_db_enabled " type="hidden" name="fusionpbx_db_enabled" value="0">
<div class="FusionPBXDomainOptions form-group hidden">
<div class="alert alert-warning pre-scrollable">
<strong>
You need access to the FusionPBX database. Run these commands as root on the FusionPBX server.
</strong>
<pre><code class="bash">DSIPROUTER_IP={{ dsiprouter_ip }}
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" /etc/postgresql/*/main/postgresql.conf
iptables -A INPUT -p tcp -s $DSIPROUTER_IP/32 --dport 5432 -j ACCEPT
iptables-save > /etc/iptables/rules.v4
iptables-save &gt;/etc/iptables/rules.v4
# Run this command if your don't want to enter a password for the FusionPBX Database(DB) Password
echo -e "host all all $DSIPROUTER_IP/32 trust" >> /etc/postgresql/*/main/pg_hba.conf
/etc/init.d/postgresql restart
echo -e "host all all $DSIPROUTER_IP/32 trust" &gt;&gt;/etc/postgresql/*/main/pg_hba.conf
systemctl restart postgresql
# Run this command if your using fail2ban
sed -i -r "s|(ignoreip = .*)|\1 $DSIPROUTER_IP/32|" /etc/fail2ban/jail.conf
sed -i -r "s|#ignoreip|ignoreip|" /etc/fail2ban/jail.conf
sed -i -r "s|^#?(ignoreip = .*)|\1 $DSIPROUTER_IP/32|" /etc/fail2ban/jail.conf
systemctl restart fail2ban</code></pre>
</div>
<div class="form-group">
<input class="fusionpbx_db_server form-control" type="text" name="fusionpbx_db_server"
placeholder="FusionPBX Database IP or Hostname">
</div>
<div class="form-group">
<input class="fusionpbx_db_username form-control" type="text" name="fusionpbx_db_username"
placeholder="FusionPBX DB Username">
</div>
<div class="form-group">
<input class="fusionpbx_db_password form-control" type="password" name="fusionpbx_db_password"
placeholder="FusionPBX DB Password(Optional)">
</div>
<div class="form-group">
<input class="fusionpbx_db_server form-control" type="text" name="fusionpbx_db_server"
placeholder="FusionPBX Database IP or Hostname">
</div>
<div class="form-group">
<input class="fusionpbx_db_username form-control" type="text" name="fusionpbx_db_username"
placeholder="FusionPBX DB Username">
</div>
<div class="form-group">
<input class="fusionpbx_db_password form-control" type="password" name="fusionpbx_db_password"
placeholder="FusionPBX DB Password(Optional)">
</div>
</div>
</div> <!-- end of fusionpbx tab -->

<div class="FreePBXDomainOptions form-group hidden">
<div class="alert alert-warning pre-scrollable">
<strong>
Run these commands as root on the FreePBX server.
Replace values within angle brackets '&lt;value&gt;' with your own values.
Replace PBX_SIP_PORTS with your own values if they are not set to the defaults.
</strong>
<pre><code class="bash">iptables -A INPUT -p udp -s &lt;dsip ip address&gt;/32 --dport &lt;pbx sip port&gt; -j ACCEPT
iptables-save
<pre><code class="bash">DSIPROUTER_IP={{ dsiprouter_ip }}
PBX_SIP_PORTS=(5060 5080)
for PORT in ${PBX_SIP_PORTS[@]}; do
iptables -A INPUT -p udp -s $DSIPROUTER_IP/32 --dport $PORT -j ACCEPT
done
iptables-save &gt;/etc/iptables/rules.v4
# Run this command if your using fail2ban
sed -i -r "s|(ignoreip = .*)|\1 &lt;{{dsiprouter_ip}}&gt;/32|" /etc/fail2ban/jail.conf
sed -i -r "s|(ignoreip = .*)|\1 $DSIPROUTER_IP/32|" /etc/fail2ban/jail.conf
systemctl restart fail2ban</code></pre>
</div>
</div> <!-- end of freepbx tab -->
Expand Down

0 comments on commit df91f9f

Please sign in to comment.