Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109069 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 85614 invoked from network); 16 Mar 2020 18:00:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Mar 2020 18:00:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D6D4B1804E0 for ; Mon, 16 Mar 2020 09:22:53 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 16 Mar 2020 09:22:53 -0700 (PDT) Received: by mail-lj1-f180.google.com with SMTP id f13so19380722ljp.0 for ; Mon, 16 Mar 2020 09:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lcPJdoqK+HienukUABFtrJOetMb9XyOr6OYj0KExlSA=; b=Gp+m1L+oh/hLMW7l18sflswWNbJWss++Et7RoFLR9TncN3D99NX3+UVW96i6qP2vRf +BHbR+3BIEac/oaCJhzbL2vljOljgsEj6xownXs8W+8J+skjs0WaqxDqI7gkXLnZgXpR 3vv2XetI7Mw2TP99AWtKTbunuvO6eXTdp8PcG5M2xU+GL+o+eX+n2UlOkOMUfwfMyxnf CY0weByjucRU0dmecO0qCWQ9UPGAu1IRGbjLLtKx8FLCZUbNygkXPJIaQKXRNVOAjaYf mFWl10mYc8UsgRpQ4jTje1HJ9IFsEJYHKLOvvZeYvyzFYk/Mos9oH1eHESseVs2j4xDs Kbzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lcPJdoqK+HienukUABFtrJOetMb9XyOr6OYj0KExlSA=; b=cZ7oPiHaFR1kLWU9ceIbSbdktw2/oG+qFDgPN19ixp4J5VpoHEaXTQvprTknuQCcjJ 3BNzPfoK6RUZUiLlHzAH2USpLHT6htvNL2qNP9IUrISSyWM2JRTNl7AYkRmCavzg7W40 /GZzXfGQ5RNDs/3bAtnxqEMNPgm8vEQsMV8AeLb6miD5dSxy+A7dO/+E44tiSVzecNn9 QPHOKCtLBhmylF6WxXdwkh7qYT8vBSOJtmdOyULmOTqrlLvIeUWeQVQOrubpdvY1DF6M t46m1PrQvRu/xWlCUtbh+k+mMNSg7KjBmOvIxJkQEw23/hjWSO9ztFQgrNMgmYIG0+ak Nfkw== X-Gm-Message-State: ANhLgQ0XZOClOIRXEMnTepwj2B/RUZRg/aRLfnFQhuZaS28lxmOxqkt5 hQk36gZ68XGhOKO+KDyZ+5PVAdhghN6RQts3VsMZa2fz X-Google-Smtp-Source: ADFU+vu47H7gwuyeISBEzVsmU2ZSzXPB/2LjQni0FUETx4Oo5Cdf3qEP/0K2ud44wju5SCEYp83Sf6sD8EhJRC2aMHA= X-Received: by 2002:a2e:b4f4:: with SMTP id s20mr46200ljm.131.1584375771878; Mon, 16 Mar 2020 09:22:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 16 Mar 2020 16:22:14 +0000 Message-ID: To: Ben Ramsey Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000012d80c05a0fb3b1a" Subject: Re: [PHP-DEV] [DISCUSSION] Native UUID support in PHP From: cdtreeks@gmail.com (Aran Reeks) --00000000000012d80c05a0fb3b1a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Ben, Thanks for the feedback, I wasn't aware of net_get_interfaces, but that's really helpful and agree that post your patch, implementing a get_network_mac_addr() function (or similar name) would be amazing. Many thanks Aran On Mon, 16 Mar 2020 at 16:16, Ben Ramsey wrote: > > On Mar 16, 2020, at 11:06, Aran Reeks wrote: > > > > Hi Internals, > > > > I'd like to open up a discussion around the implementation of a new > > function within PHP for generating a UUID. > > > > Whilst there are libraries out there already for PHP which can generate= a > > UUID, all of those libraries have the possibility to generate IDs that > > *could* have a collision. > > > > The specification for UUID versions 1 and 2 allow for collision-free ID > > generation by incorporating the unique MAC addresses from network cards= - > > something which can't be accessed from PHP code at present. > > > > I can see two possible methods to enable this; > > > > - New function added to PHP which exposes the MAC address (allowing > > external implementations for UUIDs, as well as other possible purpose= s > a > > MAC address could be used). > > > > - A new PHP function which introduced a uuid() function which will > > generate and return version-compliant UUIDs. > > > > - Both of the above. > > > > Thoughts and feedback welcome to kickstart conversations and if there's= a > > positive consensus, I'd like to put forward an RFC for this to be > > introduced in PHP 8. > > > > > While undocumented, PHP has the method `net_get_interfaces()` (since PHP > 7.3.0). It uses `getifaddrs()` on Linux and `GetAdaptersAddresses()` on > Windows to create an array of network interface addresses. > > See > https://github.com/php/php-src/commit/7ca5a7d84ebdc1b97f49cb460f200db093b= 96d9d > > Right now, the address is only added when it is an IPv4 or IPv6 address. > It just needs to be modified to look for the correct =E2=80=9Cfamily=E2= =80=9D and set that > as the =E2=80=9Cmac=E2=80=9D array value for the interface. > > I=E2=80=99m currently working on a patch for this, so this might help wit= h one > aspect of your proposal. > > Cheers, > Ben > > --00000000000012d80c05a0fb3b1a--