<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:59:53 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-2413] Native types for IP Address and MAC Address</title>
                <link>https://jira.mongodb.org/browse/SERVER-2413</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I am porting a network-oriented application from PostgreSQL to MongoDB.  The application makes heavy use of the &apos;inet&apos; and &apos;mac&apos; data types, especially when searching for IP addresses in a netblock.&lt;/p&gt;

&lt;p&gt;One could argue that IP Addresses can simply be stored and searched as strings, which is true.  However, it becomes increasingly difficult when you throw in netmasks and IPv6.  For example, the IPv6 address &quot;FFAB::1234&quot; is really &quot;FFAB:0000:0000:0000:0000:0000:0000:1234&quot;, and both forms are acceptable string representations.&lt;/p&gt;

&lt;p&gt;I could not find any plans for including this feature in MongoDB, so I decided to tackle it myself.  The resulting work can be found at:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/redmeadowman/mongo&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/redmeadowman/mongo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The change involves adding the new types to BSON, and adding new classes to the JavaScript shell.  I&apos;ve added two new types, IpAddr() and MacAddr().&lt;/p&gt;

&lt;p&gt;IpAddr - Contains an IPv4 or IPv6 address along with a netmask&lt;br/&gt;
    Examples to try in the shell:&lt;br/&gt;
    var ip4 = IpAddr(&quot;192.168.1.1&quot;)&lt;br/&gt;
    ip4.mask&lt;br/&gt;
    ip4.version&lt;br/&gt;
    ip4.mask = 16&lt;br/&gt;
    ip4.mask&lt;br/&gt;
    ip4 = IpAddr(&quot;192.168.1.1/24&quot;)&lt;br/&gt;
    ip4.mask&lt;br/&gt;
    ip4.network&lt;br/&gt;
    ip4.broadcast&lt;br/&gt;
    var ip6 = IpAddr(&quot;1234::abcd&quot;);&lt;br/&gt;
    ip6.mask&lt;br/&gt;
    ip6.version&lt;br/&gt;
    ip6.mask = 64&lt;br/&gt;
    ip6.mask&lt;br/&gt;
    var ip6 = IpAddr(&quot;1234::abcd/32&quot;);&lt;br/&gt;
    ip6.network&lt;br/&gt;
    ip6.broadcast&lt;br/&gt;
    ip6 = IpAddr(&quot;::192.168.1.1/16&quot;);&lt;br/&gt;
    db.test.insert(&lt;/p&gt;
{ip: IpAddr(&quot;192.168.1.1&quot;)}
&lt;p&gt;)&lt;br/&gt;
    db.test.insert(&lt;/p&gt;
{ip: IpAddr(&quot;1234::&quot;)}
&lt;p&gt;)&lt;br/&gt;
    db.test.find()&lt;/p&gt;

&lt;p&gt;MacAddr - Contains a 6-octet Media Access Control Address (Ethernet hardware address)&lt;br/&gt;
    var mac = MacAddr(&quot;00:23:45:ab:cd:ef&quot;);&lt;br/&gt;
    db.test.insert(&lt;/p&gt;
{mac: MacAddr(&quot;1:2:3:4:5:6&quot;)}
&lt;p&gt;)&lt;br/&gt;
    db.test.find()&lt;/p&gt;

