netmaker/controllers/dns_test.go

448 lines
14 KiB
Go
Raw Normal View History

2021-05-06 05:24:24 +08:00
package controller
import (
2023-01-21 06:38:32 +08:00
"net"
2021-10-17 23:47:25 +08:00
"os"
2021-05-06 05:24:24 +08:00
"testing"
2023-01-21 06:38:32 +08:00
"github.com/google/uuid"
2021-05-06 05:24:24 +08:00
"github.com/stretchr/testify/assert"
Net 503 - use NewHosts to init hostfile (#2473) * use NewHosts to init hostfile * Revert "Bump github.com/txn2/txeh from 1.4.0 to 1.5.3 (#2464)" (#2475) This reverts commit aafaa91af0c922157cd49a8dcb059ed2e3d3074f. * NET-433: Only Set Routes for NAT enabled egress GW (#2469) * remove related fields and code * remover metrics collection from server code * fw update struct * add ext client flag to metrics data * simply nat types * rm proxy update from cli * remove ingress routes from firewall update * check if egress ranges are present * rm unused func * ignore network parameter passed to delete ingress endpoint (#2471) * fix(NET-388): fix to update node dns toggle (#2472) * use local port for metrics pinger (#2479) * v0.20.5 release notes (#2482) * v0.20.5 release notes * add a known issue * update develop to v0.20.6 (#2485) * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * Bump github.com/go-playground/validator/v10 from 10.14.1 to 10.15.0 (#2503) Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.14.1 to 10.15.0. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.14.1...v10.15.0) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump golang.org/x/oauth2 from 0.10.0 to 0.11.0 (#2502) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/oauth2/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump alpine from 3.18.2 to 3.18.3 (#2500) Bumps alpine from 3.18.2 to 3.18.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Net 509 515 (#2496) * NET-509 * External client config files with IPv6 endpoints now have the [] separating the address and port. * NET-515 * Increased network name max length to 32 * NET-509-515 * Updated unit test for network name max length check. * Updated extclient endpoint ip string manipulation to use sprintf * Added proper error message for network name length more than max allowed. * NET-515 small typo fix for error strings should not be capitalized * [NET-494 / ACC-322] New free tier limits (#2495) * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * NET-507 (#2506) * NET-507 * Fixed server restart changing the node expiration date to the defaults. * Removed expired nodes removal from zombie cleanup routine. * Added a new expired nodes deletion routine which removes expired nodes every hour. * NET-507 suggested changes * Possible fix for zombie nodes upon node deletion from the UI. * Suggested changes implemented for expired nodes deletion go routine. * NET-507 typo fix * typo fix for DeleteNode purge parameter * NET-517 (#2510) * Fixed emqx docker compose file syntax and added volumes for persistence. * Added helper comments for docker-compose.yml and netmaker.env files to enable emqx broker support. * migration (#2509) * create gateways during migration * set version for testing * restruct migration * debug logging * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * rebase conflict * include pass and os in mirgration data * node network ranges * remove debugging logs * add gateways * use sent node * upgrade shell script * associate node to host during migration * add node to host.Nodes and publish peer update * save host outside loop * fix script name * simplify upgrade script * don't migrate relays * simplify upgrade script even more * guard against blank address or address6 * typos --------- Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> * dns tests * go mod tidy * set dns dir when testing * troubleshoot test failure * test fail troubleshooting * use txeh.RenderHostFile to compare --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-25 13:25:47 +08:00
"github.com/txn2/txeh"
2023-01-21 06:38:32 +08:00
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
Net 503 - use NewHosts to init hostfile (#2473) * use NewHosts to init hostfile * Revert "Bump github.com/txn2/txeh from 1.4.0 to 1.5.3 (#2464)" (#2475) This reverts commit aafaa91af0c922157cd49a8dcb059ed2e3d3074f. * NET-433: Only Set Routes for NAT enabled egress GW (#2469) * remove related fields and code * remover metrics collection from server code * fw update struct * add ext client flag to metrics data * simply nat types * rm proxy update from cli * remove ingress routes from firewall update * check if egress ranges are present * rm unused func * ignore network parameter passed to delete ingress endpoint (#2471) * fix(NET-388): fix to update node dns toggle (#2472) * use local port for metrics pinger (#2479) * v0.20.5 release notes (#2482) * v0.20.5 release notes * add a known issue * update develop to v0.20.6 (#2485) * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * Bump github.com/go-playground/validator/v10 from 10.14.1 to 10.15.0 (#2503) Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.14.1 to 10.15.0. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.14.1...v10.15.0) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump golang.org/x/oauth2 from 0.10.0 to 0.11.0 (#2502) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/oauth2/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump alpine from 3.18.2 to 3.18.3 (#2500) Bumps alpine from 3.18.2 to 3.18.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Net 509 515 (#2496) * NET-509 * External client config files with IPv6 endpoints now have the [] separating the address and port. * NET-515 * Increased network name max length to 32 * NET-509-515 * Updated unit test for network name max length check. * Updated extclient endpoint ip string manipulation to use sprintf * Added proper error message for network name length more than max allowed. * NET-515 small typo fix for error strings should not be capitalized * [NET-494 / ACC-322] New free tier limits (#2495) * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * NET-507 (#2506) * NET-507 * Fixed server restart changing the node expiration date to the defaults. * Removed expired nodes removal from zombie cleanup routine. * Added a new expired nodes deletion routine which removes expired nodes every hour. * NET-507 suggested changes * Possible fix for zombie nodes upon node deletion from the UI. * Suggested changes implemented for expired nodes deletion go routine. * NET-507 typo fix * typo fix for DeleteNode purge parameter * NET-517 (#2510) * Fixed emqx docker compose file syntax and added volumes for persistence. * Added helper comments for docker-compose.yml and netmaker.env files to enable emqx broker support. * migration (#2509) * create gateways during migration * set version for testing * restruct migration * debug logging * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * rebase conflict * include pass and os in mirgration data * node network ranges * remove debugging logs * add gateways * use sent node * upgrade shell script * associate node to host during migration * add node to host.Nodes and publish peer update * save host outside loop * fix script name * simplify upgrade script * don't migrate relays * simplify upgrade script even more * guard against blank address or address6 * typos --------- Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> * dns tests * go mod tidy * set dns dir when testing * troubleshoot test failure * test fail troubleshooting * use txeh.RenderHostFile to compare --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-25 13:25:47 +08:00
"github.com/gravitl/netmaker/functions"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/models"
2021-05-06 05:24:24 +08:00
)
2023-01-21 06:38:32 +08:00
var dnsHost models.Host
2021-10-17 23:47:25 +08:00
func TestGetAllDNS(t *testing.T) {
deleteAllDNS(t)
deleteAllNetworks()
createNet()
2023-01-21 06:38:32 +08:00
createHost()
2021-10-17 23:47:25 +08:00
t.Run("NoEntries", func(t *testing.T) {
2021-12-08 01:46:55 +08:00
entries, err := logic.GetAllDNS()
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Equal(t, []models.DNSEntry(nil), entries)
})
t.Run("OneEntry", func(t *testing.T) {
2023-01-21 06:38:32 +08:00
entry := models.DNSEntry{
Address: "10.0.0.3", Name: "newhost", Network: "skynet",
2023-01-21 06:38:32 +08:00
}
_, err := logic.CreateDNS(entry)
assert.Nil(t, err)
2021-12-08 01:46:55 +08:00
entries, err := logic.GetAllDNS()
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Equal(t, 1, len(entries))
})
t.Run("MultipleEntry", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.0.7", Name: "anotherhost", Network: "skynet"}
2023-01-21 06:38:32 +08:00
_, err := logic.CreateDNS(entry)
assert.Nil(t, err)
2021-12-08 01:46:55 +08:00
entries, err := logic.GetAllDNS()
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Equal(t, 2, len(entries))
})
}
2021-05-06 05:24:24 +08:00
func TestGetNodeDNS(t *testing.T) {
2021-10-17 23:47:25 +08:00
deleteAllDNS(t)
2021-09-10 04:20:21 +08:00
deleteAllNetworks()
createNet()
2023-01-21 06:38:32 +08:00
createHost()
Net 503 - use NewHosts to init hostfile (#2473) * use NewHosts to init hostfile * Revert "Bump github.com/txn2/txeh from 1.4.0 to 1.5.3 (#2464)" (#2475) This reverts commit aafaa91af0c922157cd49a8dcb059ed2e3d3074f. * NET-433: Only Set Routes for NAT enabled egress GW (#2469) * remove related fields and code * remover metrics collection from server code * fw update struct * add ext client flag to metrics data * simply nat types * rm proxy update from cli * remove ingress routes from firewall update * check if egress ranges are present * rm unused func * ignore network parameter passed to delete ingress endpoint (#2471) * fix(NET-388): fix to update node dns toggle (#2472) * use local port for metrics pinger (#2479) * v0.20.5 release notes (#2482) * v0.20.5 release notes * add a known issue * update develop to v0.20.6 (#2485) * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * Bump github.com/go-playground/validator/v10 from 10.14.1 to 10.15.0 (#2503) Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.14.1 to 10.15.0. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.14.1...v10.15.0) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump golang.org/x/oauth2 from 0.10.0 to 0.11.0 (#2502) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/oauth2/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump alpine from 3.18.2 to 3.18.3 (#2500) Bumps alpine from 3.18.2 to 3.18.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Net 509 515 (#2496) * NET-509 * External client config files with IPv6 endpoints now have the [] separating the address and port. * NET-515 * Increased network name max length to 32 * NET-509-515 * Updated unit test for network name max length check. * Updated extclient endpoint ip string manipulation to use sprintf * Added proper error message for network name length more than max allowed. * NET-515 small typo fix for error strings should not be capitalized * [NET-494 / ACC-322] New free tier limits (#2495) * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * NET-507 (#2506) * NET-507 * Fixed server restart changing the node expiration date to the defaults. * Removed expired nodes removal from zombie cleanup routine. * Added a new expired nodes deletion routine which removes expired nodes every hour. * NET-507 suggested changes * Possible fix for zombie nodes upon node deletion from the UI. * Suggested changes implemented for expired nodes deletion go routine. * NET-507 typo fix * typo fix for DeleteNode purge parameter * NET-517 (#2510) * Fixed emqx docker compose file syntax and added volumes for persistence. * Added helper comments for docker-compose.yml and netmaker.env files to enable emqx broker support. * migration (#2509) * create gateways during migration * set version for testing * restruct migration * debug logging * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * rebase conflict * include pass and os in mirgration data * node network ranges * remove debugging logs * add gateways * use sent node * upgrade shell script * associate node to host during migration * add node to host.Nodes and publish peer update * save host outside loop * fix script name * simplify upgrade script * don't migrate relays * simplify upgrade script even more * guard against blank address or address6 * typos --------- Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> * dns tests * go mod tidy * set dns dir when testing * troubleshoot test failure * test fail troubleshooting * use txeh.RenderHostFile to compare --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-25 13:25:47 +08:00
err := functions.SetDNSDir()
assert.Nil(t, err)
2021-10-17 23:47:25 +08:00
t.Run("NoNodes", func(t *testing.T) {
2023-06-28 00:45:36 +08:00
dns, _ := logic.GetNodeDNS("skynet")
2021-10-17 23:47:25 +08:00
assert.Equal(t, []models.DNSEntry(nil), dns)
})
t.Run("NodeExists", func(t *testing.T) {
2023-01-21 06:38:32 +08:00
createHost()
_, ipnet, _ := net.ParseCIDR("10.0.0.1/32")
tmpCNode := models.CommonNode{
ID: uuid.New(),
Network: "skynet",
Address: *ipnet,
DNSOn: true,
}
createnode := models.Node{
CommonNode: tmpCNode,
}
err := logic.AssociateNodeToHost(&createnode, &dnsHost)
2022-12-19 18:52:47 +08:00
assert.Nil(t, err)
2021-12-08 01:46:55 +08:00
dns, err := logic.GetNodeDNS("skynet")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Equal(t, "10.0.0.1", dns[0].Address)
})
t.Run("MultipleNodes", func(t *testing.T) {
2023-01-21 06:38:32 +08:00
_, ipnet, _ := net.ParseCIDR("10.100.100.3/32")
tmpCNode := models.CommonNode{
ID: uuid.New(),
Network: "skynet",
Address: *ipnet,
DNSOn: true,
}
createnode := models.Node{
CommonNode: tmpCNode,
}
err := logic.AssociateNodeToHost(&createnode, &dnsHost)
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
2021-12-08 01:46:55 +08:00
dns, err := logic.GetNodeDNS("skynet")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Equal(t, 2, len(dns))
})
2021-05-06 05:24:24 +08:00
}
func TestGetCustomDNS(t *testing.T) {
2021-10-17 23:47:25 +08:00
deleteAllDNS(t)
2021-09-10 04:20:21 +08:00
deleteAllNetworks()
2021-10-17 23:47:25 +08:00
t.Run("NoNetworks", func(t *testing.T) {
2021-10-27 00:27:29 +08:00
dns, err := logic.GetCustomDNS("skynet")
2021-10-17 23:47:25 +08:00
assert.EqualError(t, err, "could not find any records")
assert.Equal(t, []models.DNSEntry(nil), dns)
})
t.Run("NoNodes", func(t *testing.T) {
createNet()
2021-10-27 00:27:29 +08:00
dns, err := logic.GetCustomDNS("skynet")
2021-10-17 23:47:25 +08:00
assert.EqualError(t, err, "could not find any records")
assert.Equal(t, []models.DNSEntry(nil), dns)
})
t.Run("NodeExists", func(t *testing.T) {
createTestNode()
2021-10-27 00:27:29 +08:00
dns, err := logic.GetCustomDNS("skynet")
2021-10-17 23:47:25 +08:00
assert.EqualError(t, err, "could not find any records")
assert.Equal(t, 0, len(dns))
})
t.Run("EntryExist", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.0.3", Name: "custom1", Network: "skynet"}
2023-01-21 06:38:32 +08:00
_, err := logic.CreateDNS(entry)
2023-01-25 00:20:06 +08:00
assert.Nil(t, err)
2021-10-27 00:27:29 +08:00
dns, err := logic.GetCustomDNS("skynet")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Equal(t, 1, len(dns))
})
t.Run("MultipleEntries", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.0.4", Name: "host4", Network: "skynet"}
2023-01-21 06:38:32 +08:00
_, err := logic.CreateDNS(entry)
assert.Nil(t, err)
2021-10-27 00:27:29 +08:00
dns, err := logic.GetCustomDNS("skynet")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Equal(t, 2, len(dns))
})
2021-05-06 05:24:24 +08:00
}
2021-10-17 23:47:25 +08:00
2021-05-06 05:24:24 +08:00
func TestGetDNSEntryNum(t *testing.T) {
2021-10-17 23:47:25 +08:00
deleteAllDNS(t)
2021-09-10 04:20:21 +08:00
deleteAllNetworks()
createNet()
2021-10-17 23:47:25 +08:00
t.Run("NoNodes", func(t *testing.T) {
2021-12-08 01:46:55 +08:00
num, err := logic.GetDNSEntryNum("myhost", "skynet")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Equal(t, 0, num)
})
t.Run("NodeExists", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.0.2", Name: "newhost", Network: "skynet"}
2023-01-21 06:38:32 +08:00
_, err := logic.CreateDNS(entry)
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
2021-12-08 01:46:55 +08:00
num, err := logic.GetDNSEntryNum("newhost", "skynet")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Equal(t, 1, num)
})
2021-05-06 05:24:24 +08:00
}
func TestGetDNS(t *testing.T) {
2021-10-17 23:47:25 +08:00
deleteAllDNS(t)
2021-09-10 04:20:21 +08:00
deleteAllNetworks()
2021-10-17 23:47:25 +08:00
createNet()
t.Run("NoEntries", func(t *testing.T) {
2021-10-27 00:27:29 +08:00
dns, err := logic.GetDNS("skynet")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Nil(t, dns)
})
t.Run("CustomDNSExists", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.0.2", Name: "newhost", Network: "skynet"}
2023-01-21 06:38:32 +08:00
_, err := logic.CreateDNS(entry)
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
2021-10-27 00:27:29 +08:00
dns, err := logic.GetDNS("skynet")
2021-10-17 23:47:25 +08:00
t.Log(dns)
assert.Nil(t, err)
assert.NotNil(t, dns)
assert.Equal(t, "skynet", dns[0].Network)
assert.Equal(t, 1, len(dns))
})
t.Run("NodeExists", func(t *testing.T) {
deleteAllDNS(t)
createTestNode()
2021-10-27 00:27:29 +08:00
dns, err := logic.GetDNS("skynet")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.NotNil(t, dns)
assert.Equal(t, "skynet", dns[0].Network)
assert.Equal(t, 1, len(dns))
})
t.Run("NodeAndCustomDNS", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.0.2", Name: "newhost", Network: "skynet"}
2023-01-21 06:38:32 +08:00
_, err := logic.CreateDNS(entry)
2022-06-17 03:42:32 +08:00
assert.Nil(t, err)
2021-10-27 00:27:29 +08:00
dns, err := logic.GetDNS("skynet")
2021-10-17 23:47:25 +08:00
t.Log(dns)
assert.Nil(t, err)
assert.NotNil(t, dns)
assert.Equal(t, "skynet", dns[0].Network)
assert.Equal(t, "skynet", dns[1].Network)
assert.Equal(t, 2, len(dns))
})
2021-05-06 05:24:24 +08:00
}
2021-10-17 23:47:25 +08:00
2021-05-06 05:24:24 +08:00
func TestCreateDNS(t *testing.T) {
2021-09-10 04:20:21 +08:00
deleteAllDNS(t)
2021-10-17 23:47:25 +08:00
deleteAllNetworks()
2021-05-06 05:24:24 +08:00
createNet()
entry := models.DNSEntry{Address: "10.0.0.2", Name: "newhost", Network: "skynet"}
2023-01-21 06:38:32 +08:00
dns, err := logic.CreateDNS(entry)
2021-05-06 05:24:24 +08:00
assert.Nil(t, err)
2021-10-17 23:47:25 +08:00
assert.Equal(t, "newhost", dns.Name)
}
func TestSetDNS(t *testing.T) {
deleteAllDNS(t)
deleteAllNetworks()
Net 503 - use NewHosts to init hostfile (#2473) * use NewHosts to init hostfile * Revert "Bump github.com/txn2/txeh from 1.4.0 to 1.5.3 (#2464)" (#2475) This reverts commit aafaa91af0c922157cd49a8dcb059ed2e3d3074f. * NET-433: Only Set Routes for NAT enabled egress GW (#2469) * remove related fields and code * remover metrics collection from server code * fw update struct * add ext client flag to metrics data * simply nat types * rm proxy update from cli * remove ingress routes from firewall update * check if egress ranges are present * rm unused func * ignore network parameter passed to delete ingress endpoint (#2471) * fix(NET-388): fix to update node dns toggle (#2472) * use local port for metrics pinger (#2479) * v0.20.5 release notes (#2482) * v0.20.5 release notes * add a known issue * update develop to v0.20.6 (#2485) * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * Bump github.com/go-playground/validator/v10 from 10.14.1 to 10.15.0 (#2503) Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.14.1 to 10.15.0. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.14.1...v10.15.0) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump golang.org/x/oauth2 from 0.10.0 to 0.11.0 (#2502) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/oauth2/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump alpine from 3.18.2 to 3.18.3 (#2500) Bumps alpine from 3.18.2 to 3.18.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Net 509 515 (#2496) * NET-509 * External client config files with IPv6 endpoints now have the [] separating the address and port. * NET-515 * Increased network name max length to 32 * NET-509-515 * Updated unit test for network name max length check. * Updated extclient endpoint ip string manipulation to use sprintf * Added proper error message for network name length more than max allowed. * NET-515 small typo fix for error strings should not be capitalized * [NET-494 / ACC-322] New free tier limits (#2495) * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * NET-507 (#2506) * NET-507 * Fixed server restart changing the node expiration date to the defaults. * Removed expired nodes removal from zombie cleanup routine. * Added a new expired nodes deletion routine which removes expired nodes every hour. * NET-507 suggested changes * Possible fix for zombie nodes upon node deletion from the UI. * Suggested changes implemented for expired nodes deletion go routine. * NET-507 typo fix * typo fix for DeleteNode purge parameter * NET-517 (#2510) * Fixed emqx docker compose file syntax and added volumes for persistence. * Added helper comments for docker-compose.yml and netmaker.env files to enable emqx broker support. * migration (#2509) * create gateways during migration * set version for testing * restruct migration * debug logging * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * rebase conflict * include pass and os in mirgration data * node network ranges * remove debugging logs * add gateways * use sent node * upgrade shell script * associate node to host during migration * add node to host.Nodes and publish peer update * save host outside loop * fix script name * simplify upgrade script * don't migrate relays * simplify upgrade script even more * guard against blank address or address6 * typos --------- Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> * dns tests * go mod tidy * set dns dir when testing * troubleshoot test failure * test fail troubleshooting * use txeh.RenderHostFile to compare --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-25 13:25:47 +08:00
etc, err := txeh.NewHosts(&txeh.HostsConfig{})
assert.Nil(t, err)
err = functions.SetDNSDir()
assert.Nil(t, err)
2021-10-17 23:47:25 +08:00
t.Run("NoNetworks", func(t *testing.T) {
2021-10-27 00:27:29 +08:00
err := logic.SetDNS()
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
Net 503 - use NewHosts to init hostfile (#2473) * use NewHosts to init hostfile * Revert "Bump github.com/txn2/txeh from 1.4.0 to 1.5.3 (#2464)" (#2475) This reverts commit aafaa91af0c922157cd49a8dcb059ed2e3d3074f. * NET-433: Only Set Routes for NAT enabled egress GW (#2469) * remove related fields and code * remover metrics collection from server code * fw update struct * add ext client flag to metrics data * simply nat types * rm proxy update from cli * remove ingress routes from firewall update * check if egress ranges are present * rm unused func * ignore network parameter passed to delete ingress endpoint (#2471) * fix(NET-388): fix to update node dns toggle (#2472) * use local port for metrics pinger (#2479) * v0.20.5 release notes (#2482) * v0.20.5 release notes * add a known issue * update develop to v0.20.6 (#2485) * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * Bump github.com/go-playground/validator/v10 from 10.14.1 to 10.15.0 (#2503) Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.14.1 to 10.15.0. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.14.1...v10.15.0) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump golang.org/x/oauth2 from 0.10.0 to 0.11.0 (#2502) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/oauth2/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump alpine from 3.18.2 to 3.18.3 (#2500) Bumps alpine from 3.18.2 to 3.18.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Net 509 515 (#2496) * NET-509 * External client config files with IPv6 endpoints now have the [] separating the address and port. * NET-515 * Increased network name max length to 32 * NET-509-515 * Updated unit test for network name max length check. * Updated extclient endpoint ip string manipulation to use sprintf * Added proper error message for network name length more than max allowed. * NET-515 small typo fix for error strings should not be capitalized * [NET-494 / ACC-322] New free tier limits (#2495) * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * NET-507 (#2506) * NET-507 * Fixed server restart changing the node expiration date to the defaults. * Removed expired nodes removal from zombie cleanup routine. * Added a new expired nodes deletion routine which removes expired nodes every hour. * NET-507 suggested changes * Possible fix for zombie nodes upon node deletion from the UI. * Suggested changes implemented for expired nodes deletion go routine. * NET-507 typo fix * typo fix for DeleteNode purge parameter * NET-517 (#2510) * Fixed emqx docker compose file syntax and added volumes for persistence. * Added helper comments for docker-compose.yml and netmaker.env files to enable emqx broker support. * migration (#2509) * create gateways during migration * set version for testing * restruct migration * debug logging * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * rebase conflict * include pass and os in mirgration data * node network ranges * remove debugging logs * add gateways * use sent node * upgrade shell script * associate node to host during migration * add node to host.Nodes and publish peer update * save host outside loop * fix script name * simplify upgrade script * don't migrate relays * simplify upgrade script even more * guard against blank address or address6 * typos --------- Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> * dns tests * go mod tidy * set dns dir when testing * troubleshoot test failure * test fail troubleshooting * use txeh.RenderHostFile to compare --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-25 13:25:47 +08:00
info, err := txeh.NewHosts(&txeh.HostsConfig{
ReadFilePath: "./config/dnsconfig/netmaker.hosts",
})
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
Net 503 - use NewHosts to init hostfile (#2473) * use NewHosts to init hostfile * Revert "Bump github.com/txn2/txeh from 1.4.0 to 1.5.3 (#2464)" (#2475) This reverts commit aafaa91af0c922157cd49a8dcb059ed2e3d3074f. * NET-433: Only Set Routes for NAT enabled egress GW (#2469) * remove related fields and code * remover metrics collection from server code * fw update struct * add ext client flag to metrics data * simply nat types * rm proxy update from cli * remove ingress routes from firewall update * check if egress ranges are present * rm unused func * ignore network parameter passed to delete ingress endpoint (#2471) * fix(NET-388): fix to update node dns toggle (#2472) * use local port for metrics pinger (#2479) * v0.20.5 release notes (#2482) * v0.20.5 release notes * add a known issue * update develop to v0.20.6 (#2485) * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * Bump github.com/go-playground/validator/v10 from 10.14.1 to 10.15.0 (#2503) Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.14.1 to 10.15.0. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.14.1...v10.15.0) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump golang.org/x/oauth2 from 0.10.0 to 0.11.0 (#2502) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/oauth2/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump alpine from 3.18.2 to 3.18.3 (#2500) Bumps alpine from 3.18.2 to 3.18.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Net 509 515 (#2496) * NET-509 * External client config files with IPv6 endpoints now have the [] separating the address and port. * NET-515 * Increased network name max length to 32 * NET-509-515 * Updated unit test for network name max length check. * Updated extclient endpoint ip string manipulation to use sprintf * Added proper error message for network name length more than max allowed. * NET-515 small typo fix for error strings should not be capitalized * [NET-494 / ACC-322] New free tier limits (#2495) * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * NET-507 (#2506) * NET-507 * Fixed server restart changing the node expiration date to the defaults. * Removed expired nodes removal from zombie cleanup routine. * Added a new expired nodes deletion routine which removes expired nodes every hour. * NET-507 suggested changes * Possible fix for zombie nodes upon node deletion from the UI. * Suggested changes implemented for expired nodes deletion go routine. * NET-507 typo fix * typo fix for DeleteNode purge parameter * NET-517 (#2510) * Fixed emqx docker compose file syntax and added volumes for persistence. * Added helper comments for docker-compose.yml and netmaker.env files to enable emqx broker support. * migration (#2509) * create gateways during migration * set version for testing * restruct migration * debug logging * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * rebase conflict * include pass and os in mirgration data * node network ranges * remove debugging logs * add gateways * use sent node * upgrade shell script * associate node to host during migration * add node to host.Nodes and publish peer update * save host outside loop * fix script name * simplify upgrade script * don't migrate relays * simplify upgrade script even more * guard against blank address or address6 * typos --------- Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> * dns tests * go mod tidy * set dns dir when testing * troubleshoot test failure * test fail troubleshooting * use txeh.RenderHostFile to compare --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-25 13:25:47 +08:00
assert.Equal(t, etc.RenderHostsFile(), info.RenderHostsFile())
2021-10-17 23:47:25 +08:00
})
t.Run("NoEntries", func(t *testing.T) {
createNet()
2021-10-27 00:27:29 +08:00
err := logic.SetDNS()
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
Net 503 - use NewHosts to init hostfile (#2473) * use NewHosts to init hostfile * Revert "Bump github.com/txn2/txeh from 1.4.0 to 1.5.3 (#2464)" (#2475) This reverts commit aafaa91af0c922157cd49a8dcb059ed2e3d3074f. * NET-433: Only Set Routes for NAT enabled egress GW (#2469) * remove related fields and code * remover metrics collection from server code * fw update struct * add ext client flag to metrics data * simply nat types * rm proxy update from cli * remove ingress routes from firewall update * check if egress ranges are present * rm unused func * ignore network parameter passed to delete ingress endpoint (#2471) * fix(NET-388): fix to update node dns toggle (#2472) * use local port for metrics pinger (#2479) * v0.20.5 release notes (#2482) * v0.20.5 release notes * add a known issue * update develop to v0.20.6 (#2485) * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * Bump github.com/go-playground/validator/v10 from 10.14.1 to 10.15.0 (#2503) Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.14.1 to 10.15.0. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.14.1...v10.15.0) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump golang.org/x/oauth2 from 0.10.0 to 0.11.0 (#2502) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/oauth2/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump alpine from 3.18.2 to 3.18.3 (#2500) Bumps alpine from 3.18.2 to 3.18.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Net 509 515 (#2496) * NET-509 * External client config files with IPv6 endpoints now have the [] separating the address and port. * NET-515 * Increased network name max length to 32 * NET-509-515 * Updated unit test for network name max length check. * Updated extclient endpoint ip string manipulation to use sprintf * Added proper error message for network name length more than max allowed. * NET-515 small typo fix for error strings should not be capitalized * [NET-494 / ACC-322] New free tier limits (#2495) * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * NET-507 (#2506) * NET-507 * Fixed server restart changing the node expiration date to the defaults. * Removed expired nodes removal from zombie cleanup routine. * Added a new expired nodes deletion routine which removes expired nodes every hour. * NET-507 suggested changes * Possible fix for zombie nodes upon node deletion from the UI. * Suggested changes implemented for expired nodes deletion go routine. * NET-507 typo fix * typo fix for DeleteNode purge parameter * NET-517 (#2510) * Fixed emqx docker compose file syntax and added volumes for persistence. * Added helper comments for docker-compose.yml and netmaker.env files to enable emqx broker support. * migration (#2509) * create gateways during migration * set version for testing * restruct migration * debug logging * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * rebase conflict * include pass and os in mirgration data * node network ranges * remove debugging logs * add gateways * use sent node * upgrade shell script * associate node to host during migration * add node to host.Nodes and publish peer update * save host outside loop * fix script name * simplify upgrade script * don't migrate relays * simplify upgrade script even more * guard against blank address or address6 * typos --------- Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> * dns tests * go mod tidy * set dns dir when testing * troubleshoot test failure * test fail troubleshooting * use txeh.RenderHostFile to compare --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-25 13:25:47 +08:00
info, err := txeh.NewHosts(&txeh.HostsConfig{
ReadFilePath: "./config/dnsconfig/netmaker.hosts",
})
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
Net 503 - use NewHosts to init hostfile (#2473) * use NewHosts to init hostfile * Revert "Bump github.com/txn2/txeh from 1.4.0 to 1.5.3 (#2464)" (#2475) This reverts commit aafaa91af0c922157cd49a8dcb059ed2e3d3074f. * NET-433: Only Set Routes for NAT enabled egress GW (#2469) * remove related fields and code * remover metrics collection from server code * fw update struct * add ext client flag to metrics data * simply nat types * rm proxy update from cli * remove ingress routes from firewall update * check if egress ranges are present * rm unused func * ignore network parameter passed to delete ingress endpoint (#2471) * fix(NET-388): fix to update node dns toggle (#2472) * use local port for metrics pinger (#2479) * v0.20.5 release notes (#2482) * v0.20.5 release notes * add a known issue * update develop to v0.20.6 (#2485) * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * Bump github.com/go-playground/validator/v10 from 10.14.1 to 10.15.0 (#2503) Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.14.1 to 10.15.0. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.14.1...v10.15.0) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump golang.org/x/oauth2 from 0.10.0 to 0.11.0 (#2502) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/oauth2/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump alpine from 3.18.2 to 3.18.3 (#2500) Bumps alpine from 3.18.2 to 3.18.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Net 509 515 (#2496) * NET-509 * External client config files with IPv6 endpoints now have the [] separating the address and port. * NET-515 * Increased network name max length to 32 * NET-509-515 * Updated unit test for network name max length check. * Updated extclient endpoint ip string manipulation to use sprintf * Added proper error message for network name length more than max allowed. * NET-515 small typo fix for error strings should not be capitalized * [NET-494 / ACC-322] New free tier limits (#2495) * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * NET-507 (#2506) * NET-507 * Fixed server restart changing the node expiration date to the defaults. * Removed expired nodes removal from zombie cleanup routine. * Added a new expired nodes deletion routine which removes expired nodes every hour. * NET-507 suggested changes * Possible fix for zombie nodes upon node deletion from the UI. * Suggested changes implemented for expired nodes deletion go routine. * NET-507 typo fix * typo fix for DeleteNode purge parameter * NET-517 (#2510) * Fixed emqx docker compose file syntax and added volumes for persistence. * Added helper comments for docker-compose.yml and netmaker.env files to enable emqx broker support. * migration (#2509) * create gateways during migration * set version for testing * restruct migration * debug logging * enforce unique names for ext client names (#2476) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * prune(NET-483): remove defunct host.internetgateway field (#2487) * don't reference host on err (#2493) * deprecrate netclient install scripts (#2490) * Net 500: validate network parameter passed to node endpoints (#2480) * enforce unique names for ext client names * only check for unique id on creation * check for unique id if changed * validate network parameter passed to node endpoints --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * NET-513 (#2492) nm-certs.sh now requests certificate for EE and CE edition domains accordingly. * [NET-404] Run in limited mode when ee checks fail (#2474) * Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func * feat(NET-449): add sync feature to request a host pull from server (#2491) * fix(NET-486): change client name length validation (#2498) set limit to 5<=x<=32 * [NET-477] Pick AMB URL dynamically (#2489) * Introduce config for environment * Introduce func to get environment * Choose accounts api host from environment * Test the ee package on workflows * Use build tag ee for license_test.go * [Feature]: nm-quick script tackling arm TODO support (#2488) * domain flag for auto installs * use static servers with custom domain (#2421) * send delete peer update always * fix add/remove host api calls * keep mq updates in a single go func * move branch test logic to devops (#2443) * handle IOT OS * save server name to env (#2460) * ensure branch test servers available after test runs (#2467) * save server name to env * free server always; add PR to discord messages * use correct method to delete droplets (#2468) * quick fix for the launcher * removed exit when triggering not supported exit and removed the TODO comments related to this issue --------- Co-authored-by: Matthew R Kasun <mkasun@nusak.ca> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> * rebase conflict * include pass and os in mirgration data * node network ranges * remove debugging logs * add gateways * use sent node * upgrade shell script * associate node to host during migration * add node to host.Nodes and publish peer update * save host outside loop * fix script name * simplify upgrade script * don't migrate relays * simplify upgrade script even more * guard against blank address or address6 * typos --------- Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> * dns tests * go mod tidy * set dns dir when testing * troubleshoot test failure * test fail troubleshooting * use txeh.RenderHostFile to compare --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com> Co-authored-by: Aceix <aceixsmartX@gmail.com> Co-authored-by: Christopher Blaha <crispspiceguitar@gmail.com> Co-authored-by: Farukh Khan <farukhkhan21@gmail.com> Co-authored-by: Gabriel de Souza Seibel <gabrielseibel1@gmail.com> Co-authored-by: bornav <51048565+bornav@users.noreply.github.com> Co-authored-by: Alex Feiszli <31018251+afeiszli@users.noreply.github.com> Co-authored-by: Abhishek Kondur <abhi281342@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-25 13:25:47 +08:00
assert.Equal(t, etc.RenderHostsFile(), info.RenderHostsFile())
2021-10-17 23:47:25 +08:00
})
t.Run("NodeExists", func(t *testing.T) {
createTestNode()
2021-10-27 00:27:29 +08:00
err := logic.SetDNS()
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
info, err := os.Stat("./config/dnsconfig/netmaker.hosts")
assert.Nil(t, err)
assert.False(t, info.IsDir())
2022-01-07 04:05:38 +08:00
content, err := os.ReadFile("./config/dnsconfig/netmaker.hosts")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Contains(t, string(content), "linuxhost")
2021-10-17 23:47:25 +08:00
})
t.Run("EntryExists", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.0.3", Name: "newhost", Network: "skynet"}
2023-01-21 06:38:32 +08:00
_, err := logic.CreateDNS(entry)
assert.Nil(t, err)
err = logic.SetDNS()
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
info, err := os.Stat("./config/dnsconfig/netmaker.hosts")
assert.Nil(t, err)
assert.False(t, info.IsDir())
2022-01-07 04:05:38 +08:00
content, err := os.ReadFile("./config/dnsconfig/netmaker.hosts")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
assert.Contains(t, string(content), "newhost")
2021-10-17 23:47:25 +08:00
})
2021-05-06 05:24:24 +08:00
}
2021-10-17 23:47:25 +08:00
2021-05-06 05:24:24 +08:00
func TestGetDNSEntry(t *testing.T) {
2021-10-17 23:47:25 +08:00
deleteAllDNS(t)
2021-09-10 04:20:21 +08:00
deleteAllNetworks()
createNet()
createTestNode()
entry := models.DNSEntry{Address: "10.0.0.2", Name: "newhost", Network: "skynet"}
2023-01-21 06:38:32 +08:00
_, _ = logic.CreateDNS(entry)
2021-10-17 23:47:25 +08:00
t.Run("wrong net", func(t *testing.T) {
entry, err := GetDNSEntry("newhost", "w286 Toronto Street South, Uxbridge, ONirecat")
assert.EqualError(t, err, "no result found")
assert.Equal(t, models.DNSEntry{}, entry)
})
t.Run("wrong host", func(t *testing.T) {
entry, err := GetDNSEntry("badhost", "skynet")
assert.EqualError(t, err, "no result found")
assert.Equal(t, models.DNSEntry{}, entry)
})
t.Run("good host", func(t *testing.T) {
entry, err := GetDNSEntry("newhost", "skynet")
assert.Nil(t, err)
assert.Equal(t, "newhost", entry.Name)
})
t.Run("node", func(t *testing.T) {
entry, err := GetDNSEntry("testnode", "skynet")
assert.EqualError(t, err, "no result found")
assert.Equal(t, models.DNSEntry{}, entry)
})
2021-05-06 05:24:24 +08:00
}
2021-12-08 01:46:55 +08:00
2021-05-06 05:24:24 +08:00
func TestDeleteDNS(t *testing.T) {
2021-10-17 23:47:25 +08:00
deleteAllDNS(t)
deleteAllNetworks()
createNet()
entry := models.DNSEntry{Address: "10.0.0.2", Name: "newhost", Network: "skynet"}
2023-01-21 06:38:32 +08:00
_, _ = logic.CreateDNS(entry)
2021-05-06 05:24:24 +08:00
t.Run("EntryExists", func(t *testing.T) {
2021-12-08 01:46:55 +08:00
err := logic.DeleteDNS("newhost", "skynet")
2021-05-06 05:24:24 +08:00
assert.Nil(t, err)
})
2021-10-17 23:47:25 +08:00
t.Run("NodeExists", func(t *testing.T) {
2021-12-08 01:46:55 +08:00
err := logic.DeleteDNS("myhost", "skynet")
2021-05-06 05:24:24 +08:00
assert.Nil(t, err)
})
2021-10-17 23:47:25 +08:00
t.Run("NoEntries", func(t *testing.T) {
2021-12-08 01:46:55 +08:00
err := logic.DeleteDNS("myhost", "skynet")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
})
2021-05-06 05:24:24 +08:00
}
2021-05-10 01:31:50 +08:00
2021-05-06 05:24:24 +08:00
func TestValidateDNSUpdate(t *testing.T) {
2021-10-17 23:47:25 +08:00
deleteAllDNS(t)
deleteAllNetworks()
createNet()
entry := models.DNSEntry{Address: "10.0.0.2", Name: "myhost", Network: "skynet"}
2021-05-06 05:24:24 +08:00
t.Run("BadNetwork", func(t *testing.T) {
change := models.DNSEntry{Address: "10.0.0.2", Name: "myhost", Network: "badnet"}
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSUpdate(change, entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Network' failed on the 'network_exists' tag")
})
t.Run("EmptyNetwork", func(t *testing.T) {
// this can't actually happen as change.Network is populated if is blank
change := models.DNSEntry{Address: "10.0.0.2", Name: "myhost"}
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSUpdate(change, entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Network' failed on the 'network_exists' tag")
})
2022-04-26 01:28:00 +08:00
// t.Run("EmptyAddress", func(t *testing.T) {
// //this can't actually happen as change.Address is populated if is blank
// change := models.DNSEntry{"", "", "myhost", "skynet"}
// err := logic.ValidateDNSUpdate(change, entry)
// assert.NotNil(t, err)
// assert.Contains(t, err.Error(), "Field validation for 'Address' failed on the 'required' tag")
// })
2021-05-06 05:24:24 +08:00
t.Run("BadAddress", func(t *testing.T) {
change := models.DNSEntry{Address: "10.0.256.1", Name: "myhost", Network: "skynet"}
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSUpdate(change, entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Address' failed on the 'ip' tag")
})
t.Run("EmptyName", func(t *testing.T) {
// this can't actually happen as change.Name is populated if is blank
change := models.DNSEntry{Address: "10.0.0.2", Network: "skynet"}
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSUpdate(change, entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'required' tag")
})
t.Run("NameTooLong", func(t *testing.T) {
name := ""
2021-09-10 04:20:21 +08:00
for i := 1; i < 194; i++ {
2021-05-06 05:24:24 +08:00
name = name + "a"
}
change := models.DNSEntry{Address: "10.0.0.2", Name: name, Network: "skynet"}
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSUpdate(change, entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'max' tag")
})
t.Run("NameUnique", func(t *testing.T) {
change := models.DNSEntry{Address: "10.0.0.2", Name: "myhost", Network: "wirecat"}
2023-01-21 06:38:32 +08:00
_, _ = logic.CreateDNS(entry)
_, _ = logic.CreateDNS(change)
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSUpdate(change, entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'name_unique' tag")
// cleanup
2021-12-08 01:46:55 +08:00
err = logic.DeleteDNS("myhost", "wirecat")
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
2021-05-06 05:24:24 +08:00
})
}
func TestValidateDNSCreate(t *testing.T) {
2021-12-08 01:46:55 +08:00
_ = logic.DeleteDNS("mynode", "skynet")
2021-05-06 05:24:24 +08:00
t.Run("NoNetwork", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.0.2", Name: "myhost", Network: "badnet"}
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSCreate(entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Network' failed on the 'network_exists' tag")
})
2022-04-26 04:48:36 +08:00
// t.Run("EmptyAddress", func(t *testing.T) {
// entry := models.DNSEntry{"", "", "myhost", "skynet"}
// err := logic.ValidateDNSCreate(entry)
// assert.NotNil(t, err)
// assert.Contains(t, err.Error(), "Field validation for 'Address' failed on the 'required' tag")
// })
2021-05-06 05:24:24 +08:00
t.Run("BadAddress", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.256.1", Name: "myhost", Network: "skynet"}
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSCreate(entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Address' failed on the 'ip' tag")
})
t.Run("EmptyName", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.0.2", Network: "skynet"}
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSCreate(entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'required' tag")
})
t.Run("NameTooLong", func(t *testing.T) {
name := ""
2021-09-10 04:20:21 +08:00
for i := 1; i < 194; i++ {
2021-05-06 05:24:24 +08:00
name = name + "a"
}
entry := models.DNSEntry{Address: "10.0.0.2", Name: name, Network: "skynet"}
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSCreate(entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'max' tag")
})
t.Run("NameUnique", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.0.0.2", Name: "myhost", Network: "skynet"}
2023-01-21 06:38:32 +08:00
_, _ = logic.CreateDNS(entry)
2021-12-08 01:46:55 +08:00
err := logic.ValidateDNSCreate(entry)
2021-05-06 05:24:24 +08:00
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'name_unique' tag")
})
t.Run("WhiteSpace", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.10.10.5", Name: "white space", Network: "skynet"}
err := logic.ValidateDNSCreate(entry)
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'whitespace' tag")
})
t.Run("AllSpaces", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.10.10.5", Name: " ", Network: "skynet"}
err := logic.ValidateDNSCreate(entry)
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'whitespace' tag")
})
2021-05-06 05:24:24 +08:00
}
2021-09-10 04:20:21 +08:00
2023-01-21 06:38:32 +08:00
func createHost() {
k, _ := wgtypes.ParseKey("DM5qhLAE20PG9BbfBCger+Ac9D2NDOwCtY1rbYDLf34=")
dnsHost = models.Host{
ID: uuid.New(),
PublicKey: k.PublicKey(),
HostPass: "password",
OS: "linux",
Name: "dnshost",
}
_ = logic.CreateHost(&dnsHost)
}
2021-09-10 04:20:21 +08:00
func deleteAllDNS(t *testing.T) {
2021-12-08 01:46:55 +08:00
dns, err := logic.GetAllDNS()
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
2021-09-10 04:20:21 +08:00
for _, record := range dns {
2021-12-08 01:46:55 +08:00
err := logic.DeleteDNS(record.Name, record.Network)
2021-10-17 23:47:25 +08:00
assert.Nil(t, err)
2021-09-10 04:20:21 +08:00
}
}