Reverse domain name notation: Difference between revisions
No edit summary |
|||
(47 intermediate revisions by 28 users not shown) | |||
Line 1: | Line 1: | ||
{{verify|date=May 2024}} |
|||
{{About|the [[Java platform|Java]]-like naming convention|network process|Reverse DNS lookup}} |
|||
{{Short description|A reversed DNS name notation}} |
|||
{{confuse|Reverse DNS lookup}} |
|||
{{One source|date=May 2011}} |
|||
[[File:Android_9.0_Reverse-DNS_filesystem_hierarchy.png|thumb|An example of reverse-DNS filesystem hierarchy]] |
|||
'''Reverse domain name notation''' (or '''reverse-DNS''') is a naming convention for the components, packages, and types used by a programming language, system or framework. A characteristic of reverse-DNS strings is that they are based on registered [[domain name]]s, and are only reversed for sorting purposes. For example, if a company making a product called "MyProduct" has the registered [[domain name]] "example.com", they could use the reverse-DNS string "com.example.MyProduct" to describe it. Reverse-DNS names are a simple way of reducing name-space collisions, since any domain name is registered by only one party at a time. |
|||
{{Wikifunctions|Z19112}} |
|||
'''Reverse domain name notation''' (or '''reverse-DNS''') is a naming convention for components, packages, types or file names used by a programming language, system or framework. Reverse-DNS strings are based on registered domain names, with the order of the components reversed for grouping purposes. For example, if a company making the product "MyProduct" has the [[domain name]] <code>example.com</code>, they could use the reverse-DNS string <code>com.example.MyProduct</code> as an identifier for that product. Reverse-DNS names are a simple way of eliminating [[Naming_collision|namespace collisions]], since any registered domain name is globally unique to its owner (with [[alt root]]s making exceptions to this rule possible but unlikely). |
|||
==History== |
==History== |
||
The first appearance of reversed DNS strings predated the Internet domain name standards. The UK Joint Academic Networking Team ([[JANET]]) used this order in its [[JANET NRS|Name Registration Scheme]], before the Internet domain name standard was established. For example, the name <code>uk.ac.bris.pys.as</code> was interpreted as a host named <code>as</code> within the UK (top level domain <code>[[.uk]]</code>), while the Internet standard would have interpreted it as a host named <code>uk</code> within the American Samoa top level domain (<code>[[.as]]</code>). During the period while both [[big-endian|JANET-style]] and [[little-endian|Internet-style]] addresses were in use, mailers and gateway sites had ad-hoc workarounds to handle the differences, but could still be confused. |
|||
Reverse-DNS for identifier strings first became widely used with the [[Java platform]].{{Citation needed|reason=need a source for the chronology and why they're particularly historic|date=January 2013}} |
|||
Reverse-DNS first became widely used with the [[Java platform]], and has since been used for other systems, for example, [[ActionScript 3]] packages and [[Android (operating system)|Android]] applications.{{Citation needed|reason=need a source for the chronology and why they're particularly historic|date=January 2013}} |
|||
==Examples== |
==Examples== |
||
Examples of systems that use reverse-DNS notation are: |
|||
Examples of systems that use reverse-DNS are [[Sun Microsystems]]' [[Java platform]] and [[Apple Inc.|Apple]]'s [[Uniform Type Identifier]] or UTI. The [[Android (operating system)|Android]] operating system also makes use of the notation for classifying applications, as the [[Dalvik (software)|Dalvik]] virtual machine made use of Java. |
|||
[[dconf]] which is the configuration [[Front and back ends|back end]] used by [[GNOME]]. |
|||
Example of reverse-DNS strings are: |
|||
* com.adobe.postscript-font ([[Uniform Type Identifier|UTI]] string for [[Adobe Systems]]'s [[PostScript]] fonts) |
|||
* com.apple.ostype ([[Uniform Type Identifier|UTI]] string for [[Apple Inc.|Apple]]'s [[OSType]]) |
|||
* org.omg.CORBA ([[Java (programming language)|Java]] library for [[Common Object Request Broker Architecture|CORBA]]) |
|||
* org.w3c.dom ([[Java (programming language)|Java]] library for [[World Wide Web Consortium|W3C]]'s [[Document Object Model|DOM]]) |
|||
==Regular expression== |
|||
{{Tone|section|date=June 2018}} |
|||
<source lang="ragel">^[A-Za-x]{2,6}((?!-)/.[A-Za-z0-9-]{1,63}(?<!-))+$</source> |
|||
==Code== |
|||
The following examples split a string into multiple parts, delimited by dots, then reverse the fragments and join them. |
|||
===C#=== |
|||
<source lang="csharp"> |
|||
static string ReverseDomainName(string domain) |
|||
{ |
|||
return string.Join(".", domain.Split('.').Reverse()); |
|||
} |
|||
</source> |
|||
===Java 8 and later=== |
|||
<source lang="java"> |
|||
static String ReverseDomain(final String domain) { |
|||
final List<String> components = Arrays.asList(domain.split("/\./")); |
|||
Collections.reverse(components); |
|||
return String.join(".", components); |
|||
} |
|||
</source> |
|||
===JavaScript=== |
|||
<source lang="javascript"> |
|||
function reverseDomain(domain) { |
|||
return domain.split('.').reverse().join('.'); |
|||
} |
|||
</source> |
|||
===Julia=== |
|||
<source lang="julia"> |
|||
reversedomain(d) = join(split(d, ".") |> reverse, ".") |
|||
</source> |
|||
===Go=== |
|||
<source lang="go"> |
|||
func reverseDomain(domain string) string { |
|||
s := strings.Split(domain, ".") |
|||
for left := 0; left < (len(s)/2)+1; left++ { |
|||
right := len(s)-left-1 |
|||
s[left], s[right] = s[right], s[left] |
|||
} |
|||
return strings.Join(s, ".") |
|||
} |
|||
</source> |
|||
===PHP=== |
|||
<source lang="php"> |
|||
function reverseDomain($domain) { |
|||
return implode('.', array_reverse(explode('.', $domain))); |
|||
} |
|||
</source> |
|||
===Python=== |
|||
<source lang="python"> |
|||
def reverse_domain(domain): |
|||
return '.'.join(reversed(domain.split('.'))) |
|||
</source> |
|||
===Ruby=== |
|||
<source lang="ruby"> |
|||
def reverse_domain(domain) |
|||
domain.split('.').reverse.join('.') |
|||
end |
|||
</source> |
|||
* [[Java (software platform)|Java]] generally uses it for namespaces, including [[Java package|package]]s and [[Java Platform Module System|module]]s |
|||
===Rust=== |
|||
* [[Apple Inc.|Apple]]'s [[Uniform Type Identifier]] (UTI)<ref>{{cite web |url=https://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/understanding_utis/understand_utis_intro/understand_utis_intro.html |title=Apple Developer Connection: Introduction to Uniform Type Identifiers Overview|date=2005-11-09 |accessdate=2013-04-04}}</ref> |
|||
<source lang="rust"> |
|||
* The [[Android (operating system)|Android]] operating system, for classifying applications (because the [[Dalvik (software)|Dalvik]] virtual machine was based on Java) |
|||
fn reverse_domain(domain: &str) -> String { |
|||
* [[dconf]], the configuration [[Front and back ends|backend]] used by [[GNOME]] |
|||
domain.split('.').rev().collect::<Vec<&str>>().join(".") |
|||
* ginitd 'service' identifiers |
|||
} |
|||
* The [[freedesktop.org]] Desktop Entry Specification<ref>{{cite web |title=Desktop Entry Specification |url=https://specifications.freedesktop.org/desktop-entry-spec/ |publisher=freedesktop.org |accessdate=15 November 2020}}</ref> and D-Bus Specification<ref name="dbus">{{cite web |title=D-Bus Specification |url=https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names |website=dbus.freedesktop.org}}</ref> |
|||
</source> |
|||
* [[Flatpak]] also uses a unique reverse-DNS identifier for each application, aligning with freedesktop.org standard<ref name="flatpak">{{cite web |title=Requirements & Conventions |url=https://docs.flatpak.org/en/latest/conventions.html |website=Flatpak |language=en}}</ref> |
|||
* [[ISCSI#Addressing|iSCSI Qualified Naming]] |
|||
Some examples of reverse-DNS strings are: |
|||
===Swift=== |
|||
* <code>com.adobe.postscript-font</code>, [[Uniform Type Identifier|UTI]] string for [[Adobe Systems]]'s [[PostScript]] fonts |
|||
<source lang="swift"> |
|||
* <code>com.apple.ostype</code>, [[Uniform Type Identifier|UTI]] string for [[Apple Inc.|Apple]]'s [[OSType]] |
|||
func reversed(domain: String) -> String { |
|||
* <code>org.omg.CORBA</code>, [[Java (programming language)|Java]] library for [[Common Object Request Broker Architecture|CORBA]] |
|||
return domain |
|||
* <code>org.w3c.dom</code>, [[Java (programming language)|Java]] library for [[World Wide Web Consortium|W3C]]'s [[Document Object Model|DOM]] |
|||
.split(separator: ".") |
|||
* <code>com.eu.gershwin.DeviceManager</code>, a ginitd service identifier commonly assigned to [[udev]]. |
|||
.reversed() |
|||
* <code>org.kde.dolphin.desktop</code>, a [[.desktop|desktop]] file name |
|||
.joined(separator: ".") |
|||
} |
|||
</source> |
|||
== |
== See also == |
||
<source lang="zsh"> |
|||
function reverse_domain() { |
|||
echo ${(j:.:)${(Oa)${(s:.:)1}}} |
|||
} |
|||
</source> |
|||
* [[Non-Internet email address]] |
|||
===Kotlin=== |
|||
<source lang="kotlin"> |
|||
fun reverseDomain(domain: String) = domain.split(".").reversed().joinToString(".") |
|||
</source> |
|||
==References== |
==References== |
||
{{Reflist}} |
{{Reflist}} |
||
* {{cite web |url=https://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/understanding_utis/understand_utis_intro/understand_utis_intro.html |title=Apple Developer Connection: Introduction to Uniform Type Identifiers Overview|date=2005-11-09 |accessdate=2013-04-04}} |
|||
==External links== |
==External links== |
||
* [ |
* [https://github.com/eclipse-platform/eclipse.platform/blob/master/docs/Naming_Conventions.md Eclipse Naming Conventions] |
||
* [https://gcc.gnu.org/ml/java/2000-04/msg00095.html Re: gnu.* namespace discussion] |
* [https://gcc.gnu.org/ml/java/2000-04/msg00095.html Re: gnu.* namespace discussion] |
||
[[Category:Domain |
[[Category:Domain Name System]] |
Latest revision as of 19:22, 21 December 2024
This article needs additional citations for verification. (May 2024) |
Reverse domain name notation (or reverse-DNS) is a naming convention for components, packages, types or file names used by a programming language, system or framework. Reverse-DNS strings are based on registered domain names, with the order of the components reversed for grouping purposes. For example, if a company making the product "MyProduct" has the domain name example.com
, they could use the reverse-DNS string com.example.MyProduct
as an identifier for that product. Reverse-DNS names are a simple way of eliminating namespace collisions, since any registered domain name is globally unique to its owner (with alt roots making exceptions to this rule possible but unlikely).
History
[edit]The first appearance of reversed DNS strings predated the Internet domain name standards. The UK Joint Academic Networking Team (JANET) used this order in its Name Registration Scheme, before the Internet domain name standard was established. For example, the name uk.ac.bris.pys.as
was interpreted as a host named as
within the UK (top level domain .uk
), while the Internet standard would have interpreted it as a host named uk
within the American Samoa top level domain (.as
). During the period while both JANET-style and Internet-style addresses were in use, mailers and gateway sites had ad-hoc workarounds to handle the differences, but could still be confused.
Reverse-DNS for identifier strings first became widely used with the Java platform.[citation needed]
Examples
[edit]Examples of systems that use reverse-DNS notation are:
- Java generally uses it for namespaces, including packages and modules
- Apple's Uniform Type Identifier (UTI)[1]
- The Android operating system, for classifying applications (because the Dalvik virtual machine was based on Java)
- dconf, the configuration backend used by GNOME
- ginitd 'service' identifiers
- The freedesktop.org Desktop Entry Specification[2] and D-Bus Specification[3]
- Flatpak also uses a unique reverse-DNS identifier for each application, aligning with freedesktop.org standard[4]
- iSCSI Qualified Naming
Some examples of reverse-DNS strings are:
com.adobe.postscript-font
, UTI string for Adobe Systems's PostScript fontscom.apple.ostype
, UTI string for Apple's OSTypeorg.omg.CORBA
, Java library for CORBAorg.w3c.dom
, Java library for W3C's DOMcom.eu.gershwin.DeviceManager
, a ginitd service identifier commonly assigned to udev.org.kde.dolphin.desktop
, a desktop file name
See also
[edit]References
[edit]- ^ "Apple Developer Connection: Introduction to Uniform Type Identifiers Overview". 2005-11-09. Retrieved 2013-04-04.
- ^ "Desktop Entry Specification". freedesktop.org. Retrieved 15 November 2020.
- ^ "D-Bus Specification". dbus.freedesktop.org.
- ^ "Requirements & Conventions". Flatpak.