AdGuardHome/internal/aghnet/hostgen.go

33 lines
647 B
Go
Raw Normal View History

package aghnet
import (
Pull request 1771: AG-20352-dhcpd-lease-netip-addr Merge in DNS/adguard-home from AG-20352-dhcpd-lease-netip-addr to master Squashed commit of the following: commit 4acd094e2d6ed972bac99cdb671670f6d8e61721 Merge: 51f61c19 df61741f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 23 16:44:17 2023 +0300 Merge branch 'master' into AG-20352-dhcpd-lease-netip-addr commit 51f61c193fdd31ee675be5598fc361228e407eb3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 18:25:30 2023 +0300 dhcpd: fix typo commit 2e64ad55475957925d2a3010c649e0adc5f18c4f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 17:20:31 2023 +0300 dhcpd: add todo commit 668d4f62fd2c5b2e168025bf0b6bb36d7b617c80 Merge: 0020006e 306c1983 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 15:09:38 2023 +0300 Merge branch 'master' into AG-20352-dhcpd-lease-netip-addr commit 0020006e89f336dc58db1a2ca3ce90d2e7a5ca16 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 15:08:58 2023 +0300 all: imp code commit 9a77f79869cdbde6de760734c0d8cf504e0464ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 18:13:35 2023 +0300 dhcpd: add todo commit 638c4ce2af72235bf065a6492d58f3f1b1e7644a Merge: c82b18f1 48431f8b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 13:57:19 2023 +0300 Merge branch 'master' into AG-20352-dhcpd-lease-netip-addr commit c82b18f1408d9e353aec517f4283e2f3eb260890 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 13:56:31 2023 +0300 all: imp code commit 27e518120024103c292ac1cf134c6801fffc967e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Mar 17 12:14:02 2023 +0300 dhcpd: imp tests commit 8e919b0ceb0b20d1935587e717c7965cd8a33ad9 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Mar 17 11:02:50 2023 +0300 dhcpd: add tests commit 78ddefa73a255509af1c788147d6b1c332bb66ba Merge: c68e85c4 9f7a582d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 16 14:15:24 2023 +0300 Merge branch 'master' into AG-20352-dhcpd-lease-netip-addr commit c68e85c40947b6c83516424a2bd7af89b99447b4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 16 14:14:43 2023 +0300 all: add tests commit f338086309a68c4b71036fa14f757e39358702d4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 15 12:44:06 2023 +0300 all: dhcpd lease netip addr
2023-03-23 13:52:01 +00:00
"net/netip"
Pull request 1736: 4299-querylog-stats-api Merge in DNS/adguard-home from 4299-querylog-stats-api to master Updates #1717. Updates #4299. Squashed commit of the following: commit 5b706b7997a536bc4fd2c532fb89ca5ab3536848 Merge: 48b62b0f 306c1983 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 13:53:09 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 48b62b0f1882f1ad120c6cdd90cd7dd8cb8a7738 Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com> Date: Wed Mar 22 12:25:04 2023 +0200 client: fix styles, add titles and descrs commit 97e31cff70d05b51bd0e5ea2d20e8e7a251a7e41 Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com> Date: Tue Mar 21 18:38:12 2023 +0200 client: add ignored domains for querylog commit 24d75c4376382205ae6b8f731b1cd23d517772c9 Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com> Date: Tue Mar 21 18:21:13 2023 +0200 client: add ignore domains for stats commit eefc3891d01f90af79fdac9ba8eea06d4d54a0bc Merge: 978675ea 1daabb97 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Mar 21 10:53:35 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 978675ea2c07bf248b4c8f26ebdf78cf59a12ef5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Mar 21 10:53:11 2023 +0300 openapi: fix chlog commit 2ed33007aade115d38b0ca582206cc10678b084c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 17:49:07 2023 +0300 home: fix tests commit 6af11520c164553ee9fce8f214ea169672188d7e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 17:40:16 2023 +0300 home: fix typo commit 56acdfde5b1ee8d16b232c1293b91affbe319ad1 Merge: 319da34d 48431f8b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 17:32:58 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 319da34de41ec84310b23bba2ad79c8a3a4c14ff Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Mar 3 17:34:38 2023 +0300 querylog: fix docs commit d5a8f24d5b336e7bdbbca18069f6ede8c96bcc2c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Mar 3 11:42:00 2023 +0300 stats: fix docs commit e0cbfc1c4078180a05835ce7587e9f45484adc81 Merge: 4743c810 012e5beb Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 18:45:17 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 4743c81038052b9e0ca29ae5f1565021d36ca1ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 18:14:16 2023 +0300 all: imp code; fix time conversion commit 34310cffd7e331d098c535590245387051674fa8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 12:34:11 2023 +0300 chlog: restore order commit cadd864a66655242948f1cb16e6d4945c0235d7e Merge: 2f3e25be bb226434 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 12:26:06 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 2f3e25bee56d2c6ddcf4aa2fc6a1dc51ed9b06e1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 12:25:14 2023 +0300 all: fix fmt commit d54022baa6c8a3d0d3c308a9b6b1a6a9dc6ac7b6 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 28 16:16:40 2023 +0300 all: imp code; fix chlog commit df22de91f59a51194c55e7bcbe5bc3fcc60cb8e3 Merge: e1ea4797 a772212d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 27 17:24:09 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit e1ea4797af974c36f06683ffc6eaaae917921a43 Merge: d7db0a5a bb80a7c2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 27 17:23:20 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit d7db0a5af1e1f49f6174c1c42e6d9306f2381d16 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 27 17:12:20 2023 +0300 all: imp docs ... and 15 more commits
2023-03-23 10:46:57 +00:00
"strings"
)
// GenerateHostname generates the hostname from ip. In case of using IPv4 the
// result should be like:
//
// 192-168-10-1
//
// In case of using IPv6, the result is like:
//
// ff80-f076-0000-0000-0000-0000-0000-0010
//
// ip must be either an IPv4 or an IPv6.
Pull request 1771: AG-20352-dhcpd-lease-netip-addr Merge in DNS/adguard-home from AG-20352-dhcpd-lease-netip-addr to master Squashed commit of the following: commit 4acd094e2d6ed972bac99cdb671670f6d8e61721 Merge: 51f61c19 df61741f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 23 16:44:17 2023 +0300 Merge branch 'master' into AG-20352-dhcpd-lease-netip-addr commit 51f61c193fdd31ee675be5598fc361228e407eb3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 18:25:30 2023 +0300 dhcpd: fix typo commit 2e64ad55475957925d2a3010c649e0adc5f18c4f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 17:20:31 2023 +0300 dhcpd: add todo commit 668d4f62fd2c5b2e168025bf0b6bb36d7b617c80 Merge: 0020006e 306c1983 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 15:09:38 2023 +0300 Merge branch 'master' into AG-20352-dhcpd-lease-netip-addr commit 0020006e89f336dc58db1a2ca3ce90d2e7a5ca16 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 15:08:58 2023 +0300 all: imp code commit 9a77f79869cdbde6de760734c0d8cf504e0464ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 18:13:35 2023 +0300 dhcpd: add todo commit 638c4ce2af72235bf065a6492d58f3f1b1e7644a Merge: c82b18f1 48431f8b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 13:57:19 2023 +0300 Merge branch 'master' into AG-20352-dhcpd-lease-netip-addr commit c82b18f1408d9e353aec517f4283e2f3eb260890 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 13:56:31 2023 +0300 all: imp code commit 27e518120024103c292ac1cf134c6801fffc967e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Mar 17 12:14:02 2023 +0300 dhcpd: imp tests commit 8e919b0ceb0b20d1935587e717c7965cd8a33ad9 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Mar 17 11:02:50 2023 +0300 dhcpd: add tests commit 78ddefa73a255509af1c788147d6b1c332bb66ba Merge: c68e85c4 9f7a582d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 16 14:15:24 2023 +0300 Merge branch 'master' into AG-20352-dhcpd-lease-netip-addr commit c68e85c40947b6c83516424a2bd7af89b99447b4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 16 14:14:43 2023 +0300 all: add tests commit f338086309a68c4b71036fa14f757e39358702d4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 15 12:44:06 2023 +0300 all: dhcpd lease netip addr
2023-03-23 13:52:01 +00:00
func GenerateHostname(ip netip.Addr) (hostname string) {
if !ip.IsValid() {
// TODO(s.chzhen): Get rid of it.
panic("aghnet generate hostname: invalid ip")
}
ip = ip.Unmap()
hostname = ip.StringExpanded()
if ip.Is4() {
return strings.ReplaceAll(hostname, ".", "-")
Pull request 1736: 4299-querylog-stats-api Merge in DNS/adguard-home from 4299-querylog-stats-api to master Updates #1717. Updates #4299. Squashed commit of the following: commit 5b706b7997a536bc4fd2c532fb89ca5ab3536848 Merge: 48b62b0f 306c1983 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 13:53:09 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 48b62b0f1882f1ad120c6cdd90cd7dd8cb8a7738 Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com> Date: Wed Mar 22 12:25:04 2023 +0200 client: fix styles, add titles and descrs commit 97e31cff70d05b51bd0e5ea2d20e8e7a251a7e41 Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com> Date: Tue Mar 21 18:38:12 2023 +0200 client: add ignored domains for querylog commit 24d75c4376382205ae6b8f731b1cd23d517772c9 Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com> Date: Tue Mar 21 18:21:13 2023 +0200 client: add ignore domains for stats commit eefc3891d01f90af79fdac9ba8eea06d4d54a0bc Merge: 978675ea 1daabb97 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Mar 21 10:53:35 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 978675ea2c07bf248b4c8f26ebdf78cf59a12ef5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Mar 21 10:53:11 2023 +0300 openapi: fix chlog commit 2ed33007aade115d38b0ca582206cc10678b084c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 17:49:07 2023 +0300 home: fix tests commit 6af11520c164553ee9fce8f214ea169672188d7e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 17:40:16 2023 +0300 home: fix typo commit 56acdfde5b1ee8d16b232c1293b91affbe319ad1 Merge: 319da34d 48431f8b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 17:32:58 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 319da34de41ec84310b23bba2ad79c8a3a4c14ff Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Mar 3 17:34:38 2023 +0300 querylog: fix docs commit d5a8f24d5b336e7bdbbca18069f6ede8c96bcc2c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Mar 3 11:42:00 2023 +0300 stats: fix docs commit e0cbfc1c4078180a05835ce7587e9f45484adc81 Merge: 4743c810 012e5beb Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 18:45:17 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 4743c81038052b9e0ca29ae5f1565021d36ca1ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 18:14:16 2023 +0300 all: imp code; fix time conversion commit 34310cffd7e331d098c535590245387051674fa8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 12:34:11 2023 +0300 chlog: restore order commit cadd864a66655242948f1cb16e6d4945c0235d7e Merge: 2f3e25be bb226434 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 12:26:06 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 2f3e25bee56d2c6ddcf4aa2fc6a1dc51ed9b06e1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 12:25:14 2023 +0300 all: fix fmt commit d54022baa6c8a3d0d3c308a9b6b1a6a9dc6ac7b6 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 28 16:16:40 2023 +0300 all: imp code; fix chlog commit df22de91f59a51194c55e7bcbe5bc3fcc60cb8e3 Merge: e1ea4797 a772212d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 27 17:24:09 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit e1ea4797af974c36f06683ffc6eaaae917921a43 Merge: d7db0a5a bb80a7c2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 27 17:23:20 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit d7db0a5af1e1f49f6174c1c42e6d9306f2381d16 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 27 17:12:20 2023 +0300 all: imp docs ... and 15 more commits
2023-03-23 10:46:57 +00:00
}
return strings.ReplaceAll(hostname, ":", "-")
Pull request 1736: 4299-querylog-stats-api Merge in DNS/adguard-home from 4299-querylog-stats-api to master Updates #1717. Updates #4299. Squashed commit of the following: commit 5b706b7997a536bc4fd2c532fb89ca5ab3536848 Merge: 48b62b0f 306c1983 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 22 13:53:09 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 48b62b0f1882f1ad120c6cdd90cd7dd8cb8a7738 Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com> Date: Wed Mar 22 12:25:04 2023 +0200 client: fix styles, add titles and descrs commit 97e31cff70d05b51bd0e5ea2d20e8e7a251a7e41 Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com> Date: Tue Mar 21 18:38:12 2023 +0200 client: add ignored domains for querylog commit 24d75c4376382205ae6b8f731b1cd23d517772c9 Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com> Date: Tue Mar 21 18:21:13 2023 +0200 client: add ignore domains for stats commit eefc3891d01f90af79fdac9ba8eea06d4d54a0bc Merge: 978675ea 1daabb97 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Mar 21 10:53:35 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 978675ea2c07bf248b4c8f26ebdf78cf59a12ef5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Mar 21 10:53:11 2023 +0300 openapi: fix chlog commit 2ed33007aade115d38b0ca582206cc10678b084c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 17:49:07 2023 +0300 home: fix tests commit 6af11520c164553ee9fce8f214ea169672188d7e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 17:40:16 2023 +0300 home: fix typo commit 56acdfde5b1ee8d16b232c1293b91affbe319ad1 Merge: 319da34d 48431f8b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 20 17:32:58 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 319da34de41ec84310b23bba2ad79c8a3a4c14ff Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Mar 3 17:34:38 2023 +0300 querylog: fix docs commit d5a8f24d5b336e7bdbbca18069f6ede8c96bcc2c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Mar 3 11:42:00 2023 +0300 stats: fix docs commit e0cbfc1c4078180a05835ce7587e9f45484adc81 Merge: 4743c810 012e5beb Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 18:45:17 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 4743c81038052b9e0ca29ae5f1565021d36ca1ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 18:14:16 2023 +0300 all: imp code; fix time conversion commit 34310cffd7e331d098c535590245387051674fa8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 12:34:11 2023 +0300 chlog: restore order commit cadd864a66655242948f1cb16e6d4945c0235d7e Merge: 2f3e25be bb226434 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 12:26:06 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit 2f3e25bee56d2c6ddcf4aa2fc6a1dc51ed9b06e1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 1 12:25:14 2023 +0300 all: fix fmt commit d54022baa6c8a3d0d3c308a9b6b1a6a9dc6ac7b6 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 28 16:16:40 2023 +0300 all: imp code; fix chlog commit df22de91f59a51194c55e7bcbe5bc3fcc60cb8e3 Merge: e1ea4797 a772212d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 27 17:24:09 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit e1ea4797af974c36f06683ffc6eaaae917921a43 Merge: d7db0a5a bb80a7c2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 27 17:23:20 2023 +0300 Merge branch 'master' into 4299-querylog-stats-api commit d7db0a5af1e1f49f6174c1c42e6d9306f2381d16 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 27 17:12:20 2023 +0300 all: imp docs ... and 15 more commits
2023-03-23 10:46:57 +00:00
}