&lt;p&gt;The application I&apos;m porting also makes heavy use of UUIDs, so I&apos;ve modified the Shell UUID type so it is now a native type of JavaScript.  This now works (no need to say &apos;new UUID(...&apos;&lt;br/&gt;
    var uuid = UUID(&quot;123456789abcdef12345678901234567&quot;);&lt;br/&gt;
    db.test.insert(&lt;/p&gt;
{uuid: UUID(&quot;123456789abcdef12345678901234567&quot;)}
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;The branch listed above includes the code changes against the latest master (as of 24 Jan 2011), plus unit tests in both dbtests/ and jstests/.&lt;/p&gt;
</description>
                <environment>Fedora 14 x86_64</environment>
        <key id="14321">SERVER-2413</key>
            <summary>Native types for IP Address and MAC Address</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="12300">Won&apos;t Do</resolution>
                                        <assignee username="geert.bosch@mongodb.com">Geert Bosch</assignee>
                                    <reporter username="dnevil">Daris A Nevil</reporter>
                        <labels>
                    </labels>
                <created>Wed, 26 Jan 2011 23:54:24 +0000</created>
                <updated>Mon, 25 Oct 2021 12:26:50 +0000</updated>
                            <resolved>Mon, 25 Oct 2021 12:26:50 +0000</resolved>
                                                    <fixVersion>features we&amp;#39;re not sure of</fixVersion>
                                    <component>JavaScript</component>
                                        <votes>13</votes>
                                    <watches>19</watches>
                                                                                                                <comments>
                            <comment id="4145014" author="geert.bosch" created="Mon, 25 Oct 2021 12:26:50 +0000"  >&lt;p&gt;Adding new types to BSON has a very high distributed cost, as the entire eco-system will need to be upgraded to support the new types. So, we will not consider that for this narrow use case.&lt;/p&gt;</comment>
                            <comment id="1571843" author="sallgeud" created="Tue, 16 May 2017 01:10:58 +0000"  >&lt;p&gt;It&apos;s actually insanely fast to do in your code... Just wire it up as binary and search ranges. Would be neat to see in drivers. &lt;/p&gt;</comment>
                            <comment id="1571842" author="dev.meghraj" created="Tue, 16 May 2017 01:03:03 +0000"  >&lt;p&gt;+1&lt;/p&gt;

&lt;p&gt;MondoDB is known for scalable and big database and performance.&lt;/p&gt;

&lt;p&gt;so quering IP address sholud also be faster, in my app i also want to store list of IP Addresses in v4 and v6 including CIDR notations then for every client i need to check weather client&apos;s ip listed in blacklist or not.&lt;/p&gt;

&lt;p&gt;Someone has already done work please check, merge and doc it.&lt;/p&gt;</comment>
                            <comment id="1158182" author="sallgeud" created="Fri, 29 Jan 2016 19:16:52 +0000"  >&lt;p&gt;I think mongo could add support for IP Address searching, ranges, etc, without having to change BSON to add it as a feature.  Addresses themselves are just a set of bytes. They could use standard binary storage and do searching based on bit masking (which would actually index incredibly well).  You could also, in theory do some CIDR type searches.  Really, you&apos;re talking about wiring up something to interpret the string forms of an IP into binary, and then wiring up something to allow you to search those.&lt;/p&gt;

&lt;p&gt;CIDR search: db.Collection.find({IPAddress; &lt;/p&gt;
{ $in: Network(&apos;192.168.0.0/16&apos;) }
&lt;p&gt; });&lt;/p&gt;

&lt;p&gt;Then when entering the data, you&apos;d just need something to convert it to binary properly... but that could be done in drivers.&lt;/p&gt;</comment>
                            <comment id="1158028" author="ramnes" created="Fri, 29 Jan 2016 17:36:12 +0000"  >&lt;p&gt;I just discovered there&apos;s no BSON type to deal with IP adresses, bummer! I&apos;d love to see that feature implemented.&lt;/p&gt;</comment>
                            <comment id="496552" author="bra@fsn.hu" created="Mon, 10 Feb 2014 20:05:27 +0000"  >&lt;p&gt;Sure, but it quickly starts getting ugly.&lt;br/&gt;
Like when I&apos;d like to store CIDR format addresses and want to check whether a given address (/32 or /128), or a subnet is in any of them.&lt;br/&gt;
Yes, it can be solved by math (of course, that&apos;s the same the DB does with supporting these kind of addresses), but it&apos;s so hackish.&lt;/p&gt;</comment>
                            <comment id="496530" author="sallgeud" created="Mon, 10 Feb 2014 19:45:59 +0000"  >&lt;p&gt;Have you considered, at least in the short term, storing the data as a 64bit integer and writing your own serializer/deserializer to convert? I&apos;m not sure which language you&apos;re writing in, but this seems like it would get you at least a portion of what you want. I wish the bsonspec supported unsigned integers so we could use a 32bit, but 64 works well enough.  When you want to search for all IPs in a range in your app, you just calculate the start and finish integer equiv of the IP.  Given that an ipv4 address is just a 32bit object, any data type that supports range queries (gt, lt, etc) would work just fine.  You could even use hex strings if you were so inclined. Though, I would wager that an int would search faster because of its fixed scope &lt;span class=&quot;error&quot;&gt;&amp;#91;vs text, etc&amp;#93;&lt;/span&gt;&lt;/p&gt;</comment>
                            <comment id="496505" author="bra@fsn.hu" created="Mon, 10 Feb 2014 19:30:10 +0000"  >&lt;p&gt;I haven&apos;t touched mongodb since the 1.4-&amp;gt;1.6 upgrade (which runs in an isolated environment happily since then &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;, but for a new project, I started to re-evaluate possible solutions and I sadly discovered that mongodb still doesn&apos;t have native IP address support.&lt;br/&gt;
This is a must everywhere where the task is not only to store and search a single IP address, but handle subnetting, or IPv6.&lt;/p&gt;</comment>
                            <comment id="160930" author="dnevil" created="Wed, 5 Sep 2012 22:49:57 +0000"  >&lt;p&gt;The lack of support for native IP and MAC addresses has prevented me from using MongoDB.  Any possibility of the main branch picking up the code?  I&apos;d be willing to port these features from 1.8 to the latest branch.&lt;/p&gt;</comment>
                            <comment id="52153" author="eliot" created="Fri, 2 Sep 2011 05:37:59 +0000"  >&lt;p&gt;Trying not to add too many types to BSON, but might be worth it at some point.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="13992">SERVER-2242</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>10.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 2 Sep 2011 05:37:59 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        2 years, 15 weeks, 2 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>geert.bosch@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            2 years, 15 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>sallgeud</customfieldvalue>
            <customfieldvalue>dnevil</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>geert.bosch@mongodb.com</customfieldvalue>
            <customfieldvalue>ramnes</customfieldvalue>
            <customfieldvalue>dev.meghraj</customfieldvalue>
            <customfieldvalue>bra@fsn.hu</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrp7wf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr9jx3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6546</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrqb6f:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>