<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi Schneur,<br>
    <br>
    I was asking as maybe you could took advantage of the
    "load_credentials" option in auth_db module:<br>
       
    <a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/1.11.x/auth_db.html#id293578">http://www.opensips.org/html/docs/modules/1.11.x/auth_db.html#id293578</a><br>
    where you can load (during digest auth) extra columns from the
    subscriber table during the query for loading the passwd.<br>
    <br>
    Best regards,<br>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
    <div class="moz-cite-prefix">On 05.09.2015 02:25, Schneur Rosenberg
      wrote:<br>
    </div>
    <blockquote
cite="mid:CANvjR0Wx_N0Uehw-PZMk9zNtPFOytGxeE0-a-Ow62OK7_VrnuA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <p dir="ltr"><br>
          No, I created 2 tables, one has a record for each device and
          to what account code they belong to, 2nd table lists every
          account code and how many simultaneous calls they can make,
          then I just run a query to get account code and maximum
          concurrent calls allowed for the account code  the query
          obviously is a perfect candidate for memcaching because the
          info rarely changes so I run cache_fetch before running the
          query.</p>
        <p dir="ltr">This allows me to limit the channels on an account
          and not just on a single device, for a virtual PRI setting.</p>
        <p dir="ltr">Here is the simple query "select dev.username,
          ent.chLimit from custom_deviceToEnterprise as dev,
          custom_enterpriseConcurrent as ent where dev.username='$fU'
          and dev.enterprise=ent.enterprise;"</p>
        <p dir="ltr">1st table</p>
        <p dir="ltr">CREATE TABLE `custom_deviceToEnterprise` (</p>
        <p dir="ltr">  `id` bigint(20) NOT NULL AUTO_INCREMENT,</p>
        <p dir="ltr">  `username` varchar(50) NOT NULL,</p>
        <p dir="ltr">  `enterprise` varchar(50) NOT NULL,</p>
        <p dir="ltr">  PRIMARY KEY (`id`)</p>
        <p dir="ltr">)<br>
          <br>
        </p>
        <p dir="ltr">2nd table</p>
        <p dir="ltr">CREATE TABLE `custom_enterpriseConcurrent` (</p>
        <p dir="ltr">  `id` bigint(20) NOT NULL AUTO_INCREMENT,</p>
        <p dir="ltr">  `enterprise` varchar(25) NOT NULL,</p>
        <p dir="ltr">  `chLimit` varchar(5) NOT NULL,</p>
        <p dir="ltr">  PRIMARY KEY (`id`)</p>
        <p dir="ltr">)</p>
        <p dir="ltr">▶ Show quoted text<br>
        </p>
        <div class="gmail_quote">On Sep 4, 2015 6:42 AM, "Bogdan-Andrei
          Iancu" &lt;<a moz-do-not-send="true"
            href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>&gt;
          wrote:<br type="attribution">
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div text="#000000" bgcolor="#FFFFFF"> <tt>Hi Schneur,<br>
                <br>
                Do you originally load the limit from the subscriber
                table ?<br>
                <br>
                Best regards,<br>
              </tt>
              <pre cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a moz-do-not-send="true" href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre>
              <div>On 04.09.2015 12:36, Schneur Rosenberg wrote:<br>
              </div>
              <blockquote type="cite">
                <p dir="ltr">I limit mine on account and I used memcache
                  to store the limits because its not something that
                  changes on a constant basis, so it only does a db
                  query maximum once a hour per device.</p>
                <div class="gmail_quote">On Sep 4, 2015 4:52 AM,
                  "Bogdan-Andrei Iancu" &lt;<a moz-do-not-send="true"
                    href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>&gt;

                  wrote:<br type="attribution">
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi
                    Terrance,<br>
                    <br>
                    That check is not expensive as it is done in memory
                    cache (the "address" table is cached at startup).<br>
                    <br>
                    Regards,<br>
                    <br>
                    Bogdan-Andrei Iancu<br>
                    OpenSIPS Founder and Developer<br>
                    <a moz-do-not-send="true"
                      href="http://www.opensips-solutions.com"
                      rel="noreferrer" target="_blank">http://www.opensips-solutions.com</a><br>
                    <br>
                    On 03.09.2015 21:42, Terrance Devor wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      Lovely!<br>
                      <br>
                      For those that need to limit concurrent call on
                      OpenSIPS, here is the solution:<br>
                      <br>
                      route[limit] {<br>
                              set_dlg_profile("ip","$si");<br>
                             
                      get_profile_size("ip","$si","$var(calls)");<br>
check_address("0","$si","$sp","$proto","$avp(ctx)");<br>
                              xlog("$avp(ctx)\n");<br>
                              xlog("L_INFO","Customer IP $si has
                      $var(calls) concurrent calls, and limit is 12\n");<br>
                      <br>
                              if($var(calls)&gt;$avp(ctx)) {<br>
                                      xlog("Customer IP $si exceeded
                      number of calls $var(calls)/12\n");<br>
                                      send_reply("486", "Busy here,
                      channel limit exceeded.");<br>
                                      exit;<br>
                              }<br>
                      }<br>
                      <br>
                      Bogdan, how expensive is
                      `check_address("0","$si","$sp","$proto","$avp(ctx)")`?<br>
                      <br>
                      Terrance<br>
                      <br>
                    </blockquote>
                    <br>
                    <br>
                    _______________________________________________<br>
                    Users mailing list<br>
                    <a moz-do-not-send="true"
                      href="mailto:Users@lists.opensips.org"
                      target="_blank">Users@lists.opensips.org</a><br>
                    <a moz-do-not-send="true"
                      href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
                      rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                  </blockquote>
                </div>
                <br>
                <fieldset></fieldset>
                <br>
                <pre>_______________________________________________
Users mailing list
<a moz-do-not-send="true" href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a moz-do-not-send="true" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
              </blockquote>
              <br>
            </div>
          </blockquote>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>