[Openh323gk-users] ProxyRequired module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.
I have made some changes sourse code of gk in module Toolkit (section Proxy) to have an opportunity set addresses of proxying not one address, and pairs
(for example: InternalNetwork=1.1.1.0/24:2.2.0.0/16,3.3.3.3:4.0.0.0/8).
Here that at me it has turned out:
Toolkit.h :
        class ProxyCriterion {
                typedef PIPSocket::Address Address;
 
        public:
                ProxyCriterion() : networkx(0), networky(0) { /* initialize later */ }
                ~ProxyCriterion() { ClearTable(); }
 
                bool IsInternal(const Address &, const Address &) const;
                bool Required(const Address &, const Address &) const;
 
                void LoadConfig(PConfig *);
                void ClearTable();
 
        private:
                int size;
                Address *networkx, *netmaskx, *networky, *netmasky;
        };
 
        bool ProxyRequired(const PIPSocket::Address & ip1, const PIPSocket::Address & ip2) const
        { return m_ProxyCriterion.Required(ip1, ip2); }
Toolkit.cxx:
// class Toolkit::ProxyCriterion
void Toolkit::ProxyCriterion::LoadConfig(PConfig *config)
{
        ClearTable();
        if (!AsBool(config->GetString(ProxySection, "Enable", "0"))) {
                PTRACE(2, "GK\tH.323 Proxy: disabled");
                size = -1;
                return;
        }
 
        PTRACE(2, "GK\tH.323 Proxy enabled");
 
        PStringArray proxylinks(config->GetString(ProxySection, "InternalNetwork", "").Tokenise(" ,;\t", FALSE));
        if ((size = proxylinks.GetSize()) == 0) {
                // no internal networks specified, always no use proxy
                PTRACE(2, "GK\tH.323 Proxy: no links specified - always use proxy.");
                size = 0;
                return;
        }
 
        networkx = new Address[size * 2];
        netmaskx = networkx + size;
        networky = new Address[size * 2];
        netmasky = networky + size;
        for (int i = 0; i < size; ++i)
        {
                PStringArray networks(proxylinks[i].Tokenise(":", FALSE));
                GetNetworkFromString(networks[0], networkx[i], netmaskx[i]);
                GetNetworkFromString(networks[1], networky[i], netmasky[i]);
                PTRACE(2, "GK\tProxying Links " << i << " = " <<
                        networkx[i] << '/' << netmaskx[i] <<
                        " <=> " <<
                        networky[i] << '/' << netmasky[i]);
                        networks = 0;
        }
}
 
void Toolkit::ProxyCriterion::ClearTable()
{
        size = 0;
        delete [] networkx;
        networkx = 0;
        delete [] networky;
        networky = 0;
}
 
bool Toolkit::ProxyCriterion::Required(const Address & ip1, const Address & ip2) const
{
        return (size >= 0) ? ((size == 0) || (IsInternal(ip1,ip2) == true)) : false;
}
 
bool Toolkit::ProxyCriterion::IsInternal(const Address & ip1, const Address & ip2) const
{
        for (int i = 0; i < size; ++i)
                if (((ip1 & netmaskx[i]) == networkx[i] && (ip2 & netmasky[i]) == networky[i]) ||
                    ((ip2 & netmaskx[i]) == networkx[i] && (ip1 & netmasky[i]) == networky[i]))
                        return true;
        return false;
}
But it has turned out so, that proxying it is always on (even if Enable=0). Help, please, that I have made not correctly?

[Index of Archives]     [SIP]     [Open H.323]     [Gnu Gatekeeper]     [Asterisk PBX]     [ISDN Cause Codes]     [Yosemite News]

  Powered by Linux