diff --git a/.github/workflows/check-license-dependencies.yml b/.github/workflows/check-license-dependencies.yml
index c5cd22483..d1d2a8e50 100644
--- a/.github/workflows/check-license-dependencies.yml
+++ b/.github/workflows/check-license-dependencies.yml
@@ -39,7 +39,7 @@ jobs:
else
echo "✓ No problematic dependencies found"
fi
- done < <(find . -maxdepth 1 -type d -not -name "." -not -name "management" -not -name "signal" -not -name "relay" -not -name "proxy" -not -name ".git*" | sort)
+ done < <(find . -maxdepth 1 -type d -not -name "." -not -name "management" -not -name "signal" -not -name "relay" -not -name "proxy" -not -name "combined" -not -name ".git*" | sort)
echo ""
if [ $FOUND_ISSUES -eq 1 ]; then
@@ -88,7 +88,7 @@ jobs:
IMPORTERS=$(go list -json -deps ./... 2>/dev/null | jq -r "select(.Imports[]? == \"$package\") | .ImportPath")
# Check if any importer is NOT in management/signal/relay
- BSD_IMPORTER=$(echo "$IMPORTERS" | grep -v "github.com/netbirdio/netbird/\(management\|signal\|relay\|proxy\)" | head -1)
+ BSD_IMPORTER=$(echo "$IMPORTERS" | grep -v "github.com/netbirdio/netbird/\(management\|signal\|relay\|proxy\|combined\)" | head -1)
if [ -n "$BSD_IMPORTER" ]; then
echo "❌ $package ($license) is imported by BSD-licensed code: $BSD_IMPORTER"
diff --git a/.github/workflows/golang-test-darwin.yml b/.github/workflows/golang-test-darwin.yml
index 13af8e871..0528ed086 100644
--- a/.github/workflows/golang-test-darwin.yml
+++ b/.github/workflows/golang-test-darwin.yml
@@ -43,5 +43,5 @@ jobs:
run: git --no-pager diff --exit-code
- name: Test
- run: NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true go test -tags=devcert -exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' -timeout 5m -p 1 $(go list ./... | grep -v -e /management -e /signal -e /relay -e /proxy)
+ run: NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true go test -tags=devcert -exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' -timeout 5m -p 1 $(go list ./... | grep -v -e /management -e /signal -e /relay -e /proxy -e /combined)
diff --git a/.github/workflows/golang-test-linux.yml b/.github/workflows/golang-test-linux.yml
index f1d9f77ac..3c4674fc6 100644
--- a/.github/workflows/golang-test-linux.yml
+++ b/.github/workflows/golang-test-linux.yml
@@ -97,6 +97,16 @@ jobs:
working-directory: relay
run: CGO_ENABLED=1 GOARCH=386 go build -o relay-386 .
+ - name: Build combined
+ if: steps.cache.outputs.cache-hit != 'true'
+ working-directory: combined
+ run: CGO_ENABLED=1 go build .
+
+ - name: Build combined 386
+ if: steps.cache.outputs.cache-hit != 'true'
+ working-directory: combined
+ run: CGO_ENABLED=1 GOARCH=386 go build -o combined-386 .
+
test:
name: "Client / Unit"
needs: [build-cache]
@@ -144,7 +154,7 @@ jobs:
run: git --no-pager diff --exit-code
- name: Test
- run: CGO_ENABLED=1 GOARCH=${{ matrix.arch }} CI=true go test -tags devcert -exec 'sudo' -timeout 10m -p 1 $(go list ./... | grep -v -e /management -e /signal -e /relay -e /proxy)
+ run: CGO_ENABLED=1 GOARCH=${{ matrix.arch }} CI=true go test -tags devcert -exec 'sudo' -timeout 10m -p 1 $(go list ./... | grep -v -e /management -e /signal -e /relay -e /proxy -e /combined)
test_client_on_docker:
name: "Client (Docker) / Unit"
@@ -204,7 +214,7 @@ jobs:
sh -c ' \
apk update; apk add --no-cache \
ca-certificates iptables ip6tables dbus dbus-dev libpcap-dev build-base; \
- go test -buildvcs=false -tags devcert -v -timeout 10m -p 1 $(go list -buildvcs=false ./... | grep -v -e /management -e /signal -e /relay -e /proxy -e /client/ui -e /upload-server)
+ go test -buildvcs=false -tags devcert -v -timeout 10m -p 1 $(go list -buildvcs=false ./... | grep -v -e /management -e /signal -e /relay -e /proxy -e /combined -e /client/ui -e /upload-server)
'
test_relay:
diff --git a/.github/workflows/golang-test-windows.yml b/.github/workflows/golang-test-windows.yml
index 0e9493900..8af4046a7 100644
--- a/.github/workflows/golang-test-windows.yml
+++ b/.github/workflows/golang-test-windows.yml
@@ -63,7 +63,7 @@ jobs:
- run: PsExec64 -s -w ${{ github.workspace }} C:\hostedtoolcache\windows\go\${{ steps.go.outputs.go-version }}\x64\bin\go.exe env -w GOMODCACHE=${{ env.cache }}
- run: PsExec64 -s -w ${{ github.workspace }} C:\hostedtoolcache\windows\go\${{ steps.go.outputs.go-version }}\x64\bin\go.exe env -w GOCACHE=${{ env.modcache }}
- run: PsExec64 -s -w ${{ github.workspace }} C:\hostedtoolcache\windows\go\${{ steps.go.outputs.go-version }}\x64\bin\go.exe mod tidy
- - run: echo "files=$(go list ./... | ForEach-Object { $_ } | Where-Object { $_ -notmatch '/management' } | Where-Object { $_ -notmatch '/relay' } | Where-Object { $_ -notmatch '/signal' } | Where-Object { $_ -notmatch '/proxy' })" >> $env:GITHUB_ENV
+ - run: echo "files=$(go list ./... | ForEach-Object { $_ } | Where-Object { $_ -notmatch '/management' } | Where-Object { $_ -notmatch '/relay' } | Where-Object { $_ -notmatch '/signal' } | Where-Object { $_ -notmatch '/proxy' } | Where-Object { $_ -notmatch '/combined' })" >> $env:GITHUB_ENV
- name: test
run: PsExec64 -s -w ${{ github.workspace }} cmd.exe /c "C:\hostedtoolcache\windows\go\${{ steps.go.outputs.go-version }}\x64\bin\go.exe test -tags=devcert -timeout 10m -p 1 ${{ env.files }} > test-out.txt 2>&1"
diff --git a/LICENSE b/LICENSE
index 594691464..d922f155a 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-This BSD‑3‑Clause license applies to all parts of the repository except for the directories management/, signal/ and relay/.
+This BSD‑3‑Clause license applies to all parts of the repository except for the directories management/, signal/, relay/ and combined/.
Those directories are licensed under the GNU Affero General Public License version 3.0 (AGPLv3). See the respective LICENSE files inside each directory.
BSD 3-Clause License
diff --git a/combined/LICENSE b/combined/LICENSE
new file mode 100644
index 000000000..be3f7b28e
--- /dev/null
+++ b/combined/LICENSE
@@ -0,0 +1,661 @@
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU Affero General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+.
diff --git a/combined/cmd/root.go b/combined/cmd/root.go
index 8837fea44..0ec0e9480 100644
--- a/combined/cmd/root.go
+++ b/combined/cmd/root.go
@@ -62,6 +62,8 @@ Configuration is loaded from a YAML file specified with --config.`,
func init() {
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "path to YAML configuration file (required)")
_ = rootCmd.MarkPersistentFlagRequired("config")
+
+ rootCmd.AddCommand(newTokenCommands())
}
func Execute() error {
diff --git a/combined/cmd/token.go b/combined/cmd/token.go
new file mode 100644
index 000000000..9393c6c46
--- /dev/null
+++ b/combined/cmd/token.go
@@ -0,0 +1,60 @@
+package cmd
+
+import (
+ "context"
+ "fmt"
+ "os"
+ "strings"
+
+ log "github.com/sirupsen/logrus"
+ "github.com/spf13/cobra"
+
+ "github.com/netbirdio/netbird/formatter/hook"
+ tokencmd "github.com/netbirdio/netbird/management/cmd/token"
+ "github.com/netbirdio/netbird/management/server/store"
+ "github.com/netbirdio/netbird/management/server/types"
+ "github.com/netbirdio/netbird/util"
+)
+
+// newTokenCommands creates the token command tree with combined-specific store opener.
+func newTokenCommands() *cobra.Command {
+ return tokencmd.NewCommands(withTokenStore)
+}
+
+// withTokenStore loads the combined YAML config, initializes the store, and calls fn.
+func withTokenStore(cmd *cobra.Command, fn func(ctx context.Context, s store.Store) error) error {
+ if err := util.InitLog("error", "console"); err != nil {
+ return fmt.Errorf("init log: %w", err)
+ }
+
+ ctx := context.WithValue(cmd.Context(), hook.ExecutionContextKey, hook.SystemSource) //nolint:staticcheck
+
+ cfg, err := LoadConfig(configPath)
+ if err != nil {
+ return fmt.Errorf("load config: %w", err)
+ }
+
+ if dsn := cfg.Server.Store.DSN; dsn != "" {
+ switch strings.ToLower(cfg.Server.Store.Engine) {
+ case "postgres":
+ os.Setenv("NB_STORE_ENGINE_POSTGRES_DSN", dsn)
+ case "mysql":
+ os.Setenv("NB_STORE_ENGINE_MYSQL_DSN", dsn)
+ }
+ }
+
+ datadir := cfg.Management.DataDir
+ engine := types.Engine(cfg.Management.Store.Engine)
+
+ s, err := store.NewStore(ctx, engine, datadir, nil, true)
+ if err != nil {
+ return fmt.Errorf("create store: %w", err)
+ }
+ defer func() {
+ if err := s.Close(ctx); err != nil {
+ log.Debugf("close store: %v", err)
+ }
+ }()
+
+ return fn(ctx, s)
+}
diff --git a/management/cmd/root.go b/management/cmd/root.go
index 2eca7859d..3cb2bceb6 100644
--- a/management/cmd/root.go
+++ b/management/cmd/root.go
@@ -81,9 +81,7 @@ func init() {
rootCmd.AddCommand(migrationCmd)
- tokenCmd.PersistentFlags().StringVar(&nbconfig.MgmtConfigPath, "config", defaultMgmtConfig, "Netbird config file location")
- tokenCmd.AddCommand(tokenCreateCmd)
- tokenCmd.AddCommand(tokenListCmd)
- tokenCmd.AddCommand(tokenRevokeCmd)
- rootCmd.AddCommand(tokenCmd)
+ tc := newTokenCommands()
+ tc.PersistentFlags().StringVar(&nbconfig.MgmtConfigPath, "config", defaultMgmtConfig, "Netbird config file location")
+ rootCmd.AddCommand(tc)
}
diff --git a/management/cmd/token.go b/management/cmd/token.go
index f0e0d9945..67af1a5f5 100644
--- a/management/cmd/token.go
+++ b/management/cmd/token.go
@@ -3,62 +3,24 @@ package cmd
import (
"context"
"fmt"
- "os"
- "strconv"
- "text/tabwriter"
- "time"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/netbirdio/netbird/formatter/hook"
+ tokencmd "github.com/netbirdio/netbird/management/cmd/token"
nbconfig "github.com/netbirdio/netbird/management/internals/server/config"
"github.com/netbirdio/netbird/management/server/store"
- "github.com/netbirdio/netbird/management/server/types"
"github.com/netbirdio/netbird/util"
)
-var (
- tokenName string
- tokenExpireIn string
- tokenDatadir string
+var tokenDatadir string
- tokenCmd = &cobra.Command{
- Use: "token",
- Short: "Manage proxy access tokens",
- Long: "Commands for creating, listing, and revoking proxy access tokens used by reverse proxy instances to authenticate with the management server.",
- }
-
- tokenCreateCmd = &cobra.Command{
- Use: "create",
- Short: "Create a new proxy access token",
- Long: "Creates a new proxy access token. The plain text token is displayed only once at creation time.",
- RunE: tokenCreateRun,
- }
-
- tokenListCmd = &cobra.Command{
- Use: "list",
- Aliases: []string{"ls"},
- Short: "List all proxy access tokens",
- Long: "Lists all proxy access tokens with their IDs, names, creation dates, expiration, and revocation status.",
- RunE: tokenListRun,
- }
-
- tokenRevokeCmd = &cobra.Command{
- Use: "revoke [token-id]",
- Short: "Revoke a proxy access token",
- Long: "Revokes a proxy access token by its ID. Revoked tokens can no longer be used for authentication.",
- Args: cobra.ExactArgs(1),
- RunE: tokenRevokeRun,
- }
-)
-
-func init() {
- tokenCmd.PersistentFlags().StringVar(&tokenDatadir, "datadir", "", "Override the data directory from config (where store.db is located)")
-
- tokenCreateCmd.Flags().StringVar(&tokenName, "name", "", "Name for the token (required)")
- tokenCreateCmd.Flags().StringVar(&tokenExpireIn, "expires-in", "", "Token expiration duration (e.g., 365d, 24h, 30d). Empty means no expiration")
- tokenCreateCmd.MarkFlagRequired("name") //nolint
+// newTokenCommands creates the token command tree with management-specific store opener.
+func newTokenCommands() *cobra.Command {
+ cmd := tokencmd.NewCommands(withTokenStore)
+ cmd.PersistentFlags().StringVar(&tokenDatadir, "datadir", "", "Override the data directory from config (where store.db is located)")
+ return cmd
}
// withTokenStore initializes logging, loads config, opens the store, and calls fn.
@@ -67,8 +29,7 @@ func withTokenStore(cmd *cobra.Command, fn func(ctx context.Context, s store.Sto
return fmt.Errorf("init log: %w", err)
}
- //nolint
- ctx := context.WithValue(cmd.Context(), hook.ExecutionContextKey, hook.SystemSource)
+ ctx := context.WithValue(cmd.Context(), hook.ExecutionContextKey, hook.SystemSource) //nolint:staticcheck
config, err := LoadMgmtConfig(ctx, nbconfig.MgmtConfigPath)
if err != nil {
@@ -92,118 +53,3 @@ func withTokenStore(cmd *cobra.Command, fn func(ctx context.Context, s store.Sto
return fn(ctx, s)
}
-
-func tokenCreateRun(cmd *cobra.Command, _ []string) error {
- return withTokenStore(cmd, func(ctx context.Context, s store.Store) error {
- expiresIn, err := parseDuration(tokenExpireIn)
- if err != nil {
- return fmt.Errorf("parse expiration: %w", err)
- }
-
- generated, err := types.CreateNewProxyAccessToken(tokenName, expiresIn, nil, "CLI")
- if err != nil {
- return fmt.Errorf("generate token: %w", err)
- }
-
- if err := s.SaveProxyAccessToken(ctx, &generated.ProxyAccessToken); err != nil {
- return fmt.Errorf("save token: %w", err)
- }
-
- fmt.Println("Token created successfully!") //nolint:forbidigo
- fmt.Printf("Token: %s\n", generated.PlainToken) //nolint:forbidigo
- fmt.Println() //nolint:forbidigo
- fmt.Println("IMPORTANT: Save this token now. It will not be shown again.") //nolint:forbidigo
- fmt.Printf("Token ID: %s\n", generated.ID) //nolint:forbidigo
-
- return nil
- })
-}
-
-func tokenListRun(cmd *cobra.Command, _ []string) error {
- return withTokenStore(cmd, func(ctx context.Context, s store.Store) error {
- tokens, err := s.GetAllProxyAccessTokens(ctx, store.LockingStrengthNone)
- if err != nil {
- return fmt.Errorf("list tokens: %w", err)
- }
-
- if len(tokens) == 0 {
- fmt.Println("No proxy access tokens found.") //nolint:forbidigo
- return nil
- }
-
- w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
- fmt.Fprintln(w, "ID\tNAME\tCREATED\tEXPIRES\tLAST USED\tREVOKED")
- fmt.Fprintln(w, "--\t----\t-------\t-------\t---------\t-------")
-
- for _, t := range tokens {
- expires := "never"
- if t.ExpiresAt != nil {
- expires = t.ExpiresAt.Format("2006-01-02")
- }
-
- lastUsed := "never"
- if t.LastUsed != nil {
- lastUsed = t.LastUsed.Format("2006-01-02 15:04")
- }
-
- revoked := "no"
- if t.Revoked {
- revoked = "yes"
- }
-
- fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\n",
- t.ID,
- t.Name,
- t.CreatedAt.Format("2006-01-02"),
- expires,
- lastUsed,
- revoked,
- )
- }
-
- w.Flush()
-
- return nil
- })
-}
-
-func tokenRevokeRun(cmd *cobra.Command, args []string) error {
- return withTokenStore(cmd, func(ctx context.Context, s store.Store) error {
- tokenID := args[0]
-
- if err := s.RevokeProxyAccessToken(ctx, tokenID); err != nil {
- return fmt.Errorf("revoke token: %w", err)
- }
-
- fmt.Printf("Token %s revoked successfully.\n", tokenID) //nolint:forbidigo
- return nil
- })
-}
-
-// parseDuration parses a duration string with support for days (e.g., "30d", "365d").
-// An empty string returns zero duration (no expiration).
-func parseDuration(s string) (time.Duration, error) {
- if len(s) == 0 {
- return 0, nil
- }
-
- if s[len(s)-1] == 'd' {
- d, err := strconv.Atoi(s[:len(s)-1])
- if err != nil {
- return 0, fmt.Errorf("invalid day format: %s", s)
- }
- if d <= 0 {
- return 0, fmt.Errorf("duration must be positive: %s", s)
- }
- return time.Duration(d) * 24 * time.Hour, nil
- }
-
- d, err := time.ParseDuration(s)
- if err != nil {
- return 0, err
- }
- if d <= 0 {
- return 0, fmt.Errorf("duration must be positive: %s", s)
- }
- return d, nil
-}
diff --git a/management/cmd/token/token.go b/management/cmd/token/token.go
new file mode 100644
index 000000000..fb89e732c
--- /dev/null
+++ b/management/cmd/token/token.go
@@ -0,0 +1,185 @@
+// Package tokencmd provides reusable cobra commands for managing proxy access tokens.
+// Both the management and combined binaries use these commands, each providing
+// their own StoreOpener to handle config loading and store initialization.
+package tokencmd
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "strconv"
+ "text/tabwriter"
+ "time"
+
+ "github.com/spf13/cobra"
+
+ "github.com/netbirdio/netbird/management/server/store"
+ "github.com/netbirdio/netbird/management/server/types"
+)
+
+// StoreOpener initializes a store from the command context and calls fn.
+type StoreOpener func(cmd *cobra.Command, fn func(ctx context.Context, s store.Store) error) error
+
+// NewCommands creates the token command tree with the given store opener.
+// Returns the parent "token" command with create, list, and revoke subcommands.
+func NewCommands(opener StoreOpener) *cobra.Command {
+ var (
+ tokenName string
+ tokenExpireIn string
+ )
+
+ tokenCmd := &cobra.Command{
+ Use: "token",
+ Short: "Manage proxy access tokens",
+ Long: "Commands for creating, listing, and revoking proxy access tokens used by reverse proxy instances to authenticate with the management server.",
+ }
+
+ createCmd := &cobra.Command{
+ Use: "create",
+ Short: "Create a new proxy access token",
+ Long: "Creates a new proxy access token. The plain text token is displayed only once at creation time.",
+ RunE: func(cmd *cobra.Command, _ []string) error {
+ return opener(cmd, func(ctx context.Context, s store.Store) error {
+ return runCreate(ctx, s, cmd.OutOrStdout(), tokenName, tokenExpireIn)
+ })
+ },
+ }
+ createCmd.Flags().StringVar(&tokenName, "name", "", "Name for the token (required)")
+ createCmd.Flags().StringVar(&tokenExpireIn, "expires-in", "", "Token expiration duration (e.g., 365d, 24h, 30d). Empty means no expiration")
+ if err := createCmd.MarkFlagRequired("name"); err != nil {
+ panic(err)
+ }
+
+ listCmd := &cobra.Command{
+ Use: "list",
+ Aliases: []string{"ls"},
+ Short: "List all proxy access tokens",
+ Long: "Lists all proxy access tokens with their IDs, names, creation dates, expiration, and revocation status.",
+ RunE: func(cmd *cobra.Command, _ []string) error {
+ return opener(cmd, func(ctx context.Context, s store.Store) error {
+ return runList(ctx, s, cmd.OutOrStdout())
+ })
+ },
+ }
+
+ revokeCmd := &cobra.Command{
+ Use: "revoke [token-id]",
+ Short: "Revoke a proxy access token",
+ Long: "Revokes a proxy access token by its ID. Revoked tokens can no longer be used for authentication.",
+ Args: cobra.ExactArgs(1),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return opener(cmd, func(ctx context.Context, s store.Store) error {
+ return runRevoke(ctx, s, cmd.OutOrStdout(), args[0])
+ })
+ },
+ }
+
+ tokenCmd.AddCommand(createCmd, listCmd, revokeCmd)
+ return tokenCmd
+}
+
+func runCreate(ctx context.Context, s store.Store, w io.Writer, name string, expireIn string) error {
+ expiresIn, err := ParseDuration(expireIn)
+ if err != nil {
+ return fmt.Errorf("parse expiration: %w", err)
+ }
+
+ generated, err := types.CreateNewProxyAccessToken(name, expiresIn, nil, "CLI")
+ if err != nil {
+ return fmt.Errorf("generate token: %w", err)
+ }
+
+ if err := s.SaveProxyAccessToken(ctx, &generated.ProxyAccessToken); err != nil {
+ return fmt.Errorf("save token: %w", err)
+ }
+
+ _, _ = fmt.Fprintln(w, "Token created successfully!")
+ _, _ = fmt.Fprintf(w, "Token: %s\n", generated.PlainToken)
+ _, _ = fmt.Fprintln(w)
+ _, _ = fmt.Fprintln(w, "IMPORTANT: Save this token now. It will not be shown again.")
+ _, _ = fmt.Fprintf(w, "Token ID: %s\n", generated.ID)
+ return nil
+}
+
+func runList(ctx context.Context, s store.Store, out io.Writer) error {
+ tokens, err := s.GetAllProxyAccessTokens(ctx, store.LockingStrengthNone)
+ if err != nil {
+ return fmt.Errorf("list tokens: %w", err)
+ }
+
+ if len(tokens) == 0 {
+ _, _ = fmt.Fprintln(out, "No proxy access tokens found.")
+ return nil
+ }
+
+ w := tabwriter.NewWriter(out, 0, 0, 2, ' ', 0)
+ _, _ = fmt.Fprintln(w, "ID\tNAME\tCREATED\tEXPIRES\tLAST USED\tREVOKED")
+ _, _ = fmt.Fprintln(w, "--\t----\t-------\t-------\t---------\t-------")
+
+ for _, t := range tokens {
+ expires := "never"
+ if t.ExpiresAt != nil {
+ expires = t.ExpiresAt.Format("2006-01-02")
+ }
+
+ lastUsed := "never"
+ if t.LastUsed != nil {
+ lastUsed = t.LastUsed.Format("2006-01-02 15:04")
+ }
+
+ revoked := "no"
+ if t.Revoked {
+ revoked = "yes"
+ }
+
+ _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\n",
+ t.ID,
+ t.Name,
+ t.CreatedAt.Format("2006-01-02"),
+ expires,
+ lastUsed,
+ revoked,
+ )
+ }
+
+ w.Flush()
+
+ return nil
+}
+
+func runRevoke(ctx context.Context, s store.Store, w io.Writer, tokenID string) error {
+ if err := s.RevokeProxyAccessToken(ctx, tokenID); err != nil {
+ return fmt.Errorf("revoke token: %w", err)
+ }
+
+ _, _ = fmt.Fprintf(w, "Token %s revoked successfully.\n", tokenID)
+ return nil
+}
+
+// ParseDuration parses a duration string with support for days (e.g., "30d", "365d").
+// An empty string returns zero duration (no expiration).
+func ParseDuration(s string) (time.Duration, error) {
+ if len(s) == 0 {
+ return 0, nil
+ }
+
+ if s[len(s)-1] == 'd' {
+ d, err := strconv.Atoi(s[:len(s)-1])
+ if err != nil {
+ return 0, fmt.Errorf("invalid day format: %s", s)
+ }
+ if d <= 0 {
+ return 0, fmt.Errorf("duration must be positive: %s", s)
+ }
+ return time.Duration(d) * 24 * time.Hour, nil
+ }
+
+ d, err := time.ParseDuration(s)
+ if err != nil {
+ return 0, err
+ }
+ if d <= 0 {
+ return 0, fmt.Errorf("duration must be positive: %s", s)
+ }
+ return d, nil
+}
diff --git a/management/cmd/token_test.go b/management/cmd/token/token_test.go
similarity index 96%
rename from management/cmd/token_test.go
rename to management/cmd/token/token_test.go
index 35ac0895e..d554bbe45 100644
--- a/management/cmd/token_test.go
+++ b/management/cmd/token/token_test.go
@@ -1,4 +1,4 @@
-package cmd
+package tokencmd
import (
"testing"
@@ -89,7 +89,7 @@ func TestParseDuration(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- result, err := parseDuration(tt.input)
+ result, err := ParseDuration(tt.input)
if tt.wantErr {
assert.Error(t, err)
return
diff --git a/management/internals/modules/reverseproxy/accesslogs/filter.go b/management/internals/modules/reverseproxy/accesslogs/filter.go
index 17edc4b1c..f4b0a2048 100644
--- a/management/internals/modules/reverseproxy/accesslogs/filter.go
+++ b/management/internals/modules/reverseproxy/accesslogs/filter.go
@@ -39,78 +39,63 @@ type AccessLogFilter struct {
func (f *AccessLogFilter) ParseFromRequest(r *http.Request) {
queryParams := r.URL.Query()
- f.Page = 1
- if pageStr := queryParams.Get("page"); pageStr != "" {
- if page, err := strconv.Atoi(pageStr); err == nil && page > 0 {
- f.Page = page
- }
- }
+ f.Page = parsePositiveInt(queryParams.Get("page"), 1)
+ f.PageSize = min(parsePositiveInt(queryParams.Get("page_size"), DefaultPageSize), MaxPageSize)
- f.PageSize = DefaultPageSize
- if pageSizeStr := queryParams.Get("page_size"); pageSizeStr != "" {
- if pageSize, err := strconv.Atoi(pageSizeStr); err == nil && pageSize > 0 {
- f.PageSize = pageSize
- if f.PageSize > MaxPageSize {
- f.PageSize = MaxPageSize
- }
- }
- }
+ f.Search = parseOptionalString(queryParams.Get("search"))
+ f.SourceIP = parseOptionalString(queryParams.Get("source_ip"))
+ f.Host = parseOptionalString(queryParams.Get("host"))
+ f.Path = parseOptionalString(queryParams.Get("path"))
+ f.UserID = parseOptionalString(queryParams.Get("user_id"))
+ f.UserEmail = parseOptionalString(queryParams.Get("user_email"))
+ f.UserName = parseOptionalString(queryParams.Get("user_name"))
+ f.Method = parseOptionalString(queryParams.Get("method"))
+ f.Status = parseOptionalString(queryParams.Get("status"))
+ f.StatusCode = parseOptionalInt(queryParams.Get("status_code"))
+ f.StartDate = parseOptionalRFC3339(queryParams.Get("start_date"))
+ f.EndDate = parseOptionalRFC3339(queryParams.Get("end_date"))
+}
- if search := queryParams.Get("search"); search != "" {
- f.Search = &search
+// parsePositiveInt parses a positive integer from a string, returning defaultValue if invalid
+func parsePositiveInt(s string, defaultValue int) int {
+ if s == "" {
+ return defaultValue
}
+ if val, err := strconv.Atoi(s); err == nil && val > 0 {
+ return val
+ }
+ return defaultValue
+}
- if sourceIP := queryParams.Get("source_ip"); sourceIP != "" {
- f.SourceIP = &sourceIP
+// parseOptionalString returns a pointer to the string if non-empty, otherwise nil
+func parseOptionalString(s string) *string {
+ if s == "" {
+ return nil
}
+ return &s
+}
- if host := queryParams.Get("host"); host != "" {
- f.Host = &host
+// parseOptionalInt parses an optional positive integer from a string
+func parseOptionalInt(s string) *int {
+ if s == "" {
+ return nil
}
+ if val, err := strconv.Atoi(s); err == nil && val > 0 {
+ v := val
+ return &v
+ }
+ return nil
+}
- if path := queryParams.Get("path"); path != "" {
- f.Path = &path
+// parseOptionalRFC3339 parses an optional RFC3339 timestamp from a string
+func parseOptionalRFC3339(s string) *time.Time {
+ if s == "" {
+ return nil
}
-
- if userID := queryParams.Get("user_id"); userID != "" {
- f.UserID = &userID
- }
-
- if userEmail := queryParams.Get("user_email"); userEmail != "" {
- f.UserEmail = &userEmail
- }
-
- if userName := queryParams.Get("user_name"); userName != "" {
- f.UserName = &userName
- }
-
- if method := queryParams.Get("method"); method != "" {
- f.Method = &method
- }
-
- if status := queryParams.Get("status"); status != "" {
- f.Status = &status
- }
-
- if statusCodeStr := queryParams.Get("status_code"); statusCodeStr != "" {
- if statusCode, err := strconv.Atoi(statusCodeStr); err == nil && statusCode > 0 {
- f.StatusCode = &statusCode
- }
- }
-
- if startDate := queryParams.Get("start_date"); startDate != "" {
- parsedStartDate, err := time.Parse(time.RFC3339, startDate)
- if err == nil {
- f.StartDate = &parsedStartDate
- }
- }
-
- if endDate := queryParams.Get("end_date"); endDate != "" {
- parsedEndDate, err := time.Parse(time.RFC3339, endDate)
- if err == nil {
- f.EndDate = &parsedEndDate
- }
+ if t, err := time.Parse(time.RFC3339, s); err == nil {
+ return &t
}
+ return nil
}
// GetOffset calculates the database offset for pagination
diff --git a/management/internals/modules/reverseproxy/accesslogs/filter_test.go b/management/internals/modules/reverseproxy/accesslogs/filter_test.go
index 4ca4508bc..5d48ea9d2 100644
--- a/management/internals/modules/reverseproxy/accesslogs/filter_test.go
+++ b/management/internals/modules/reverseproxy/accesslogs/filter_test.go
@@ -4,8 +4,10 @@ import (
"net/http"
"net/http/httptest"
"testing"
+ "time"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
func TestAccessLogFilter_ParseFromRequest(t *testing.T) {
@@ -159,3 +161,211 @@ func TestAccessLogFilter_GetLimit(t *testing.T) {
limit := filter.GetLimit()
assert.Equal(t, 25, limit, "GetLimit should return PageSize")
}
+
+func TestAccessLogFilter_ParseFromRequest_FilterParams(t *testing.T) {
+ startDate := "2024-01-15T10:30:00Z"
+ endDate := "2024-01-16T15:45:00Z"
+
+ req := httptest.NewRequest(http.MethodGet, "/test", nil)
+ q := req.URL.Query()
+ q.Set("search", "test query")
+ q.Set("source_ip", "192.168.1.1")
+ q.Set("host", "example.com")
+ q.Set("path", "/api/users")
+ q.Set("user_id", "user123")
+ q.Set("user_email", "user@example.com")
+ q.Set("user_name", "John Doe")
+ q.Set("method", "GET")
+ q.Set("status", "success")
+ q.Set("status_code", "200")
+ q.Set("start_date", startDate)
+ q.Set("end_date", endDate)
+ req.URL.RawQuery = q.Encode()
+
+ filter := &AccessLogFilter{}
+ filter.ParseFromRequest(req)
+
+ require.NotNil(t, filter.Search)
+ assert.Equal(t, "test query", *filter.Search)
+
+ require.NotNil(t, filter.SourceIP)
+ assert.Equal(t, "192.168.1.1", *filter.SourceIP)
+
+ require.NotNil(t, filter.Host)
+ assert.Equal(t, "example.com", *filter.Host)
+
+ require.NotNil(t, filter.Path)
+ assert.Equal(t, "/api/users", *filter.Path)
+
+ require.NotNil(t, filter.UserID)
+ assert.Equal(t, "user123", *filter.UserID)
+
+ require.NotNil(t, filter.UserEmail)
+ assert.Equal(t, "user@example.com", *filter.UserEmail)
+
+ require.NotNil(t, filter.UserName)
+ assert.Equal(t, "John Doe", *filter.UserName)
+
+ require.NotNil(t, filter.Method)
+ assert.Equal(t, "GET", *filter.Method)
+
+ require.NotNil(t, filter.Status)
+ assert.Equal(t, "success", *filter.Status)
+
+ require.NotNil(t, filter.StatusCode)
+ assert.Equal(t, 200, *filter.StatusCode)
+
+ require.NotNil(t, filter.StartDate)
+ expectedStart, _ := time.Parse(time.RFC3339, startDate)
+ assert.Equal(t, expectedStart, *filter.StartDate)
+
+ require.NotNil(t, filter.EndDate)
+ expectedEnd, _ := time.Parse(time.RFC3339, endDate)
+ assert.Equal(t, expectedEnd, *filter.EndDate)
+}
+
+func TestAccessLogFilter_ParseFromRequest_EmptyFilters(t *testing.T) {
+ req := httptest.NewRequest(http.MethodGet, "/test", nil)
+
+ filter := &AccessLogFilter{}
+ filter.ParseFromRequest(req)
+
+ assert.Nil(t, filter.Search)
+ assert.Nil(t, filter.SourceIP)
+ assert.Nil(t, filter.Host)
+ assert.Nil(t, filter.Path)
+ assert.Nil(t, filter.UserID)
+ assert.Nil(t, filter.UserEmail)
+ assert.Nil(t, filter.UserName)
+ assert.Nil(t, filter.Method)
+ assert.Nil(t, filter.Status)
+ assert.Nil(t, filter.StatusCode)
+ assert.Nil(t, filter.StartDate)
+ assert.Nil(t, filter.EndDate)
+}
+
+func TestAccessLogFilter_ParseFromRequest_InvalidFilters(t *testing.T) {
+ req := httptest.NewRequest(http.MethodGet, "/test", nil)
+ q := req.URL.Query()
+ q.Set("status_code", "invalid")
+ q.Set("start_date", "not-a-date")
+ q.Set("end_date", "2024-99-99")
+ req.URL.RawQuery = q.Encode()
+
+ filter := &AccessLogFilter{}
+ filter.ParseFromRequest(req)
+
+ assert.Nil(t, filter.StatusCode, "invalid status_code should be nil")
+ assert.Nil(t, filter.StartDate, "invalid start_date should be nil")
+ assert.Nil(t, filter.EndDate, "invalid end_date should be nil")
+}
+
+func TestParsePositiveInt(t *testing.T) {
+ tests := []struct {
+ name string
+ input string
+ defaultValue int
+ expected int
+ }{
+ {"empty string", "", 10, 10},
+ {"valid positive int", "25", 10, 25},
+ {"zero", "0", 10, 10},
+ {"negative", "-5", 10, 10},
+ {"invalid string", "abc", 10, 10},
+ {"float", "3.14", 10, 10},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ result := parsePositiveInt(tt.input, tt.defaultValue)
+ assert.Equal(t, tt.expected, result)
+ })
+ }
+}
+
+func TestParseOptionalString(t *testing.T) {
+ tests := []struct {
+ name string
+ input string
+ expected *string
+ }{
+ {"empty string", "", nil},
+ {"valid string", "hello", strPtr("hello")},
+ {"whitespace", " ", strPtr(" ")},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ result := parseOptionalString(tt.input)
+ if tt.expected == nil {
+ assert.Nil(t, result)
+ } else {
+ require.NotNil(t, result)
+ assert.Equal(t, *tt.expected, *result)
+ }
+ })
+ }
+}
+
+func TestParseOptionalInt(t *testing.T) {
+ tests := []struct {
+ name string
+ input string
+ expected *int
+ }{
+ {"empty string", "", nil},
+ {"valid positive int", "42", intPtr(42)},
+ {"zero", "0", nil},
+ {"negative", "-10", nil},
+ {"invalid string", "abc", nil},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ result := parseOptionalInt(tt.input)
+ if tt.expected == nil {
+ assert.Nil(t, result)
+ } else {
+ require.NotNil(t, result)
+ assert.Equal(t, *tt.expected, *result)
+ }
+ })
+ }
+}
+
+func TestParseOptionalRFC3339(t *testing.T) {
+ validDate := "2024-01-15T10:30:00Z"
+ expectedTime, _ := time.Parse(time.RFC3339, validDate)
+
+ tests := []struct {
+ name string
+ input string
+ expected *time.Time
+ }{
+ {"empty string", "", nil},
+ {"valid RFC3339", validDate, &expectedTime},
+ {"invalid format", "2024-01-15", nil},
+ {"invalid date", "not-a-date", nil},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ result := parseOptionalRFC3339(tt.input)
+ if tt.expected == nil {
+ assert.Nil(t, result)
+ } else {
+ require.NotNil(t, result)
+ assert.Equal(t, *tt.expected, *result)
+ }
+ })
+ }
+}
+
+// Helper functions for creating pointers
+func strPtr(s string) *string {
+ return &s
+}
+
+func intPtr(i int) *int {
+ return &i
+}
diff --git a/management/internals/modules/reverseproxy/manager/manager.go b/management/internals/modules/reverseproxy/manager/manager.go
index df0c8fea6..2a93fdff6 100644
--- a/management/internals/modules/reverseproxy/manager/manager.go
+++ b/management/internals/modules/reverseproxy/manager/manager.go
@@ -135,54 +135,11 @@ func (m *managerImpl) CreateService(ctx context.Context, accountID, userID strin
return nil, status.NewPermissionDeniedError()
}
- var proxyCluster string
- if m.clusterDeriver != nil {
- proxyCluster, err = m.clusterDeriver.DeriveClusterFromDomain(ctx, accountID, service.Domain)
- if err != nil {
- log.WithError(err).Warnf("could not derive cluster from domain %s, updates will broadcast to all proxy servers", service.Domain)
- return nil, status.Errorf(status.PreconditionFailed, "could not derive cluster from domain %s: %v", service.Domain, err)
- }
+ if err := m.initializeServiceForCreate(ctx, accountID, service); err != nil {
+ return nil, err
}
- service.AccountID = accountID
- service.ProxyCluster = proxyCluster
- service.InitNewRecord()
- err = service.Auth.HashSecrets()
- if err != nil {
- return nil, fmt.Errorf("hash secrets: %w", err)
- }
-
- // Generate session JWT signing keys
- keyPair, err := sessionkey.GenerateKeyPair()
- if err != nil {
- return nil, fmt.Errorf("generate session keys: %w", err)
- }
- service.SessionPrivateKey = keyPair.PrivateKey
- service.SessionPublicKey = keyPair.PublicKey
-
- err = m.store.ExecuteInTransaction(ctx, func(transaction store.Store) error {
- // Check for duplicate domain
- existingService, err := transaction.GetServiceByDomain(ctx, accountID, service.Domain)
- if err != nil {
- if sErr, ok := status.FromError(err); !ok || sErr.Type() != status.NotFound {
- return fmt.Errorf("failed to check existing service: %w", err)
- }
- }
- if existingService != nil {
- return status.Errorf(status.AlreadyExists, "service with domain %s already exists", service.Domain)
- }
-
- if err = validateTargetReferences(ctx, transaction, accountID, service.Targets); err != nil {
- return err
- }
-
- if err = transaction.CreateService(ctx, service); err != nil {
- return fmt.Errorf("failed to create service: %w", err)
- }
-
- return nil
- })
- if err != nil {
+ if err := m.persistNewService(ctx, accountID, service); err != nil {
return nil, err
}
@@ -200,6 +157,67 @@ func (m *managerImpl) CreateService(ctx context.Context, accountID, userID strin
return service, nil
}
+func (m *managerImpl) initializeServiceForCreate(ctx context.Context, accountID string, service *reverseproxy.Service) error {
+ if m.clusterDeriver != nil {
+ proxyCluster, err := m.clusterDeriver.DeriveClusterFromDomain(ctx, accountID, service.Domain)
+ if err != nil {
+ log.WithError(err).Warnf("could not derive cluster from domain %s, updates will broadcast to all proxy servers", service.Domain)
+ return status.Errorf(status.PreconditionFailed, "could not derive cluster from domain %s: %v", service.Domain, err)
+ }
+ service.ProxyCluster = proxyCluster
+ }
+
+ service.AccountID = accountID
+ service.InitNewRecord()
+
+ if err := service.Auth.HashSecrets(); err != nil {
+ return fmt.Errorf("hash secrets: %w", err)
+ }
+
+ keyPair, err := sessionkey.GenerateKeyPair()
+ if err != nil {
+ return fmt.Errorf("generate session keys: %w", err)
+ }
+ service.SessionPrivateKey = keyPair.PrivateKey
+ service.SessionPublicKey = keyPair.PublicKey
+
+ return nil
+}
+
+func (m *managerImpl) persistNewService(ctx context.Context, accountID string, service *reverseproxy.Service) error {
+ return m.store.ExecuteInTransaction(ctx, func(transaction store.Store) error {
+ if err := m.checkDomainAvailable(ctx, transaction, accountID, service.Domain, ""); err != nil {
+ return err
+ }
+
+ if err := validateTargetReferences(ctx, transaction, accountID, service.Targets); err != nil {
+ return err
+ }
+
+ if err := transaction.CreateService(ctx, service); err != nil {
+ return fmt.Errorf("failed to create service: %w", err)
+ }
+
+ return nil
+ })
+}
+
+func (m *managerImpl) checkDomainAvailable(ctx context.Context, transaction store.Store, accountID, domain, excludeServiceID string) error {
+ existingService, err := transaction.GetServiceByDomain(ctx, accountID, domain)
+ if err != nil {
+ if sErr, ok := status.FromError(err); !ok || sErr.Type() != status.NotFound {
+ return fmt.Errorf("failed to check existing service: %w", err)
+ }
+ return nil
+ }
+
+ if existingService != nil && existingService.ID != excludeServiceID {
+ return status.Errorf(status.AlreadyExists, "service with domain %s already exists", domain)
+ }
+
+ return nil
+}
+
func (m *managerImpl) UpdateService(ctx context.Context, accountID, userID string, service *reverseproxy.Service) (*reverseproxy.Service, error) {
ok, err := m.permissionsManager.ValidateUserPermissions(ctx, accountID, userID, modules.Services, operations.Update)
if err != nil {
@@ -209,99 +227,122 @@ func (m *managerImpl) UpdateService(ctx context.Context, accountID, userID strin
return nil, status.NewPermissionDeniedError()
}
- var oldCluster string
- var domainChanged bool
- var serviceEnabledChanged bool
-
- err = service.Auth.HashSecrets()
- if err != nil {
+ if err := service.Auth.HashSecrets(); err != nil {
return nil, fmt.Errorf("hash secrets: %w", err)
}
- err = m.store.ExecuteInTransaction(ctx, func(transaction store.Store) error {
- existingService, err := transaction.GetServiceByID(ctx, store.LockingStrengthUpdate, accountID, service.ID)
- if err != nil {
- return err
- }
-
- oldCluster = existingService.ProxyCluster
-
- if existingService.Domain != service.Domain {
- domainChanged = true
- conflictService, err := transaction.GetServiceByDomain(ctx, accountID, service.Domain)
- if err != nil {
- if sErr, ok := status.FromError(err); !ok || sErr.Type() != status.NotFound {
- return fmt.Errorf("check existing service: %w", err)
- }
- }
- if conflictService != nil && conflictService.ID != service.ID {
- return status.Errorf(status.AlreadyExists, "service with domain %s already exists", service.Domain)
- }
-
- if m.clusterDeriver != nil {
- newCluster, err := m.clusterDeriver.DeriveClusterFromDomain(ctx, accountID, service.Domain)
- if err != nil {
- log.WithError(err).Warnf("could not derive cluster from domain %s", service.Domain)
- }
- service.ProxyCluster = newCluster
- }
- } else {
- service.ProxyCluster = existingService.ProxyCluster
- }
-
- if service.Auth.PasswordAuth != nil && service.Auth.PasswordAuth.Enabled &&
- existingService.Auth.PasswordAuth != nil && existingService.Auth.PasswordAuth.Enabled &&
- service.Auth.PasswordAuth.Password == "" {
- service.Auth.PasswordAuth = existingService.Auth.PasswordAuth
- }
-
- if service.Auth.PinAuth != nil && service.Auth.PinAuth.Enabled &&
- existingService.Auth.PinAuth != nil && existingService.Auth.PinAuth.Enabled &&
- service.Auth.PinAuth.Pin == "" {
- service.Auth.PinAuth = existingService.Auth.PinAuth
- }
-
- service.Meta = existingService.Meta
- service.SessionPrivateKey = existingService.SessionPrivateKey
- service.SessionPublicKey = existingService.SessionPublicKey
- serviceEnabledChanged = existingService.Enabled != service.Enabled
-
- if err = validateTargetReferences(ctx, transaction, accountID, service.Targets); err != nil {
- return err
- }
-
- if err = transaction.UpdateService(ctx, service); err != nil {
- return fmt.Errorf("update service: %w", err)
- }
-
- return nil
- })
+ updateInfo, err := m.persistServiceUpdate(ctx, accountID, service)
if err != nil {
return nil, err
}
m.accountManager.StoreEvent(ctx, userID, service.ID, accountID, activity.ServiceUpdated, service.EventMeta())
- err = m.replaceHostByLookup(ctx, accountID, service)
- if err != nil {
+ if err := m.replaceHostByLookup(ctx, accountID, service); err != nil {
return nil, fmt.Errorf("failed to replace host by lookup for service %s: %w", service.ID, err)
}
+ m.sendServiceUpdateNotifications(service, updateInfo)
+ m.accountManager.UpdateAccountPeers(ctx, accountID)
+
+ return service, nil
+}
+
+type serviceUpdateInfo struct {
+ oldCluster string
+ domainChanged bool
+ serviceEnabledChanged bool
+}
+
+func (m *managerImpl) persistServiceUpdate(ctx context.Context, accountID string, service *reverseproxy.Service) (*serviceUpdateInfo, error) {
+ var updateInfo serviceUpdateInfo
+
+ err := m.store.ExecuteInTransaction(ctx, func(transaction store.Store) error {
+ existingService, err := transaction.GetServiceByID(ctx, store.LockingStrengthUpdate, accountID, service.ID)
+ if err != nil {
+ return err
+ }
+
+ updateInfo.oldCluster = existingService.ProxyCluster
+ updateInfo.domainChanged = existingService.Domain != service.Domain
+
+ if updateInfo.domainChanged {
+ if err := m.handleDomainChange(ctx, transaction, accountID, service); err != nil {
+ return err
+ }
+ } else {
+ service.ProxyCluster = existingService.ProxyCluster
+ }
+
+ m.preserveExistingAuthSecrets(service, existingService)
+ m.preserveServiceMetadata(service, existingService)
+ updateInfo.serviceEnabledChanged = existingService.Enabled != service.Enabled
+
+ if err := validateTargetReferences(ctx, transaction, accountID, service.Targets); err != nil {
+ return err
+ }
+
+ if err := transaction.UpdateService(ctx, service); err != nil {
+ return fmt.Errorf("update service: %w", err)
+ }
+
+ return nil
+ })
+
+ return &updateInfo, err
+}
+
+func (m *managerImpl) handleDomainChange(ctx context.Context, transaction store.Store, accountID string, service *reverseproxy.Service) error {
+ if err := m.checkDomainAvailable(ctx, transaction, accountID, service.Domain, service.ID); err != nil {
+ return err
+ }
+
+ if m.clusterDeriver != nil {
+ newCluster, err := m.clusterDeriver.DeriveClusterFromDomain(ctx, accountID, service.Domain)
+ if err != nil {
+ log.WithError(err).Warnf("could not derive cluster from domain %s", service.Domain)
+ } else {
+ service.ProxyCluster = newCluster
+ }
+ }
+
+ return nil
+}
+
+func (m *managerImpl) preserveExistingAuthSecrets(service, existingService *reverseproxy.Service) {
+ if service.Auth.PasswordAuth != nil && service.Auth.PasswordAuth.Enabled &&
+ existingService.Auth.PasswordAuth != nil && existingService.Auth.PasswordAuth.Enabled &&
+ service.Auth.PasswordAuth.Password == "" {
+ service.Auth.PasswordAuth = existingService.Auth.PasswordAuth
+ }
+
+ if service.Auth.PinAuth != nil && service.Auth.PinAuth.Enabled &&
+ existingService.Auth.PinAuth != nil && existingService.Auth.PinAuth.Enabled &&
+ service.Auth.PinAuth.Pin == "" {
+ service.Auth.PinAuth = existingService.Auth.PinAuth
+ }
+}
+
+func (m *managerImpl) preserveServiceMetadata(service, existingService *reverseproxy.Service) {
+ service.Meta = existingService.Meta
+ service.SessionPrivateKey = existingService.SessionPrivateKey
+ service.SessionPublicKey = existingService.SessionPublicKey
+}
+
+func (m *managerImpl) sendServiceUpdateNotifications(service *reverseproxy.Service, updateInfo *serviceUpdateInfo) {
oidcCfg := m.proxyGRPCServer.GetOIDCValidationConfig()
+
switch {
- case domainChanged && oldCluster != service.ProxyCluster:
- m.proxyGRPCServer.SendServiceUpdateToCluster(service.ToProtoMapping(reverseproxy.Delete, "", oidcCfg), oldCluster)
+ case updateInfo.domainChanged && updateInfo.oldCluster != service.ProxyCluster:
+ m.proxyGRPCServer.SendServiceUpdateToCluster(service.ToProtoMapping(reverseproxy.Delete, "", oidcCfg), updateInfo.oldCluster)
m.proxyGRPCServer.SendServiceUpdateToCluster(service.ToProtoMapping(reverseproxy.Create, "", oidcCfg), service.ProxyCluster)
- case !service.Enabled && serviceEnabledChanged:
+ case !service.Enabled && updateInfo.serviceEnabledChanged:
m.proxyGRPCServer.SendServiceUpdateToCluster(service.ToProtoMapping(reverseproxy.Delete, "", oidcCfg), service.ProxyCluster)
- case service.Enabled && serviceEnabledChanged:
+ case service.Enabled && updateInfo.serviceEnabledChanged:
m.proxyGRPCServer.SendServiceUpdateToCluster(service.ToProtoMapping(reverseproxy.Create, "", oidcCfg), service.ProxyCluster)
default:
m.proxyGRPCServer.SendServiceUpdateToCluster(service.ToProtoMapping(reverseproxy.Update, "", oidcCfg), service.ProxyCluster)
}
- m.accountManager.UpdateAccountPeers(ctx, accountID)
-
- return service, nil
}
// validateTargetReferences checks that all target IDs reference existing peers or resources in the account.
diff --git a/management/internals/modules/reverseproxy/manager/manager_test.go b/management/internals/modules/reverseproxy/manager/manager_test.go
new file mode 100644
index 000000000..266b0066f
--- /dev/null
+++ b/management/internals/modules/reverseproxy/manager/manager_test.go
@@ -0,0 +1,375 @@
+package manager
+
+import (
+ "context"
+ "errors"
+ "testing"
+ "time"
+
+ "github.com/golang/mock/gomock"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+
+ "github.com/netbirdio/netbird/management/internals/modules/reverseproxy"
+ "github.com/netbirdio/netbird/management/server/store"
+ "github.com/netbirdio/netbird/shared/management/status"
+)
+
+func TestInitializeServiceForCreate(t *testing.T) {
+ ctx := context.Background()
+ accountID := "test-account"
+
+ t.Run("successful initialization without cluster deriver", func(t *testing.T) {
+ mgr := &managerImpl{
+ clusterDeriver: nil,
+ }
+
+ service := &reverseproxy.Service{
+ Domain: "example.com",
+ Auth: reverseproxy.AuthConfig{},
+ }
+
+ err := mgr.initializeServiceForCreate(ctx, accountID, service)
+
+ assert.NoError(t, err)
+ assert.Equal(t, accountID, service.AccountID)
+ assert.Empty(t, service.ProxyCluster, "proxy cluster should be empty when no deriver")
+ assert.NotEmpty(t, service.ID, "service ID should be initialized")
+ assert.NotEmpty(t, service.SessionPrivateKey, "session private key should be generated")
+ assert.NotEmpty(t, service.SessionPublicKey, "session public key should be generated")
+ })
+
+ t.Run("verifies session keys are different", func(t *testing.T) {
+ mgr := &managerImpl{
+ clusterDeriver: nil,
+ }
+
+ service1 := &reverseproxy.Service{Domain: "test1.com", Auth: reverseproxy.AuthConfig{}}
+ service2 := &reverseproxy.Service{Domain: "test2.com", Auth: reverseproxy.AuthConfig{}}
+
+ err1 := mgr.initializeServiceForCreate(ctx, accountID, service1)
+ err2 := mgr.initializeServiceForCreate(ctx, accountID, service2)
+
+ assert.NoError(t, err1)
+ assert.NoError(t, err2)
+ assert.NotEqual(t, service1.SessionPrivateKey, service2.SessionPrivateKey, "private keys should be unique")
+ assert.NotEqual(t, service1.SessionPublicKey, service2.SessionPublicKey, "public keys should be unique")
+ })
+}
+
+func TestCheckDomainAvailable(t *testing.T) {
+ ctx := context.Background()
+ accountID := "test-account"
+
+ tests := []struct {
+ name string
+ domain string
+ excludeServiceID string
+ setupMock func(*store.MockStore)
+ expectedError bool
+ errorType status.Type
+ }{
+ {
+ name: "domain available - not found",
+ domain: "available.com",
+ excludeServiceID: "",
+ setupMock: func(ms *store.MockStore) {
+ ms.EXPECT().
+ GetServiceByDomain(ctx, accountID, "available.com").
+ Return(nil, status.Errorf(status.NotFound, "not found"))
+ },
+ expectedError: false,
+ },
+ {
+ name: "domain already exists",
+ domain: "exists.com",
+ excludeServiceID: "",
+ setupMock: func(ms *store.MockStore) {
+ ms.EXPECT().
+ GetServiceByDomain(ctx, accountID, "exists.com").
+ Return(&reverseproxy.Service{ID: "existing-id", Domain: "exists.com"}, nil)
+ },
+ expectedError: true,
+ errorType: status.AlreadyExists,
+ },
+ {
+ name: "domain exists but excluded (same ID)",
+ domain: "exists.com",
+ excludeServiceID: "service-123",
+ setupMock: func(ms *store.MockStore) {
+ ms.EXPECT().
+ GetServiceByDomain(ctx, accountID, "exists.com").
+ Return(&reverseproxy.Service{ID: "service-123", Domain: "exists.com"}, nil)
+ },
+ expectedError: false,
+ },
+ {
+ name: "domain exists with different ID",
+ domain: "exists.com",
+ excludeServiceID: "service-456",
+ setupMock: func(ms *store.MockStore) {
+ ms.EXPECT().
+ GetServiceByDomain(ctx, accountID, "exists.com").
+ Return(&reverseproxy.Service{ID: "service-123", Domain: "exists.com"}, nil)
+ },
+ expectedError: true,
+ errorType: status.AlreadyExists,
+ },
+ {
+ name: "store error (non-NotFound)",
+ domain: "error.com",
+ excludeServiceID: "",
+ setupMock: func(ms *store.MockStore) {
+ ms.EXPECT().
+ GetServiceByDomain(ctx, accountID, "error.com").
+ Return(nil, errors.New("database error"))
+ },
+ expectedError: true,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ ctrl := gomock.NewController(t)
+ defer ctrl.Finish()
+
+ mockStore := store.NewMockStore(ctrl)
+ tt.setupMock(mockStore)
+
+ mgr := &managerImpl{}
+ err := mgr.checkDomainAvailable(ctx, mockStore, accountID, tt.domain, tt.excludeServiceID)
+
+ if tt.expectedError {
+ require.Error(t, err)
+ if tt.errorType != 0 {
+ sErr, ok := status.FromError(err)
+ require.True(t, ok, "error should be a status error")
+ assert.Equal(t, tt.errorType, sErr.Type())
+ }
+ } else {
+ assert.NoError(t, err)
+ }
+ })
+ }
+}
+
+func TestCheckDomainAvailable_EdgeCases(t *testing.T) {
+ ctx := context.Background()
+ accountID := "test-account"
+
+ t.Run("empty domain", func(t *testing.T) {
+ ctrl := gomock.NewController(t)
+ defer ctrl.Finish()
+
+ mockStore := store.NewMockStore(ctrl)
+ mockStore.EXPECT().
+ GetServiceByDomain(ctx, accountID, "").
+ Return(nil, status.Errorf(status.NotFound, "not found"))
+
+ mgr := &managerImpl{}
+ err := mgr.checkDomainAvailable(ctx, mockStore, accountID, "", "")
+
+ assert.NoError(t, err)
+ })
+
+ t.Run("empty exclude ID with existing service", func(t *testing.T) {
+ ctrl := gomock.NewController(t)
+ defer ctrl.Finish()
+
+ mockStore := store.NewMockStore(ctrl)
+ mockStore.EXPECT().
+ GetServiceByDomain(ctx, accountID, "test.com").
+ Return(&reverseproxy.Service{ID: "some-id", Domain: "test.com"}, nil)
+
+ mgr := &managerImpl{}
+ err := mgr.checkDomainAvailable(ctx, mockStore, accountID, "test.com", "")
+
+ assert.Error(t, err)
+ sErr, ok := status.FromError(err)
+ require.True(t, ok)
+ assert.Equal(t, status.AlreadyExists, sErr.Type())
+ })
+
+ t.Run("nil existing service with nil error", func(t *testing.T) {
+ ctrl := gomock.NewController(t)
+ defer ctrl.Finish()
+
+ mockStore := store.NewMockStore(ctrl)
+ mockStore.EXPECT().
+ GetServiceByDomain(ctx, accountID, "nil.com").
+ Return(nil, nil)
+
+ mgr := &managerImpl{}
+ err := mgr.checkDomainAvailable(ctx, mockStore, accountID, "nil.com", "")
+
+ assert.NoError(t, err)
+ })
+}
+
+func TestPersistNewService(t *testing.T) {
+ ctx := context.Background()
+ accountID := "test-account"
+
+ t.Run("successful service creation with no targets", func(t *testing.T) {
+ ctrl := gomock.NewController(t)
+ defer ctrl.Finish()
+
+ mockStore := store.NewMockStore(ctrl)
+ service := &reverseproxy.Service{
+ ID: "service-123",
+ Domain: "new.com",
+ Targets: []*reverseproxy.Target{},
+ }
+
+ // Mock ExecuteInTransaction to execute the function immediately
+ mockStore.EXPECT().
+ ExecuteInTransaction(ctx, gomock.Any()).
+ DoAndReturn(func(ctx context.Context, fn func(store.Store) error) error {
+ // Create another mock for the transaction
+ txMock := store.NewMockStore(ctrl)
+ txMock.EXPECT().
+ GetServiceByDomain(ctx, accountID, "new.com").
+ Return(nil, status.Errorf(status.NotFound, "not found"))
+ txMock.EXPECT().
+ CreateService(ctx, service).
+ Return(nil)
+
+ return fn(txMock)
+ })
+
+ mgr := &managerImpl{store: mockStore}
+ err := mgr.persistNewService(ctx, accountID, service)
+
+ assert.NoError(t, err)
+ })
+
+ t.Run("domain already exists", func(t *testing.T) {
+ ctrl := gomock.NewController(t)
+ defer ctrl.Finish()
+
+ mockStore := store.NewMockStore(ctrl)
+ service := &reverseproxy.Service{
+ ID: "service-123",
+ Domain: "existing.com",
+ Targets: []*reverseproxy.Target{},
+ }
+
+ mockStore.EXPECT().
+ ExecuteInTransaction(ctx, gomock.Any()).
+ DoAndReturn(func(ctx context.Context, fn func(store.Store) error) error {
+ txMock := store.NewMockStore(ctrl)
+ txMock.EXPECT().
+ GetServiceByDomain(ctx, accountID, "existing.com").
+ Return(&reverseproxy.Service{ID: "other-id", Domain: "existing.com"}, nil)
+
+ return fn(txMock)
+ })
+
+ mgr := &managerImpl{store: mockStore}
+ err := mgr.persistNewService(ctx, accountID, service)
+
+ require.Error(t, err)
+ sErr, ok := status.FromError(err)
+ require.True(t, ok)
+ assert.Equal(t, status.AlreadyExists, sErr.Type())
+ })
+}
+func TestPreserveExistingAuthSecrets(t *testing.T) {
+ mgr := &managerImpl{}
+
+ t.Run("preserve password when empty", func(t *testing.T) {
+ existing := &reverseproxy.Service{
+ Auth: reverseproxy.AuthConfig{
+ PasswordAuth: &reverseproxy.PasswordAuthConfig{
+ Enabled: true,
+ Password: "hashed-password",
+ },
+ },
+ }
+
+ updated := &reverseproxy.Service{
+ Auth: reverseproxy.AuthConfig{
+ PasswordAuth: &reverseproxy.PasswordAuthConfig{
+ Enabled: true,
+ Password: "",
+ },
+ },
+ }
+
+ mgr.preserveExistingAuthSecrets(updated, existing)
+
+ assert.Equal(t, existing.Auth.PasswordAuth, updated.Auth.PasswordAuth)
+ })
+
+ t.Run("preserve pin when empty", func(t *testing.T) {
+ existing := &reverseproxy.Service{
+ Auth: reverseproxy.AuthConfig{
+ PinAuth: &reverseproxy.PINAuthConfig{
+ Enabled: true,
+ Pin: "hashed-pin",
+ },
+ },
+ }
+
+ updated := &reverseproxy.Service{
+ Auth: reverseproxy.AuthConfig{
+ PinAuth: &reverseproxy.PINAuthConfig{
+ Enabled: true,
+ Pin: "",
+ },
+ },
+ }
+
+ mgr.preserveExistingAuthSecrets(updated, existing)
+
+ assert.Equal(t, existing.Auth.PinAuth, updated.Auth.PinAuth)
+ })
+
+ t.Run("do not preserve when password is provided", func(t *testing.T) {
+ existing := &reverseproxy.Service{
+ Auth: reverseproxy.AuthConfig{
+ PasswordAuth: &reverseproxy.PasswordAuthConfig{
+ Enabled: true,
+ Password: "old-password",
+ },
+ },
+ }
+
+ updated := &reverseproxy.Service{
+ Auth: reverseproxy.AuthConfig{
+ PasswordAuth: &reverseproxy.PasswordAuthConfig{
+ Enabled: true,
+ Password: "new-password",
+ },
+ },
+ }
+
+ mgr.preserveExistingAuthSecrets(updated, existing)
+
+ assert.Equal(t, "new-password", updated.Auth.PasswordAuth.Password)
+ assert.NotEqual(t, existing.Auth.PasswordAuth, updated.Auth.PasswordAuth)
+ })
+}
+
+func TestPreserveServiceMetadata(t *testing.T) {
+ mgr := &managerImpl{}
+
+ existing := &reverseproxy.Service{
+ Meta: reverseproxy.ServiceMeta{
+ CertificateIssuedAt: time.Now(),
+ Status: "active",
+ },
+ SessionPrivateKey: "private-key",
+ SessionPublicKey: "public-key",
+ }
+
+ updated := &reverseproxy.Service{
+ Domain: "updated.com",
+ }
+
+ mgr.preserveServiceMetadata(updated, existing)
+
+ assert.Equal(t, existing.Meta, updated.Meta)
+ assert.Equal(t, existing.SessionPrivateKey, updated.SessionPrivateKey)
+ assert.Equal(t, existing.SessionPublicKey, updated.SessionPublicKey)
+}
diff --git a/management/server/http/handlers/peers/peers_handler.go b/management/server/http/handlers/peers/peers_handler.go
index 613b81de0..6b9a69f04 100644
--- a/management/server/http/handlers/peers/peers_handler.go
+++ b/management/server/http/handlers/peers/peers_handler.go
@@ -18,6 +18,8 @@ import (
"github.com/netbirdio/netbird/management/server/groups"
nbpeer "github.com/netbirdio/netbird/management/server/peer"
"github.com/netbirdio/netbird/management/server/permissions"
+ "github.com/netbirdio/netbird/management/server/permissions/modules"
+ "github.com/netbirdio/netbird/management/server/permissions/operations"
"github.com/netbirdio/netbird/management/server/types"
"github.com/netbirdio/netbird/shared/management/http/api"
"github.com/netbirdio/netbird/shared/management/http/util"
@@ -376,9 +378,9 @@ func (h *Handler) GetAccessiblePeers(w http.ResponseWriter, r *http.Request) {
return
}
- err = h.permissionsManager.ValidateAccountAccess(r.Context(), accountID, user, false)
+ allowed, err := h.permissionsManager.ValidateUserPermissions(r.Context(), accountID, userID, modules.Peers, operations.Read)
if err != nil {
- util.WriteError(r.Context(), status.NewPermissionDeniedError(), w)
+ util.WriteError(r.Context(), status.NewPermissionValidationError(err), w)
return
}
@@ -388,9 +390,12 @@ func (h *Handler) GetAccessiblePeers(w http.ResponseWriter, r *http.Request) {
return
}
- // If the user is regular user and does not own the peer
- // with the given peerID return an empty list
- if !user.HasAdminPower() && !user.IsServiceUser && !userAuth.IsChild {
+ if !allowed && !userAuth.IsChild {
+ if account.Settings.RegularUsersViewBlocked {
+ util.WriteJSONObject(r.Context(), w, []api.AccessiblePeer{})
+ return
+ }
+
peer, ok := account.Peers[peerID]
if !ok {
util.WriteError(r.Context(), status.Errorf(status.NotFound, "peer not found"), w)
diff --git a/management/server/http/handlers/peers/peers_handler_test.go b/management/server/http/handlers/peers/peers_handler_test.go
index 786c144fc..6b3616597 100644
--- a/management/server/http/handlers/peers/peers_handler_test.go
+++ b/management/server/http/handlers/peers/peers_handler_test.go
@@ -22,6 +22,8 @@ import (
nbcontext "github.com/netbirdio/netbird/management/server/context"
nbpeer "github.com/netbirdio/netbird/management/server/peer"
"github.com/netbirdio/netbird/management/server/permissions"
+ "github.com/netbirdio/netbird/management/server/permissions/modules"
+ "github.com/netbirdio/netbird/management/server/permissions/operations"
"github.com/netbirdio/netbird/management/server/types"
"github.com/netbirdio/netbird/shared/auth"
"github.com/netbirdio/netbird/shared/management/http/api"
@@ -115,6 +117,16 @@ func initTestMetaData(t *testing.T, peers ...*nbpeer.Peer) *Handler {
ctrl2 := gomock.NewController(t)
permissionsManager := permissions.NewMockManager(ctrl2)
permissionsManager.EXPECT().ValidateAccountAccess(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
+ permissionsManager.EXPECT().
+ ValidateUserPermissions(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Eq(modules.Peers), gomock.Eq(operations.Read)).
+ DoAndReturn(func(ctx context.Context, accountID, userID string, module modules.Module, operation operations.Operation) (bool, error) {
+ user, ok := account.Users[userID]
+ if !ok {
+ return false, fmt.Errorf("user not found")
+ }
+ return user.HasAdminPower() || user.IsServiceUser, nil
+ }).
+ AnyTimes()
return &Handler{
accountManager: &mock_server.MockAccountManager{
@@ -383,12 +395,11 @@ func TestGetAccessiblePeers(t *testing.T) {
UserID: regularUser,
}
- p := initTestMetaData(t, peer1, peer2, peer3)
-
tt := []struct {
name string
peerID string
callerUserID string
+ viewBlocked bool
expectedStatus int
expectedPeers []string
}{
@@ -427,10 +438,56 @@ func TestGetAccessiblePeers(t *testing.T) {
expectedStatus: http.StatusOK,
expectedPeers: []string{"peer1", "peer2"},
},
+ {
+ name: "regular user gets empty for owned peer list when view blocked",
+ peerID: "peer1",
+ callerUserID: regularUser,
+ viewBlocked: true,
+ expectedStatus: http.StatusOK,
+ expectedPeers: []string{},
+ },
+ {
+ name: "regular user gets empty list for unowned peer when view blocked",
+ peerID: "peer2",
+ callerUserID: regularUser,
+ viewBlocked: true,
+ expectedStatus: http.StatusOK,
+ expectedPeers: []string{},
+ },
+ {
+ name: "admin user still sees accessible peers when view blocked",
+ peerID: "peer2",
+ callerUserID: adminUser,
+ viewBlocked: true,
+ expectedStatus: http.StatusOK,
+ expectedPeers: []string{"peer1", "peer3"},
+ },
+ {
+ name: "service user still sees accessible peers when view blocked",
+ peerID: "peer3",
+ callerUserID: serviceUser,
+ viewBlocked: true,
+ expectedStatus: http.StatusOK,
+ expectedPeers: []string{"peer1", "peer2"},
+ },
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
+ p := initTestMetaData(t, peer1, peer2, peer3)
+
+ if tc.viewBlocked {
+ mockAM := p.accountManager.(*mock_server.MockAccountManager)
+ originalGetAccountByIDFunc := mockAM.GetAccountByIDFunc
+ mockAM.GetAccountByIDFunc = func(ctx context.Context, accountID string, userID string) (*types.Account, error) {
+ account, err := originalGetAccountByIDFunc(ctx, accountID, userID)
+ if err != nil {
+ return nil, err
+ }
+ account.Settings.RegularUsersViewBlocked = true
+ return account, nil
+ }
+ }
recorder := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/api/peers/%s/accessible-peers", tc.peerID), nil)
diff --git a/management/server/peer.go b/management/server/peer.go
index 5101a5133..a2ca97208 100644
--- a/management/server/peer.go
+++ b/management/server/peer.go
@@ -561,6 +561,99 @@ func (am *DefaultAccountManager) GetPeerNetwork(ctx context.Context, peerID stri
return account.Network.Copy(), err
}
+type peerAddAuthConfig struct {
+ AccountID string
+ SetupKeyID string
+ SetupKeyName string
+ GroupsToAdd []string
+ AllowExtraDNSLabels bool
+ Ephemeral bool
+}
+
+func (am *DefaultAccountManager) processPeerAddAuth(ctx context.Context, accountID, userID, encodedHashedKey string, peer *nbpeer.Peer, temporary, addedByUser, addedBySetupKey bool, opEvent *activity.Event) (*peerAddAuthConfig, error) {
+ config := &peerAddAuthConfig{
+ AccountID: accountID,
+ Ephemeral: peer.Ephemeral,
+ }
+
+ switch {
+ case addedByUser:
+ if err := am.handleUserAddedPeer(ctx, accountID, userID, temporary, opEvent, config); err != nil {
+ return nil, err
+ }
+ case addedBySetupKey:
+ if err := am.handleSetupKeyAddedPeer(ctx, encodedHashedKey, peer, opEvent, config); err != nil {
+ return nil, err
+ }
+ default:
+ if peer.ProxyMeta.Embedded {
+ log.WithContext(ctx).Debugf("adding peer for proxy embedded, accountID: %s", accountID)
+ } else {
+ log.WithContext(ctx).Warnf("adding peer without setup key or userID, accountID: %s", accountID)
+ }
+ }
+
+ opEvent.AccountID = config.AccountID
+ if temporary {
+ config.Ephemeral = true
+ }
+
+ return config, nil
+}
+
+func (am *DefaultAccountManager) handleUserAddedPeer(ctx context.Context, accountID, userID string, temporary bool, opEvent *activity.Event, config *peerAddAuthConfig) error {
+ user, err := am.Store.GetUserByUserID(ctx, store.LockingStrengthNone, userID)
+ if err != nil {
+ return status.Errorf(status.NotFound, "failed adding new peer: user not found")
+ }
+ if user.PendingApproval {
+ return status.Errorf(status.PermissionDenied, "user pending approval cannot add peers")
+ }
+
+ if temporary {
+ allowed, err := am.permissionsManager.ValidateUserPermissions(ctx, accountID, userID, modules.Peers, operations.Create)
+ if err != nil {
+ return status.NewPermissionValidationError(err)
+ }
+ if !allowed {
+ return status.NewPermissionDeniedError()
+ }
+ } else {
+ config.AccountID = user.AccountID
+ config.GroupsToAdd = user.AutoGroups
+ }
+
+ opEvent.InitiatorID = userID
+ opEvent.Activity = activity.PeerAddedByUser
+ return nil
+}
+
+func (am *DefaultAccountManager) handleSetupKeyAddedPeer(ctx context.Context, encodedHashedKey string, peer *nbpeer.Peer, opEvent *activity.Event, config *peerAddAuthConfig) error {
+ sk, err := am.Store.GetSetupKeyBySecret(ctx, store.LockingStrengthNone, encodedHashedKey)
+ if err != nil {
+ return status.Errorf(status.NotFound, "couldn't add peer: setup key is invalid")
+ }
+
+ if !sk.IsValid() {
+ return status.Errorf(status.NotFound, "couldn't add peer: setup key is invalid")
+ }
+
+ if !sk.AllowExtraDNSLabels && len(peer.ExtraDNSLabels) > 0 {
+ return status.Errorf(status.PreconditionFailed, "couldn't add peer: setup key doesn't allow extra DNS labels")
+ }
+
+ opEvent.InitiatorID = sk.Id
+ opEvent.Activity = activity.PeerAddedWithSetupKey
+ config.GroupsToAdd = sk.AutoGroups
+ config.Ephemeral = sk.Ephemeral
+ config.SetupKeyID = sk.Id
+ config.SetupKeyName = sk.Name
+ config.AllowExtraDNSLabels = sk.AllowExtraDNSLabels
+ config.AccountID = sk.AccountID
+
+ return nil
+}
+
// AddPeer adds a new peer to the Store.
// Each Account has a list of pre-authorized SetupKey and if no Account has a given key err with a code status.PermissionDenied
// will be returned, meaning the setup key is invalid or not found.
@@ -596,70 +689,12 @@ func (am *DefaultAccountManager) AddPeer(ctx context.Context, accountID, setupKe
var newPeer *nbpeer.Peer
- var setupKeyID string
- var setupKeyName string
- var groupsToAdd []string
- var allowExtraDNSLabels bool
- ephemeral := peer.Ephemeral
- switch {
- case addedByUser:
- user, err := am.Store.GetUserByUserID(ctx, store.LockingStrengthNone, userID)
- if err != nil {
- return nil, nil, nil, status.Errorf(status.NotFound, "failed adding new peer: user not found")
- }
- if user.PendingApproval {
- return nil, nil, nil, status.Errorf(status.PermissionDenied, "user pending approval cannot add peers")
- }
- if temporary {
- allowed, err := am.permissionsManager.ValidateUserPermissions(ctx, accountID, userID, modules.Peers, operations.Create)
- if err != nil {
- return nil, nil, nil, status.NewPermissionValidationError(err)
- }
-
- if !allowed {
- return nil, nil, nil, status.NewPermissionDeniedError()
- }
- } else {
- accountID = user.AccountID
- groupsToAdd = user.AutoGroups
- }
- opEvent.InitiatorID = userID
- opEvent.Activity = activity.PeerAddedByUser
- case addedBySetupKey:
- // Validate the setup key
- sk, err := am.Store.GetSetupKeyBySecret(ctx, store.LockingStrengthNone, encodedHashedKey)
- if err != nil {
- return nil, nil, nil, status.Errorf(status.NotFound, "couldn't add peer: setup key is invalid")
- }
-
- // we will check key twice for early return
- if !sk.IsValid() {
- return nil, nil, nil, status.Errorf(status.NotFound, "couldn't add peer: setup key is invalid")
- }
-
- opEvent.InitiatorID = sk.Id
- opEvent.Activity = activity.PeerAddedWithSetupKey
- groupsToAdd = sk.AutoGroups
- ephemeral = sk.Ephemeral
- setupKeyID = sk.Id
- setupKeyName = sk.Name
- allowExtraDNSLabels = sk.AllowExtraDNSLabels
- accountID = sk.AccountID
- if !sk.AllowExtraDNSLabels && len(peer.ExtraDNSLabels) > 0 {
- return nil, nil, nil, status.Errorf(status.PreconditionFailed, "couldn't add peer: setup key doesn't allow extra DNS labels")
- }
- default:
- if peer.ProxyMeta.Embedded {
- log.WithContext(ctx).Debugf("adding peer for proxy embedded, accountID: %s", accountID)
- } else {
- log.WithContext(ctx).Warnf("adding peer without setup key or userID, accountID: %s", accountID)
- }
- }
- opEvent.AccountID = accountID
-
- if temporary {
- ephemeral = true
+ peerAddConfig, err := am.processPeerAddAuth(ctx, accountID, userID, encodedHashedKey, peer, temporary, addedByUser, addedBySetupKey, opEvent)
+ if err != nil {
+ return nil, nil, nil, err
}
+ accountID = peerAddConfig.AccountID
+ ephemeral := peerAddConfig.Ephemeral
if (strings.ToLower(peer.Meta.Hostname) == "iphone" || strings.ToLower(peer.Meta.Hostname) == "ipad") && userID != "" {
if am.idpManager != nil {
@@ -693,7 +728,7 @@ func (am *DefaultAccountManager) AddPeer(ctx context.Context, accountID, setupKe
Location: peer.Location,
InactivityExpirationEnabled: addedByUser && !temporary,
ExtraDNSLabels: peer.ExtraDNSLabels,
- AllowExtraDNSLabels: allowExtraDNSLabels,
+ AllowExtraDNSLabels: peerAddConfig.AllowExtraDNSLabels,
}
settings, err := am.Store.GetAccountSettings(ctx, store.LockingStrengthNone, accountID)
if err != nil {
@@ -711,7 +746,7 @@ func (am *DefaultAccountManager) AddPeer(ctx context.Context, accountID, setupKe
}
}
- newPeer = am.integratedPeerValidator.PreparePeer(ctx, accountID, newPeer, groupsToAdd, settings.Extra, temporary)
+ newPeer = am.integratedPeerValidator.PreparePeer(ctx, accountID, newPeer, peerAddConfig.GroupsToAdd, settings.Extra, temporary)
network, err := am.Store.GetAccountNetwork(ctx, store.LockingStrengthNone, accountID)
if err != nil {
@@ -747,8 +782,8 @@ func (am *DefaultAccountManager) AddPeer(ctx context.Context, accountID, setupKe
return err
}
- if len(groupsToAdd) > 0 {
- for _, g := range groupsToAdd {
+ if len(peerAddConfig.GroupsToAdd) > 0 {
+ for _, g := range peerAddConfig.GroupsToAdd {
err = transaction.AddPeerToGroup(ctx, newPeer.AccountID, newPeer.ID, g)
if err != nil {
return err
@@ -780,7 +815,7 @@ func (am *DefaultAccountManager) AddPeer(ctx context.Context, accountID, setupKe
return status.Errorf(status.PreconditionFailed, "couldn't add peer: setup key is invalid")
}
- err = transaction.IncrementSetupKeyUsage(ctx, setupKeyID)
+ err = transaction.IncrementSetupKeyUsage(ctx, peerAddConfig.SetupKeyID)
if err != nil {
return fmt.Errorf("failed to increment setup key usage: %w", err)
}
@@ -821,7 +856,7 @@ func (am *DefaultAccountManager) AddPeer(ctx context.Context, accountID, setupKe
opEvent.TargetID = newPeer.ID
opEvent.Meta = newPeer.EventMeta(am.networkMapController.GetDNSDomain(settings))
if !addedByUser {
- opEvent.Meta["setup_key_name"] = setupKeyName
+ opEvent.Meta["setup_key_name"] = peerAddConfig.SetupKeyName
}
am.StoreEvent(ctx, opEvent.InitiatorID, opEvent.TargetID, opEvent.AccountID, opEvent.Activity, opEvent.Meta)
diff --git a/management/server/peer_test.go b/management/server/peer_test.go
index 3846a3e85..b17757ffd 100644
--- a/management/server/peer_test.go
+++ b/management/server/peer_test.go
@@ -2489,3 +2489,252 @@ func TestLoginPeer_ApprovedUserCanLogin(t *testing.T) {
_, _, _, err = manager.LoginPeer(context.Background(), login)
require.NoError(t, err, "Regular user should be able to login peers")
}
+
+func TestHandleUserAddedPeer(t *testing.T) {
+ manager, _, err := createManager(t)
+ require.NoError(t, err)
+
+ account := newAccountWithId(context.Background(), "test-account", "owner", "", "", "", false)
+ err = manager.Store.SaveAccount(context.Background(), account)
+ require.NoError(t, err)
+
+ t.Run("regular user can add peer", func(t *testing.T) {
+ regularUser := types.NewRegularUser("regular-user-1", "", "")
+ regularUser.AccountID = account.Id
+ regularUser.AutoGroups = []string{"group1", "group2"}
+ err = manager.Store.SaveUser(context.Background(), regularUser)
+ require.NoError(t, err)
+
+ opEvent := &activity.Event{}
+ config := &peerAddAuthConfig{}
+
+ err = manager.handleUserAddedPeer(context.Background(), account.Id, regularUser.Id, false, opEvent, config)
+ require.NoError(t, err)
+ assert.Equal(t, account.Id, config.AccountID)
+ assert.Equal(t, regularUser.AutoGroups, config.GroupsToAdd)
+ assert.Equal(t, regularUser.Id, opEvent.InitiatorID)
+ assert.Equal(t, activity.PeerAddedByUser, opEvent.Activity)
+ })
+
+ t.Run("pending approval user cannot add peer", func(t *testing.T) {
+ pendingUser := types.NewRegularUser("pending-user", "", "")
+ pendingUser.AccountID = account.Id
+ pendingUser.PendingApproval = true
+ err = manager.Store.SaveUser(context.Background(), pendingUser)
+ require.NoError(t, err)
+
+ opEvent := &activity.Event{}
+ config := &peerAddAuthConfig{}
+
+ err = manager.handleUserAddedPeer(context.Background(), account.Id, pendingUser.Id, false, opEvent, config)
+ require.Error(t, err)
+ assert.Contains(t, err.Error(), "user pending approval cannot add peers")
+ })
+
+ t.Run("user not found", func(t *testing.T) {
+ opEvent := &activity.Event{}
+ config := &peerAddAuthConfig{}
+
+ err = manager.handleUserAddedPeer(context.Background(), account.Id, "non-existent-user", false, opEvent, config)
+ require.Error(t, err)
+ assert.Contains(t, err.Error(), "user not found")
+ })
+
+ t.Run("temporary peer requires permissions", func(t *testing.T) {
+ regularUser := types.NewRegularUser("regular-user-2", "", "")
+ regularUser.AccountID = account.Id
+ err = manager.Store.SaveUser(context.Background(), regularUser)
+ require.NoError(t, err)
+
+ opEvent := &activity.Event{}
+ config := &peerAddAuthConfig{}
+
+ // Should fail because user doesn't have permissions for temporary peers
+ err = manager.handleUserAddedPeer(context.Background(), account.Id, regularUser.Id, true, opEvent, config)
+ require.Error(t, err)
+ })
+}
+
+func TestHandleSetupKeyAddedPeer(t *testing.T) {
+ manager, _, err := createManager(t)
+ require.NoError(t, err)
+
+ account := newAccountWithId(context.Background(), "test-account", "owner", "", "", "", false)
+ err = manager.Store.SaveAccount(context.Background(), account)
+ require.NoError(t, err)
+
+ // Create admin user for setup key creation
+ adminUser := types.NewAdminUser("admin-user")
+ adminUser.AccountID = account.Id
+ err = manager.Store.SaveUser(context.Background(), adminUser)
+ require.NoError(t, err)
+
+ t.Run("valid setup key", func(t *testing.T) {
+ setupKey, err := manager.CreateSetupKey(context.Background(), account.Id, "test-key", types.SetupKeyReusable, time.Hour, []string{}, 0, adminUser.Id, false, false)
+ require.NoError(t, err)
+
+ upperKey := strings.ToUpper(setupKey.Key)
+ hashedKey := sha256.Sum256([]byte(upperKey))
+ encodedHashedKey := b64.StdEncoding.EncodeToString(hashedKey[:])
+
+ opEvent := &activity.Event{}
+ config := &peerAddAuthConfig{}
+ peer := &nbpeer.Peer{ExtraDNSLabels: []string{}}
+
+ err = manager.handleSetupKeyAddedPeer(context.Background(), encodedHashedKey, peer, opEvent, config)
+ require.NoError(t, err)
+ assert.Equal(t, setupKey.Id, config.SetupKeyID)
+ assert.Equal(t, setupKey.Name, config.SetupKeyName)
+ assert.Equal(t, setupKey.AutoGroups, config.GroupsToAdd)
+ assert.Equal(t, setupKey.Ephemeral, config.Ephemeral)
+ assert.Equal(t, setupKey.Id, opEvent.InitiatorID)
+ assert.Equal(t, activity.PeerAddedWithSetupKey, opEvent.Activity)
+ })
+
+ t.Run("invalid setup key", func(t *testing.T) {
+ invalidKey := "invalid-key"
+ hashedKey := sha256.Sum256([]byte(invalidKey))
+ encodedHashedKey := b64.StdEncoding.EncodeToString(hashedKey[:])
+
+ opEvent := &activity.Event{}
+ config := &peerAddAuthConfig{}
+ peer := &nbpeer.Peer{}
+
+ err = manager.handleSetupKeyAddedPeer(context.Background(), encodedHashedKey, peer, opEvent, config)
+ require.Error(t, err)
+ assert.Contains(t, err.Error(), "setup key is invalid")
+ })
+
+ t.Run("expired setup key", func(t *testing.T) {
+ setupKey, err := manager.CreateSetupKey(context.Background(), account.Id, "expired-key", types.SetupKeyReusable, time.Millisecond, []string{}, 0, adminUser.Id, false, false)
+ require.NoError(t, err)
+
+ // Wait for key to expire
+ time.Sleep(10 * time.Millisecond)
+
+ upperKey := strings.ToUpper(setupKey.Key)
+ hashedKey := sha256.Sum256([]byte(upperKey))
+ encodedHashedKey := b64.StdEncoding.EncodeToString(hashedKey[:])
+
+ opEvent := &activity.Event{}
+ config := &peerAddAuthConfig{}
+ peer := &nbpeer.Peer{}
+
+ err = manager.handleSetupKeyAddedPeer(context.Background(), encodedHashedKey, peer, opEvent, config)
+ require.Error(t, err)
+ assert.Contains(t, err.Error(), "setup key is invalid")
+ })
+
+ t.Run("extra DNS labels not allowed", func(t *testing.T) {
+ setupKey, err := manager.CreateSetupKey(context.Background(), account.Id, "no-dns-key", types.SetupKeyReusable, time.Hour, []string{}, 0, adminUser.Id, false, false)
+ require.NoError(t, err)
+
+ upperKey := strings.ToUpper(setupKey.Key)
+ hashedKey := sha256.Sum256([]byte(upperKey))
+ encodedHashedKey := b64.StdEncoding.EncodeToString(hashedKey[:])
+
+ opEvent := &activity.Event{}
+ config := &peerAddAuthConfig{}
+ peer := &nbpeer.Peer{ExtraDNSLabels: []string{"custom.label"}}
+
+ err = manager.handleSetupKeyAddedPeer(context.Background(), encodedHashedKey, peer, opEvent, config)
+ require.Error(t, err)
+ assert.Contains(t, err.Error(), "doesn't allow extra DNS labels")
+ })
+
+ t.Run("extra DNS labels allowed", func(t *testing.T) {
+ setupKey, err := manager.CreateSetupKey(context.Background(), account.Id, "dns-key", types.SetupKeyReusable, time.Hour, []string{}, 0, adminUser.Id, false, true)
+ require.NoError(t, err)
+
+ upperKey := strings.ToUpper(setupKey.Key)
+ hashedKey := sha256.Sum256([]byte(upperKey))
+ encodedHashedKey := b64.StdEncoding.EncodeToString(hashedKey[:])
+
+ opEvent := &activity.Event{}
+ config := &peerAddAuthConfig{}
+ peer := &nbpeer.Peer{ExtraDNSLabels: []string{"custom.label"}}
+
+ err = manager.handleSetupKeyAddedPeer(context.Background(), encodedHashedKey, peer, opEvent, config)
+ require.NoError(t, err)
+ assert.True(t, config.AllowExtraDNSLabels)
+ })
+}
+
+func TestProcessPeerAddAuth(t *testing.T) {
+ manager, _, err := createManager(t)
+ require.NoError(t, err)
+
+ account := newAccountWithId(context.Background(), "test-account", "owner", "", "", "", false)
+ err = manager.Store.SaveAccount(context.Background(), account)
+ require.NoError(t, err)
+
+ adminUser := types.NewAdminUser("admin")
+ adminUser.AccountID = account.Id
+ err = manager.Store.SaveUser(context.Background(), adminUser)
+ require.NoError(t, err)
+
+ t.Run("user authentication flow", func(t *testing.T) {
+ regularUser := types.NewRegularUser("user-auth-test", "", "")
+ regularUser.AccountID = account.Id
+ regularUser.AutoGroups = []string{"group1"}
+ err = manager.Store.SaveUser(context.Background(), regularUser)
+ require.NoError(t, err)
+
+ opEvent := &activity.Event{Timestamp: time.Now()}
+ peer := &nbpeer.Peer{Ephemeral: false}
+
+ config, err := manager.processPeerAddAuth(context.Background(), account.Id, regularUser.Id, "", peer, false, true, false, opEvent)
+ require.NoError(t, err)
+ assert.Equal(t, account.Id, config.AccountID)
+ assert.False(t, config.Ephemeral)
+ assert.Equal(t, regularUser.AutoGroups, config.GroupsToAdd)
+ assert.Equal(t, account.Id, opEvent.AccountID)
+ })
+
+ t.Run("setup key authentication flow", func(t *testing.T) {
+ setupKey, err := manager.CreateSetupKey(context.Background(), account.Id, "auth-test-key", types.SetupKeyReusable, time.Hour, []string{}, 0, adminUser.Id, true, false)
+ require.NoError(t, err)
+
+ upperKey := strings.ToUpper(setupKey.Key)
+ hashedKey := sha256.Sum256([]byte(upperKey))
+ encodedHashedKey := b64.StdEncoding.EncodeToString(hashedKey[:])
+
+ opEvent := &activity.Event{Timestamp: time.Now()}
+ peer := &nbpeer.Peer{Ephemeral: false}
+
+ config, err := manager.processPeerAddAuth(context.Background(), account.Id, "", encodedHashedKey, peer, false, false, true, opEvent)
+ require.NoError(t, err)
+ assert.Equal(t, account.Id, config.AccountID)
+ assert.True(t, config.Ephemeral) // setupKey.Ephemeral is true
+ assert.Equal(t, setupKey.AutoGroups, config.GroupsToAdd)
+ assert.Equal(t, account.Id, opEvent.AccountID)
+ })
+
+ t.Run("temporary flag overrides ephemeral", func(t *testing.T) {
+ regularUser := types.NewRegularUser("temp-user", "", "")
+ regularUser.AccountID = account.Id
+ err = manager.Store.SaveUser(context.Background(), regularUser)
+ require.NoError(t, err)
+
+ opEvent := &activity.Event{Timestamp: time.Now()}
+ peer := &nbpeer.Peer{Ephemeral: false}
+
+ config, err := manager.processPeerAddAuth(context.Background(), account.Id, regularUser.Id, "", peer, true, true, false, opEvent)
+ require.Error(t, err) // Will fail permission check but that's expected
+ _ = config // avoid unused warning
+ })
+
+ t.Run("proxy embedded peer (no auth)", func(t *testing.T) {
+ opEvent := &activity.Event{Timestamp: time.Now()}
+ peer := &nbpeer.Peer{
+ Ephemeral: false,
+ ProxyMeta: nbpeer.ProxyMeta{Embedded: true},
+ }
+
+ config, err := manager.processPeerAddAuth(context.Background(), account.Id, "", "", peer, false, false, false, opEvent)
+ require.NoError(t, err)
+ assert.Equal(t, account.Id, config.AccountID)
+ assert.False(t, config.Ephemeral)
+ assert.Empty(t, config.GroupsToAdd)
+ })
+}
diff --git a/management/server/store/store.go b/management/server/store/store.go
index 6ade5c4f4..a8e44a438 100644
--- a/management/server/store/store.go
+++ b/management/server/store/store.go
@@ -1,5 +1,7 @@
package store
+//go:generate go run github.com/golang/mock/mockgen -package store -destination=store_mock.go -source=./store.go -build_flags=-mod=mod
+
import (
"context"
"errors"
diff --git a/management/server/store/store_mock.go b/management/server/store/store_mock.go
new file mode 100644
index 000000000..2f451dc43
--- /dev/null
+++ b/management/server/store/store_mock.go
@@ -0,0 +1,2745 @@
+// Code generated by MockGen. DO NOT EDIT.
+// Source: ./store.go
+
+// Package store is a generated GoMock package.
+package store
+
+import (
+ context "context"
+ net "net"
+ reflect "reflect"
+ time "time"
+
+ gomock "github.com/golang/mock/gomock"
+ dns "github.com/netbirdio/netbird/dns"
+ reverseproxy "github.com/netbirdio/netbird/management/internals/modules/reverseproxy"
+ accesslogs "github.com/netbirdio/netbird/management/internals/modules/reverseproxy/accesslogs"
+ domain "github.com/netbirdio/netbird/management/internals/modules/reverseproxy/domain"
+ zones "github.com/netbirdio/netbird/management/internals/modules/zones"
+ records "github.com/netbirdio/netbird/management/internals/modules/zones/records"
+ types "github.com/netbirdio/netbird/management/server/networks/resources/types"
+ types0 "github.com/netbirdio/netbird/management/server/networks/routers/types"
+ types1 "github.com/netbirdio/netbird/management/server/networks/types"
+ peer "github.com/netbirdio/netbird/management/server/peer"
+ posture "github.com/netbirdio/netbird/management/server/posture"
+ types2 "github.com/netbirdio/netbird/management/server/types"
+ route "github.com/netbirdio/netbird/route"
+ crypt "github.com/netbirdio/netbird/util/crypt"
+)
+
+// MockStore is a mock of Store interface.
+type MockStore struct {
+ ctrl *gomock.Controller
+ recorder *MockStoreMockRecorder
+}
+
+// MockStoreMockRecorder is the mock recorder for MockStore.
+type MockStoreMockRecorder struct {
+ mock *MockStore
+}
+
+// NewMockStore creates a new mock instance.
+func NewMockStore(ctrl *gomock.Controller) *MockStore {
+ mock := &MockStore{ctrl: ctrl}
+ mock.recorder = &MockStoreMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockStore) EXPECT() *MockStoreMockRecorder {
+ return m.recorder
+}
+
+// AccountExists mocks base method.
+func (m *MockStore) AccountExists(ctx context.Context, lockStrength LockingStrength, id string) (bool, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "AccountExists", ctx, lockStrength, id)
+ ret0, _ := ret[0].(bool)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// AccountExists indicates an expected call of AccountExists.
+func (mr *MockStoreMockRecorder) AccountExists(ctx, lockStrength, id interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AccountExists", reflect.TypeOf((*MockStore)(nil).AccountExists), ctx, lockStrength, id)
+}
+
+// AcquireGlobalLock mocks base method.
+func (m *MockStore) AcquireGlobalLock(ctx context.Context) func() {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "AcquireGlobalLock", ctx)
+ ret0, _ := ret[0].(func())
+ return ret0
+}
+
+// AcquireGlobalLock indicates an expected call of AcquireGlobalLock.
+func (mr *MockStoreMockRecorder) AcquireGlobalLock(ctx interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcquireGlobalLock", reflect.TypeOf((*MockStore)(nil).AcquireGlobalLock), ctx)
+}
+
+// AddPeerToAccount mocks base method.
+func (m *MockStore) AddPeerToAccount(ctx context.Context, peer *peer.Peer) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "AddPeerToAccount", ctx, peer)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// AddPeerToAccount indicates an expected call of AddPeerToAccount.
+func (mr *MockStoreMockRecorder) AddPeerToAccount(ctx, peer interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddPeerToAccount", reflect.TypeOf((*MockStore)(nil).AddPeerToAccount), ctx, peer)
+}
+
+// AddPeerToAllGroup mocks base method.
+func (m *MockStore) AddPeerToAllGroup(ctx context.Context, accountID, peerID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "AddPeerToAllGroup", ctx, accountID, peerID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// AddPeerToAllGroup indicates an expected call of AddPeerToAllGroup.
+func (mr *MockStoreMockRecorder) AddPeerToAllGroup(ctx, accountID, peerID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddPeerToAllGroup", reflect.TypeOf((*MockStore)(nil).AddPeerToAllGroup), ctx, accountID, peerID)
+}
+
+// AddPeerToGroup mocks base method.
+func (m *MockStore) AddPeerToGroup(ctx context.Context, accountID, peerId, groupID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "AddPeerToGroup", ctx, accountID, peerId, groupID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// AddPeerToGroup indicates an expected call of AddPeerToGroup.
+func (mr *MockStoreMockRecorder) AddPeerToGroup(ctx, accountID, peerId, groupID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddPeerToGroup", reflect.TypeOf((*MockStore)(nil).AddPeerToGroup), ctx, accountID, peerId, groupID)
+}
+
+// AddResourceToGroup mocks base method.
+func (m *MockStore) AddResourceToGroup(ctx context.Context, accountId, groupID string, resource *types2.Resource) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "AddResourceToGroup", ctx, accountId, groupID, resource)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// AddResourceToGroup indicates an expected call of AddResourceToGroup.
+func (mr *MockStoreMockRecorder) AddResourceToGroup(ctx, accountId, groupID, resource interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddResourceToGroup", reflect.TypeOf((*MockStore)(nil).AddResourceToGroup), ctx, accountId, groupID, resource)
+}
+
+// ApproveAccountPeers mocks base method.
+func (m *MockStore) ApproveAccountPeers(ctx context.Context, accountID string) (int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ApproveAccountPeers", ctx, accountID)
+ ret0, _ := ret[0].(int)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ApproveAccountPeers indicates an expected call of ApproveAccountPeers.
+func (mr *MockStoreMockRecorder) ApproveAccountPeers(ctx, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApproveAccountPeers", reflect.TypeOf((*MockStore)(nil).ApproveAccountPeers), ctx, accountID)
+}
+
+// Close mocks base method.
+func (m *MockStore) Close(ctx context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Close", ctx)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// Close indicates an expected call of Close.
+func (mr *MockStoreMockRecorder) Close(ctx interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockStore)(nil).Close), ctx)
+}
+
+// CompletePeerJob mocks base method.
+func (m *MockStore) CompletePeerJob(ctx context.Context, job *types2.Job) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CompletePeerJob", ctx, job)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CompletePeerJob indicates an expected call of CompletePeerJob.
+func (mr *MockStoreMockRecorder) CompletePeerJob(ctx, job interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompletePeerJob", reflect.TypeOf((*MockStore)(nil).CompletePeerJob), ctx, job)
+}
+
+// CountAccountsByPrivateDomain mocks base method.
+func (m *MockStore) CountAccountsByPrivateDomain(ctx context.Context, domain string) (int64, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CountAccountsByPrivateDomain", ctx, domain)
+ ret0, _ := ret[0].(int64)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CountAccountsByPrivateDomain indicates an expected call of CountAccountsByPrivateDomain.
+func (mr *MockStoreMockRecorder) CountAccountsByPrivateDomain(ctx, domain interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountAccountsByPrivateDomain", reflect.TypeOf((*MockStore)(nil).CountAccountsByPrivateDomain), ctx, domain)
+}
+
+// CreateAccessLog mocks base method.
+func (m *MockStore) CreateAccessLog(ctx context.Context, log *accesslogs.AccessLogEntry) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateAccessLog", ctx, log)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CreateAccessLog indicates an expected call of CreateAccessLog.
+func (mr *MockStoreMockRecorder) CreateAccessLog(ctx, log interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAccessLog", reflect.TypeOf((*MockStore)(nil).CreateAccessLog), ctx, log)
+}
+
+// CreateCustomDomain mocks base method.
+func (m *MockStore) CreateCustomDomain(ctx context.Context, accountID, domainName, targetCluster string, validated bool) (*domain.Domain, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateCustomDomain", ctx, accountID, domainName, targetCluster, validated)
+ ret0, _ := ret[0].(*domain.Domain)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CreateCustomDomain indicates an expected call of CreateCustomDomain.
+func (mr *MockStoreMockRecorder) CreateCustomDomain(ctx, accountID, domainName, targetCluster, validated interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateCustomDomain", reflect.TypeOf((*MockStore)(nil).CreateCustomDomain), ctx, accountID, domainName, targetCluster, validated)
+}
+
+// CreateDNSRecord mocks base method.
+func (m *MockStore) CreateDNSRecord(ctx context.Context, record *records.Record) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateDNSRecord", ctx, record)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CreateDNSRecord indicates an expected call of CreateDNSRecord.
+func (mr *MockStoreMockRecorder) CreateDNSRecord(ctx, record interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateDNSRecord", reflect.TypeOf((*MockStore)(nil).CreateDNSRecord), ctx, record)
+}
+
+// CreateGroup mocks base method.
+func (m *MockStore) CreateGroup(ctx context.Context, group *types2.Group) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateGroup", ctx, group)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CreateGroup indicates an expected call of CreateGroup.
+func (mr *MockStoreMockRecorder) CreateGroup(ctx, group interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateGroup", reflect.TypeOf((*MockStore)(nil).CreateGroup), ctx, group)
+}
+
+// CreateGroups mocks base method.
+func (m *MockStore) CreateGroups(ctx context.Context, accountID string, groups []*types2.Group) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateGroups", ctx, accountID, groups)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CreateGroups indicates an expected call of CreateGroups.
+func (mr *MockStoreMockRecorder) CreateGroups(ctx, accountID, groups interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateGroups", reflect.TypeOf((*MockStore)(nil).CreateGroups), ctx, accountID, groups)
+}
+
+// CreatePeerJob mocks base method.
+func (m *MockStore) CreatePeerJob(ctx context.Context, job *types2.Job) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreatePeerJob", ctx, job)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CreatePeerJob indicates an expected call of CreatePeerJob.
+func (mr *MockStoreMockRecorder) CreatePeerJob(ctx, job interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePeerJob", reflect.TypeOf((*MockStore)(nil).CreatePeerJob), ctx, job)
+}
+
+// CreatePolicy mocks base method.
+func (m *MockStore) CreatePolicy(ctx context.Context, policy *types2.Policy) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreatePolicy", ctx, policy)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CreatePolicy indicates an expected call of CreatePolicy.
+func (mr *MockStoreMockRecorder) CreatePolicy(ctx, policy interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePolicy", reflect.TypeOf((*MockStore)(nil).CreatePolicy), ctx, policy)
+}
+
+// CreateService mocks base method.
+func (m *MockStore) CreateService(ctx context.Context, service *reverseproxy.Service) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateService", ctx, service)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CreateService indicates an expected call of CreateService.
+func (mr *MockStoreMockRecorder) CreateService(ctx, service interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateService", reflect.TypeOf((*MockStore)(nil).CreateService), ctx, service)
+}
+
+// CreateZone mocks base method.
+func (m *MockStore) CreateZone(ctx context.Context, zone *zones.Zone) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateZone", ctx, zone)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CreateZone indicates an expected call of CreateZone.
+func (mr *MockStoreMockRecorder) CreateZone(ctx, zone interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateZone", reflect.TypeOf((*MockStore)(nil).CreateZone), ctx, zone)
+}
+
+// DeleteAccount mocks base method.
+func (m *MockStore) DeleteAccount(ctx context.Context, account *types2.Account) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteAccount", ctx, account)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteAccount indicates an expected call of DeleteAccount.
+func (mr *MockStoreMockRecorder) DeleteAccount(ctx, account interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAccount", reflect.TypeOf((*MockStore)(nil).DeleteAccount), ctx, account)
+}
+
+// DeleteCustomDomain mocks base method.
+func (m *MockStore) DeleteCustomDomain(ctx context.Context, accountID, domainID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteCustomDomain", ctx, accountID, domainID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteCustomDomain indicates an expected call of DeleteCustomDomain.
+func (mr *MockStoreMockRecorder) DeleteCustomDomain(ctx, accountID, domainID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteCustomDomain", reflect.TypeOf((*MockStore)(nil).DeleteCustomDomain), ctx, accountID, domainID)
+}
+
+// DeleteDNSRecord mocks base method.
+func (m *MockStore) DeleteDNSRecord(ctx context.Context, accountID, zoneID, recordID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteDNSRecord", ctx, accountID, zoneID, recordID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteDNSRecord indicates an expected call of DeleteDNSRecord.
+func (mr *MockStoreMockRecorder) DeleteDNSRecord(ctx, accountID, zoneID, recordID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDNSRecord", reflect.TypeOf((*MockStore)(nil).DeleteDNSRecord), ctx, accountID, zoneID, recordID)
+}
+
+// DeleteGroup mocks base method.
+func (m *MockStore) DeleteGroup(ctx context.Context, accountID, groupID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteGroup", ctx, accountID, groupID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteGroup indicates an expected call of DeleteGroup.
+func (mr *MockStoreMockRecorder) DeleteGroup(ctx, accountID, groupID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteGroup", reflect.TypeOf((*MockStore)(nil).DeleteGroup), ctx, accountID, groupID)
+}
+
+// DeleteGroups mocks base method.
+func (m *MockStore) DeleteGroups(ctx context.Context, accountID string, groupIDs []string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteGroups", ctx, accountID, groupIDs)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteGroups indicates an expected call of DeleteGroups.
+func (mr *MockStoreMockRecorder) DeleteGroups(ctx, accountID, groupIDs interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteGroups", reflect.TypeOf((*MockStore)(nil).DeleteGroups), ctx, accountID, groupIDs)
+}
+
+// DeleteHashedPAT2TokenIDIndex mocks base method.
+func (m *MockStore) DeleteHashedPAT2TokenIDIndex(hashedToken string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteHashedPAT2TokenIDIndex", hashedToken)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteHashedPAT2TokenIDIndex indicates an expected call of DeleteHashedPAT2TokenIDIndex.
+func (mr *MockStoreMockRecorder) DeleteHashedPAT2TokenIDIndex(hashedToken interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteHashedPAT2TokenIDIndex", reflect.TypeOf((*MockStore)(nil).DeleteHashedPAT2TokenIDIndex), hashedToken)
+}
+
+// DeleteNameServerGroup mocks base method.
+func (m *MockStore) DeleteNameServerGroup(ctx context.Context, accountID, nameServerGroupID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteNameServerGroup", ctx, accountID, nameServerGroupID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteNameServerGroup indicates an expected call of DeleteNameServerGroup.
+func (mr *MockStoreMockRecorder) DeleteNameServerGroup(ctx, accountID, nameServerGroupID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteNameServerGroup", reflect.TypeOf((*MockStore)(nil).DeleteNameServerGroup), ctx, accountID, nameServerGroupID)
+}
+
+// DeleteNetwork mocks base method.
+func (m *MockStore) DeleteNetwork(ctx context.Context, accountID, networkID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteNetwork", ctx, accountID, networkID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteNetwork indicates an expected call of DeleteNetwork.
+func (mr *MockStoreMockRecorder) DeleteNetwork(ctx, accountID, networkID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteNetwork", reflect.TypeOf((*MockStore)(nil).DeleteNetwork), ctx, accountID, networkID)
+}
+
+// DeleteNetworkResource mocks base method.
+func (m *MockStore) DeleteNetworkResource(ctx context.Context, accountID, resourceID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteNetworkResource", ctx, accountID, resourceID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteNetworkResource indicates an expected call of DeleteNetworkResource.
+func (mr *MockStoreMockRecorder) DeleteNetworkResource(ctx, accountID, resourceID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteNetworkResource", reflect.TypeOf((*MockStore)(nil).DeleteNetworkResource), ctx, accountID, resourceID)
+}
+
+// DeleteNetworkRouter mocks base method.
+func (m *MockStore) DeleteNetworkRouter(ctx context.Context, accountID, routerID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteNetworkRouter", ctx, accountID, routerID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteNetworkRouter indicates an expected call of DeleteNetworkRouter.
+func (mr *MockStoreMockRecorder) DeleteNetworkRouter(ctx, accountID, routerID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteNetworkRouter", reflect.TypeOf((*MockStore)(nil).DeleteNetworkRouter), ctx, accountID, routerID)
+}
+
+// DeletePAT mocks base method.
+func (m *MockStore) DeletePAT(ctx context.Context, userID, patID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeletePAT", ctx, userID, patID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeletePAT indicates an expected call of DeletePAT.
+func (mr *MockStoreMockRecorder) DeletePAT(ctx, userID, patID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePAT", reflect.TypeOf((*MockStore)(nil).DeletePAT), ctx, userID, patID)
+}
+
+// DeletePeer mocks base method.
+func (m *MockStore) DeletePeer(ctx context.Context, accountID, peerID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeletePeer", ctx, accountID, peerID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeletePeer indicates an expected call of DeletePeer.
+func (mr *MockStoreMockRecorder) DeletePeer(ctx, accountID, peerID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePeer", reflect.TypeOf((*MockStore)(nil).DeletePeer), ctx, accountID, peerID)
+}
+
+// DeletePolicy mocks base method.
+func (m *MockStore) DeletePolicy(ctx context.Context, accountID, policyID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeletePolicy", ctx, accountID, policyID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeletePolicy indicates an expected call of DeletePolicy.
+func (mr *MockStoreMockRecorder) DeletePolicy(ctx, accountID, policyID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePolicy", reflect.TypeOf((*MockStore)(nil).DeletePolicy), ctx, accountID, policyID)
+}
+
+// DeletePostureChecks mocks base method.
+func (m *MockStore) DeletePostureChecks(ctx context.Context, accountID, postureChecksID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeletePostureChecks", ctx, accountID, postureChecksID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeletePostureChecks indicates an expected call of DeletePostureChecks.
+func (mr *MockStoreMockRecorder) DeletePostureChecks(ctx, accountID, postureChecksID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePostureChecks", reflect.TypeOf((*MockStore)(nil).DeletePostureChecks), ctx, accountID, postureChecksID)
+}
+
+// DeleteRoute mocks base method.
+func (m *MockStore) DeleteRoute(ctx context.Context, accountID, routeID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteRoute", ctx, accountID, routeID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteRoute indicates an expected call of DeleteRoute.
+func (mr *MockStoreMockRecorder) DeleteRoute(ctx, accountID, routeID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRoute", reflect.TypeOf((*MockStore)(nil).DeleteRoute), ctx, accountID, routeID)
+}
+
+// DeleteService mocks base method.
+func (m *MockStore) DeleteService(ctx context.Context, accountID, serviceID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteService", ctx, accountID, serviceID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteService indicates an expected call of DeleteService.
+func (mr *MockStoreMockRecorder) DeleteService(ctx, accountID, serviceID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteService", reflect.TypeOf((*MockStore)(nil).DeleteService), ctx, accountID, serviceID)
+}
+
+// DeleteSetupKey mocks base method.
+func (m *MockStore) DeleteSetupKey(ctx context.Context, accountID, keyID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteSetupKey", ctx, accountID, keyID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteSetupKey indicates an expected call of DeleteSetupKey.
+func (mr *MockStoreMockRecorder) DeleteSetupKey(ctx, accountID, keyID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSetupKey", reflect.TypeOf((*MockStore)(nil).DeleteSetupKey), ctx, accountID, keyID)
+}
+
+// DeleteTokenID2UserIDIndex mocks base method.
+func (m *MockStore) DeleteTokenID2UserIDIndex(tokenID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteTokenID2UserIDIndex", tokenID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteTokenID2UserIDIndex indicates an expected call of DeleteTokenID2UserIDIndex.
+func (mr *MockStoreMockRecorder) DeleteTokenID2UserIDIndex(tokenID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteTokenID2UserIDIndex", reflect.TypeOf((*MockStore)(nil).DeleteTokenID2UserIDIndex), tokenID)
+}
+
+// DeleteUser mocks base method.
+func (m *MockStore) DeleteUser(ctx context.Context, accountID, userID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteUser", ctx, accountID, userID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteUser indicates an expected call of DeleteUser.
+func (mr *MockStoreMockRecorder) DeleteUser(ctx, accountID, userID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteUser", reflect.TypeOf((*MockStore)(nil).DeleteUser), ctx, accountID, userID)
+}
+
+// DeleteUserInvite mocks base method.
+func (m *MockStore) DeleteUserInvite(ctx context.Context, inviteID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteUserInvite", ctx, inviteID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteUserInvite indicates an expected call of DeleteUserInvite.
+func (mr *MockStoreMockRecorder) DeleteUserInvite(ctx, inviteID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteUserInvite", reflect.TypeOf((*MockStore)(nil).DeleteUserInvite), ctx, inviteID)
+}
+
+// DeleteZone mocks base method.
+func (m *MockStore) DeleteZone(ctx context.Context, accountID, zoneID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteZone", ctx, accountID, zoneID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteZone indicates an expected call of DeleteZone.
+func (mr *MockStoreMockRecorder) DeleteZone(ctx, accountID, zoneID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteZone", reflect.TypeOf((*MockStore)(nil).DeleteZone), ctx, accountID, zoneID)
+}
+
+// DeleteZoneDNSRecords mocks base method.
+func (m *MockStore) DeleteZoneDNSRecords(ctx context.Context, accountID, zoneID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteZoneDNSRecords", ctx, accountID, zoneID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteZoneDNSRecords indicates an expected call of DeleteZoneDNSRecords.
+func (mr *MockStoreMockRecorder) DeleteZoneDNSRecords(ctx, accountID, zoneID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteZoneDNSRecords", reflect.TypeOf((*MockStore)(nil).DeleteZoneDNSRecords), ctx, accountID, zoneID)
+}
+
+// ExecuteInTransaction mocks base method.
+func (m *MockStore) ExecuteInTransaction(ctx context.Context, f func(Store) error) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ExecuteInTransaction", ctx, f)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// ExecuteInTransaction indicates an expected call of ExecuteInTransaction.
+func (mr *MockStoreMockRecorder) ExecuteInTransaction(ctx, f interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExecuteInTransaction", reflect.TypeOf((*MockStore)(nil).ExecuteInTransaction), ctx, f)
+}
+
+// GetAccount mocks base method.
+func (m *MockStore) GetAccount(ctx context.Context, accountID string) (*types2.Account, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccount", ctx, accountID)
+ ret0, _ := ret[0].(*types2.Account)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccount indicates an expected call of GetAccount.
+func (mr *MockStoreMockRecorder) GetAccount(ctx, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*MockStore)(nil).GetAccount), ctx, accountID)
+}
+
+// GetAccountAccessLogs mocks base method.
+func (m *MockStore) GetAccountAccessLogs(ctx context.Context, lockStrength LockingStrength, accountID string, filter accesslogs.AccessLogFilter) ([]*accesslogs.AccessLogEntry, int64, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountAccessLogs", ctx, lockStrength, accountID, filter)
+ ret0, _ := ret[0].([]*accesslogs.AccessLogEntry)
+ ret1, _ := ret[1].(int64)
+ ret2, _ := ret[2].(error)
+ return ret0, ret1, ret2
+}
+
+// GetAccountAccessLogs indicates an expected call of GetAccountAccessLogs.
+func (mr *MockStoreMockRecorder) GetAccountAccessLogs(ctx, lockStrength, accountID, filter interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountAccessLogs", reflect.TypeOf((*MockStore)(nil).GetAccountAccessLogs), ctx, lockStrength, accountID, filter)
+}
+
+// GetAccountByPeerID mocks base method.
+func (m *MockStore) GetAccountByPeerID(ctx context.Context, peerID string) (*types2.Account, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountByPeerID", ctx, peerID)
+ ret0, _ := ret[0].(*types2.Account)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountByPeerID indicates an expected call of GetAccountByPeerID.
+func (mr *MockStoreMockRecorder) GetAccountByPeerID(ctx, peerID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountByPeerID", reflect.TypeOf((*MockStore)(nil).GetAccountByPeerID), ctx, peerID)
+}
+
+// GetAccountByPeerPubKey mocks base method.
+func (m *MockStore) GetAccountByPeerPubKey(ctx context.Context, peerKey string) (*types2.Account, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountByPeerPubKey", ctx, peerKey)
+ ret0, _ := ret[0].(*types2.Account)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountByPeerPubKey indicates an expected call of GetAccountByPeerPubKey.
+func (mr *MockStoreMockRecorder) GetAccountByPeerPubKey(ctx, peerKey interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountByPeerPubKey", reflect.TypeOf((*MockStore)(nil).GetAccountByPeerPubKey), ctx, peerKey)
+}
+
+// GetAccountByPrivateDomain mocks base method.
+func (m *MockStore) GetAccountByPrivateDomain(ctx context.Context, domain string) (*types2.Account, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountByPrivateDomain", ctx, domain)
+ ret0, _ := ret[0].(*types2.Account)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountByPrivateDomain indicates an expected call of GetAccountByPrivateDomain.
+func (mr *MockStoreMockRecorder) GetAccountByPrivateDomain(ctx, domain interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountByPrivateDomain", reflect.TypeOf((*MockStore)(nil).GetAccountByPrivateDomain), ctx, domain)
+}
+
+// GetAccountBySetupKey mocks base method.
+func (m *MockStore) GetAccountBySetupKey(ctx context.Context, setupKey string) (*types2.Account, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountBySetupKey", ctx, setupKey)
+ ret0, _ := ret[0].(*types2.Account)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountBySetupKey indicates an expected call of GetAccountBySetupKey.
+func (mr *MockStoreMockRecorder) GetAccountBySetupKey(ctx, setupKey interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountBySetupKey", reflect.TypeOf((*MockStore)(nil).GetAccountBySetupKey), ctx, setupKey)
+}
+
+// GetAccountByUser mocks base method.
+func (m *MockStore) GetAccountByUser(ctx context.Context, userID string) (*types2.Account, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountByUser", ctx, userID)
+ ret0, _ := ret[0].(*types2.Account)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountByUser indicates an expected call of GetAccountByUser.
+func (mr *MockStoreMockRecorder) GetAccountByUser(ctx, userID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountByUser", reflect.TypeOf((*MockStore)(nil).GetAccountByUser), ctx, userID)
+}
+
+// GetAccountCreatedBy mocks base method.
+func (m *MockStore) GetAccountCreatedBy(ctx context.Context, lockStrength LockingStrength, accountID string) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountCreatedBy", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountCreatedBy indicates an expected call of GetAccountCreatedBy.
+func (mr *MockStoreMockRecorder) GetAccountCreatedBy(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountCreatedBy", reflect.TypeOf((*MockStore)(nil).GetAccountCreatedBy), ctx, lockStrength, accountID)
+}
+
+// GetAccountDNSSettings mocks base method.
+func (m *MockStore) GetAccountDNSSettings(ctx context.Context, lockStrength LockingStrength, accountID string) (*types2.DNSSettings, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountDNSSettings", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].(*types2.DNSSettings)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountDNSSettings indicates an expected call of GetAccountDNSSettings.
+func (mr *MockStoreMockRecorder) GetAccountDNSSettings(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountDNSSettings", reflect.TypeOf((*MockStore)(nil).GetAccountDNSSettings), ctx, lockStrength, accountID)
+}
+
+// GetAccountDomainAndCategory mocks base method.
+func (m *MockStore) GetAccountDomainAndCategory(ctx context.Context, lockStrength LockingStrength, accountID string) (string, string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountDomainAndCategory", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(string)
+ ret2, _ := ret[2].(error)
+ return ret0, ret1, ret2
+}
+
+// GetAccountDomainAndCategory indicates an expected call of GetAccountDomainAndCategory.
+func (mr *MockStoreMockRecorder) GetAccountDomainAndCategory(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountDomainAndCategory", reflect.TypeOf((*MockStore)(nil).GetAccountDomainAndCategory), ctx, lockStrength, accountID)
+}
+
+// GetAccountGroupPeers mocks base method.
+func (m *MockStore) GetAccountGroupPeers(ctx context.Context, lockStrength LockingStrength, accountID string) (map[string]map[string]struct{}, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountGroupPeers", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].(map[string]map[string]struct{})
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountGroupPeers indicates an expected call of GetAccountGroupPeers.
+func (mr *MockStoreMockRecorder) GetAccountGroupPeers(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountGroupPeers", reflect.TypeOf((*MockStore)(nil).GetAccountGroupPeers), ctx, lockStrength, accountID)
+}
+
+// GetAccountGroups mocks base method.
+func (m *MockStore) GetAccountGroups(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types2.Group, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountGroups", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*types2.Group)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountGroups indicates an expected call of GetAccountGroups.
+func (mr *MockStoreMockRecorder) GetAccountGroups(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountGroups", reflect.TypeOf((*MockStore)(nil).GetAccountGroups), ctx, lockStrength, accountID)
+}
+
+// GetAccountIDByPeerID mocks base method.
+func (m *MockStore) GetAccountIDByPeerID(ctx context.Context, lockStrength LockingStrength, peerID string) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountIDByPeerID", ctx, lockStrength, peerID)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountIDByPeerID indicates an expected call of GetAccountIDByPeerID.
+func (mr *MockStoreMockRecorder) GetAccountIDByPeerID(ctx, lockStrength, peerID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountIDByPeerID", reflect.TypeOf((*MockStore)(nil).GetAccountIDByPeerID), ctx, lockStrength, peerID)
+}
+
+// GetAccountIDByPeerPubKey mocks base method.
+func (m *MockStore) GetAccountIDByPeerPubKey(ctx context.Context, peerKey string) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountIDByPeerPubKey", ctx, peerKey)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountIDByPeerPubKey indicates an expected call of GetAccountIDByPeerPubKey.
+func (mr *MockStoreMockRecorder) GetAccountIDByPeerPubKey(ctx, peerKey interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountIDByPeerPubKey", reflect.TypeOf((*MockStore)(nil).GetAccountIDByPeerPubKey), ctx, peerKey)
+}
+
+// GetAccountIDByPrivateDomain mocks base method.
+func (m *MockStore) GetAccountIDByPrivateDomain(ctx context.Context, lockStrength LockingStrength, domain string) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountIDByPrivateDomain", ctx, lockStrength, domain)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountIDByPrivateDomain indicates an expected call of GetAccountIDByPrivateDomain.
+func (mr *MockStoreMockRecorder) GetAccountIDByPrivateDomain(ctx, lockStrength, domain interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountIDByPrivateDomain", reflect.TypeOf((*MockStore)(nil).GetAccountIDByPrivateDomain), ctx, lockStrength, domain)
+}
+
+// GetAccountIDBySetupKey mocks base method.
+func (m *MockStore) GetAccountIDBySetupKey(ctx context.Context, peerKey string) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountIDBySetupKey", ctx, peerKey)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountIDBySetupKey indicates an expected call of GetAccountIDBySetupKey.
+func (mr *MockStoreMockRecorder) GetAccountIDBySetupKey(ctx, peerKey interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountIDBySetupKey", reflect.TypeOf((*MockStore)(nil).GetAccountIDBySetupKey), ctx, peerKey)
+}
+
+// GetAccountIDByUserID mocks base method.
+func (m *MockStore) GetAccountIDByUserID(ctx context.Context, lockStrength LockingStrength, userID string) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountIDByUserID", ctx, lockStrength, userID)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountIDByUserID indicates an expected call of GetAccountIDByUserID.
+func (mr *MockStoreMockRecorder) GetAccountIDByUserID(ctx, lockStrength, userID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountIDByUserID", reflect.TypeOf((*MockStore)(nil).GetAccountIDByUserID), ctx, lockStrength, userID)
+}
+
+// GetAccountMeta mocks base method.
+func (m *MockStore) GetAccountMeta(ctx context.Context, lockStrength LockingStrength, accountID string) (*types2.AccountMeta, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountMeta", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].(*types2.AccountMeta)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountMeta indicates an expected call of GetAccountMeta.
+func (mr *MockStoreMockRecorder) GetAccountMeta(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountMeta", reflect.TypeOf((*MockStore)(nil).GetAccountMeta), ctx, lockStrength, accountID)
+}
+
+// GetAccountNameServerGroups mocks base method.
+func (m *MockStore) GetAccountNameServerGroups(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*dns.NameServerGroup, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountNameServerGroups", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*dns.NameServerGroup)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountNameServerGroups indicates an expected call of GetAccountNameServerGroups.
+func (mr *MockStoreMockRecorder) GetAccountNameServerGroups(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountNameServerGroups", reflect.TypeOf((*MockStore)(nil).GetAccountNameServerGroups), ctx, lockStrength, accountID)
+}
+
+// GetAccountNetwork mocks base method.
+func (m *MockStore) GetAccountNetwork(ctx context.Context, lockStrength LockingStrength, accountId string) (*types2.Network, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountNetwork", ctx, lockStrength, accountId)
+ ret0, _ := ret[0].(*types2.Network)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountNetwork indicates an expected call of GetAccountNetwork.
+func (mr *MockStoreMockRecorder) GetAccountNetwork(ctx, lockStrength, accountId interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountNetwork", reflect.TypeOf((*MockStore)(nil).GetAccountNetwork), ctx, lockStrength, accountId)
+}
+
+// GetAccountNetworks mocks base method.
+func (m *MockStore) GetAccountNetworks(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types1.Network, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountNetworks", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*types1.Network)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountNetworks indicates an expected call of GetAccountNetworks.
+func (mr *MockStoreMockRecorder) GetAccountNetworks(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountNetworks", reflect.TypeOf((*MockStore)(nil).GetAccountNetworks), ctx, lockStrength, accountID)
+}
+
+// GetAccountOnboarding mocks base method.
+func (m *MockStore) GetAccountOnboarding(ctx context.Context, accountID string) (*types2.AccountOnboarding, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountOnboarding", ctx, accountID)
+ ret0, _ := ret[0].(*types2.AccountOnboarding)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountOnboarding indicates an expected call of GetAccountOnboarding.
+func (mr *MockStoreMockRecorder) GetAccountOnboarding(ctx, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountOnboarding", reflect.TypeOf((*MockStore)(nil).GetAccountOnboarding), ctx, accountID)
+}
+
+// GetAccountOwner mocks base method.
+func (m *MockStore) GetAccountOwner(ctx context.Context, lockStrength LockingStrength, accountID string) (*types2.User, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountOwner", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].(*types2.User)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountOwner indicates an expected call of GetAccountOwner.
+func (mr *MockStoreMockRecorder) GetAccountOwner(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountOwner", reflect.TypeOf((*MockStore)(nil).GetAccountOwner), ctx, lockStrength, accountID)
+}
+
+// GetAccountPeers mocks base method.
+func (m *MockStore) GetAccountPeers(ctx context.Context, lockStrength LockingStrength, accountID, nameFilter, ipFilter string) ([]*peer.Peer, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountPeers", ctx, lockStrength, accountID, nameFilter, ipFilter)
+ ret0, _ := ret[0].([]*peer.Peer)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountPeers indicates an expected call of GetAccountPeers.
+func (mr *MockStoreMockRecorder) GetAccountPeers(ctx, lockStrength, accountID, nameFilter, ipFilter interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountPeers", reflect.TypeOf((*MockStore)(nil).GetAccountPeers), ctx, lockStrength, accountID, nameFilter, ipFilter)
+}
+
+// GetAccountPeersWithExpiration mocks base method.
+func (m *MockStore) GetAccountPeersWithExpiration(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*peer.Peer, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountPeersWithExpiration", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*peer.Peer)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountPeersWithExpiration indicates an expected call of GetAccountPeersWithExpiration.
+func (mr *MockStoreMockRecorder) GetAccountPeersWithExpiration(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountPeersWithExpiration", reflect.TypeOf((*MockStore)(nil).GetAccountPeersWithExpiration), ctx, lockStrength, accountID)
+}
+
+// GetAccountPeersWithInactivity mocks base method.
+func (m *MockStore) GetAccountPeersWithInactivity(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*peer.Peer, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountPeersWithInactivity", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*peer.Peer)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountPeersWithInactivity indicates an expected call of GetAccountPeersWithInactivity.
+func (mr *MockStoreMockRecorder) GetAccountPeersWithInactivity(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountPeersWithInactivity", reflect.TypeOf((*MockStore)(nil).GetAccountPeersWithInactivity), ctx, lockStrength, accountID)
+}
+
+// GetAccountPolicies mocks base method.
+func (m *MockStore) GetAccountPolicies(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types2.Policy, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountPolicies", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*types2.Policy)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountPolicies indicates an expected call of GetAccountPolicies.
+func (mr *MockStoreMockRecorder) GetAccountPolicies(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountPolicies", reflect.TypeOf((*MockStore)(nil).GetAccountPolicies), ctx, lockStrength, accountID)
+}
+
+// GetAccountPostureChecks mocks base method.
+func (m *MockStore) GetAccountPostureChecks(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*posture.Checks, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountPostureChecks", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*posture.Checks)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountPostureChecks indicates an expected call of GetAccountPostureChecks.
+func (mr *MockStoreMockRecorder) GetAccountPostureChecks(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountPostureChecks", reflect.TypeOf((*MockStore)(nil).GetAccountPostureChecks), ctx, lockStrength, accountID)
+}
+
+// GetAccountRoutes mocks base method.
+func (m *MockStore) GetAccountRoutes(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*route.Route, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountRoutes", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*route.Route)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountRoutes indicates an expected call of GetAccountRoutes.
+func (mr *MockStoreMockRecorder) GetAccountRoutes(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountRoutes", reflect.TypeOf((*MockStore)(nil).GetAccountRoutes), ctx, lockStrength, accountID)
+}
+
+// GetAccountServices mocks base method.
+func (m *MockStore) GetAccountServices(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*reverseproxy.Service, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountServices", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*reverseproxy.Service)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountServices indicates an expected call of GetAccountServices.
+func (mr *MockStoreMockRecorder) GetAccountServices(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountServices", reflect.TypeOf((*MockStore)(nil).GetAccountServices), ctx, lockStrength, accountID)
+}
+
+// GetAccountSettings mocks base method.
+func (m *MockStore) GetAccountSettings(ctx context.Context, lockStrength LockingStrength, accountID string) (*types2.Settings, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountSettings", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].(*types2.Settings)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountSettings indicates an expected call of GetAccountSettings.
+func (mr *MockStoreMockRecorder) GetAccountSettings(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountSettings", reflect.TypeOf((*MockStore)(nil).GetAccountSettings), ctx, lockStrength, accountID)
+}
+
+// GetAccountSetupKeys mocks base method.
+func (m *MockStore) GetAccountSetupKeys(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types2.SetupKey, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountSetupKeys", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*types2.SetupKey)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountSetupKeys indicates an expected call of GetAccountSetupKeys.
+func (mr *MockStoreMockRecorder) GetAccountSetupKeys(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountSetupKeys", reflect.TypeOf((*MockStore)(nil).GetAccountSetupKeys), ctx, lockStrength, accountID)
+}
+
+// GetAccountUserInvites mocks base method.
+func (m *MockStore) GetAccountUserInvites(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types2.UserInviteRecord, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountUserInvites", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*types2.UserInviteRecord)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountUserInvites indicates an expected call of GetAccountUserInvites.
+func (mr *MockStoreMockRecorder) GetAccountUserInvites(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountUserInvites", reflect.TypeOf((*MockStore)(nil).GetAccountUserInvites), ctx, lockStrength, accountID)
+}
+
+// GetAccountUsers mocks base method.
+func (m *MockStore) GetAccountUsers(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types2.User, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountUsers", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*types2.User)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountUsers indicates an expected call of GetAccountUsers.
+func (mr *MockStoreMockRecorder) GetAccountUsers(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountUsers", reflect.TypeOf((*MockStore)(nil).GetAccountUsers), ctx, lockStrength, accountID)
+}
+
+// GetAccountZones mocks base method.
+func (m *MockStore) GetAccountZones(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*zones.Zone, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountZones", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*zones.Zone)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountZones indicates an expected call of GetAccountZones.
+func (mr *MockStoreMockRecorder) GetAccountZones(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountZones", reflect.TypeOf((*MockStore)(nil).GetAccountZones), ctx, lockStrength, accountID)
+}
+
+// GetAccountsCounter mocks base method.
+func (m *MockStore) GetAccountsCounter(ctx context.Context) (int64, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccountsCounter", ctx)
+ ret0, _ := ret[0].(int64)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccountsCounter indicates an expected call of GetAccountsCounter.
+func (mr *MockStoreMockRecorder) GetAccountsCounter(ctx interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountsCounter", reflect.TypeOf((*MockStore)(nil).GetAccountsCounter), ctx)
+}
+
+// GetAllAccounts mocks base method.
+func (m *MockStore) GetAllAccounts(ctx context.Context) []*types2.Account {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAllAccounts", ctx)
+ ret0, _ := ret[0].([]*types2.Account)
+ return ret0
+}
+
+// GetAllAccounts indicates an expected call of GetAllAccounts.
+func (mr *MockStoreMockRecorder) GetAllAccounts(ctx interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllAccounts", reflect.TypeOf((*MockStore)(nil).GetAllAccounts), ctx)
+}
+
+// GetAllEphemeralPeers mocks base method.
+func (m *MockStore) GetAllEphemeralPeers(ctx context.Context, lockStrength LockingStrength) ([]*peer.Peer, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAllEphemeralPeers", ctx, lockStrength)
+ ret0, _ := ret[0].([]*peer.Peer)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAllEphemeralPeers indicates an expected call of GetAllEphemeralPeers.
+func (mr *MockStoreMockRecorder) GetAllEphemeralPeers(ctx, lockStrength interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllEphemeralPeers", reflect.TypeOf((*MockStore)(nil).GetAllEphemeralPeers), ctx, lockStrength)
+}
+
+// GetAllProxyAccessTokens mocks base method.
+func (m *MockStore) GetAllProxyAccessTokens(ctx context.Context, lockStrength LockingStrength) ([]*types2.ProxyAccessToken, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAllProxyAccessTokens", ctx, lockStrength)
+ ret0, _ := ret[0].([]*types2.ProxyAccessToken)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAllProxyAccessTokens indicates an expected call of GetAllProxyAccessTokens.
+func (mr *MockStoreMockRecorder) GetAllProxyAccessTokens(ctx, lockStrength interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllProxyAccessTokens", reflect.TypeOf((*MockStore)(nil).GetAllProxyAccessTokens), ctx, lockStrength)
+}
+
+// GetAnyAccountID mocks base method.
+func (m *MockStore) GetAnyAccountID(ctx context.Context) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAnyAccountID", ctx)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAnyAccountID indicates an expected call of GetAnyAccountID.
+func (mr *MockStoreMockRecorder) GetAnyAccountID(ctx interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAnyAccountID", reflect.TypeOf((*MockStore)(nil).GetAnyAccountID), ctx)
+}
+
+// GetCustomDomain mocks base method.
+func (m *MockStore) GetCustomDomain(ctx context.Context, accountID, domainID string) (*domain.Domain, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetCustomDomain", ctx, accountID, domainID)
+ ret0, _ := ret[0].(*domain.Domain)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetCustomDomain indicates an expected call of GetCustomDomain.
+func (mr *MockStoreMockRecorder) GetCustomDomain(ctx, accountID, domainID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCustomDomain", reflect.TypeOf((*MockStore)(nil).GetCustomDomain), ctx, accountID, domainID)
+}
+
+// GetDNSRecordByID mocks base method.
+func (m *MockStore) GetDNSRecordByID(ctx context.Context, lockStrength LockingStrength, accountID, zoneID, recordID string) (*records.Record, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetDNSRecordByID", ctx, lockStrength, accountID, zoneID, recordID)
+ ret0, _ := ret[0].(*records.Record)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetDNSRecordByID indicates an expected call of GetDNSRecordByID.
+func (mr *MockStoreMockRecorder) GetDNSRecordByID(ctx, lockStrength, accountID, zoneID, recordID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDNSRecordByID", reflect.TypeOf((*MockStore)(nil).GetDNSRecordByID), ctx, lockStrength, accountID, zoneID, recordID)
+}
+
+// GetGroupByID mocks base method.
+func (m *MockStore) GetGroupByID(ctx context.Context, lockStrength LockingStrength, accountID, groupID string) (*types2.Group, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetGroupByID", ctx, lockStrength, accountID, groupID)
+ ret0, _ := ret[0].(*types2.Group)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetGroupByID indicates an expected call of GetGroupByID.
+func (mr *MockStoreMockRecorder) GetGroupByID(ctx, lockStrength, accountID, groupID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupByID", reflect.TypeOf((*MockStore)(nil).GetGroupByID), ctx, lockStrength, accountID, groupID)
+}
+
+// GetGroupByName mocks base method.
+func (m *MockStore) GetGroupByName(ctx context.Context, lockStrength LockingStrength, groupName, accountID string) (*types2.Group, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetGroupByName", ctx, lockStrength, groupName, accountID)
+ ret0, _ := ret[0].(*types2.Group)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetGroupByName indicates an expected call of GetGroupByName.
+func (mr *MockStoreMockRecorder) GetGroupByName(ctx, lockStrength, groupName, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupByName", reflect.TypeOf((*MockStore)(nil).GetGroupByName), ctx, lockStrength, groupName, accountID)
+}
+
+// GetGroupsByIDs mocks base method.
+func (m *MockStore) GetGroupsByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, groupIDs []string) (map[string]*types2.Group, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetGroupsByIDs", ctx, lockStrength, accountID, groupIDs)
+ ret0, _ := ret[0].(map[string]*types2.Group)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetGroupsByIDs indicates an expected call of GetGroupsByIDs.
+func (mr *MockStoreMockRecorder) GetGroupsByIDs(ctx, lockStrength, accountID, groupIDs interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupsByIDs", reflect.TypeOf((*MockStore)(nil).GetGroupsByIDs), ctx, lockStrength, accountID, groupIDs)
+}
+
+// GetInstallationID mocks base method.
+func (m *MockStore) GetInstallationID() string {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetInstallationID")
+ ret0, _ := ret[0].(string)
+ return ret0
+}
+
+// GetInstallationID indicates an expected call of GetInstallationID.
+func (mr *MockStoreMockRecorder) GetInstallationID() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInstallationID", reflect.TypeOf((*MockStore)(nil).GetInstallationID))
+}
+
+// GetNameServerGroupByID mocks base method.
+func (m *MockStore) GetNameServerGroupByID(ctx context.Context, lockStrength LockingStrength, nameServerGroupID, accountID string) (*dns.NameServerGroup, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetNameServerGroupByID", ctx, lockStrength, nameServerGroupID, accountID)
+ ret0, _ := ret[0].(*dns.NameServerGroup)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetNameServerGroupByID indicates an expected call of GetNameServerGroupByID.
+func (mr *MockStoreMockRecorder) GetNameServerGroupByID(ctx, lockStrength, nameServerGroupID, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNameServerGroupByID", reflect.TypeOf((*MockStore)(nil).GetNameServerGroupByID), ctx, lockStrength, nameServerGroupID, accountID)
+}
+
+// GetNetworkByID mocks base method.
+func (m *MockStore) GetNetworkByID(ctx context.Context, lockStrength LockingStrength, accountID, networkID string) (*types1.Network, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetNetworkByID", ctx, lockStrength, accountID, networkID)
+ ret0, _ := ret[0].(*types1.Network)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetNetworkByID indicates an expected call of GetNetworkByID.
+func (mr *MockStoreMockRecorder) GetNetworkByID(ctx, lockStrength, accountID, networkID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetworkByID", reflect.TypeOf((*MockStore)(nil).GetNetworkByID), ctx, lockStrength, accountID, networkID)
+}
+
+// GetNetworkResourceByID mocks base method.
+func (m *MockStore) GetNetworkResourceByID(ctx context.Context, lockStrength LockingStrength, accountID, resourceID string) (*types.NetworkResource, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetNetworkResourceByID", ctx, lockStrength, accountID, resourceID)
+ ret0, _ := ret[0].(*types.NetworkResource)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetNetworkResourceByID indicates an expected call of GetNetworkResourceByID.
+func (mr *MockStoreMockRecorder) GetNetworkResourceByID(ctx, lockStrength, accountID, resourceID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetworkResourceByID", reflect.TypeOf((*MockStore)(nil).GetNetworkResourceByID), ctx, lockStrength, accountID, resourceID)
+}
+
+// GetNetworkResourceByName mocks base method.
+func (m *MockStore) GetNetworkResourceByName(ctx context.Context, lockStrength LockingStrength, accountID, resourceName string) (*types.NetworkResource, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetNetworkResourceByName", ctx, lockStrength, accountID, resourceName)
+ ret0, _ := ret[0].(*types.NetworkResource)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetNetworkResourceByName indicates an expected call of GetNetworkResourceByName.
+func (mr *MockStoreMockRecorder) GetNetworkResourceByName(ctx, lockStrength, accountID, resourceName interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetworkResourceByName", reflect.TypeOf((*MockStore)(nil).GetNetworkResourceByName), ctx, lockStrength, accountID, resourceName)
+}
+
+// GetNetworkResourcesByAccountID mocks base method.
+func (m *MockStore) GetNetworkResourcesByAccountID(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.NetworkResource, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetNetworkResourcesByAccountID", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*types.NetworkResource)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetNetworkResourcesByAccountID indicates an expected call of GetNetworkResourcesByAccountID.
+func (mr *MockStoreMockRecorder) GetNetworkResourcesByAccountID(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetworkResourcesByAccountID", reflect.TypeOf((*MockStore)(nil).GetNetworkResourcesByAccountID), ctx, lockStrength, accountID)
+}
+
+// GetNetworkResourcesByNetID mocks base method.
+func (m *MockStore) GetNetworkResourcesByNetID(ctx context.Context, lockStrength LockingStrength, accountID, netID string) ([]*types.NetworkResource, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetNetworkResourcesByNetID", ctx, lockStrength, accountID, netID)
+ ret0, _ := ret[0].([]*types.NetworkResource)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetNetworkResourcesByNetID indicates an expected call of GetNetworkResourcesByNetID.
+func (mr *MockStoreMockRecorder) GetNetworkResourcesByNetID(ctx, lockStrength, accountID, netID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetworkResourcesByNetID", reflect.TypeOf((*MockStore)(nil).GetNetworkResourcesByNetID), ctx, lockStrength, accountID, netID)
+}
+
+// GetNetworkRouterByID mocks base method.
+func (m *MockStore) GetNetworkRouterByID(ctx context.Context, lockStrength LockingStrength, accountID, routerID string) (*types0.NetworkRouter, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetNetworkRouterByID", ctx, lockStrength, accountID, routerID)
+ ret0, _ := ret[0].(*types0.NetworkRouter)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetNetworkRouterByID indicates an expected call of GetNetworkRouterByID.
+func (mr *MockStoreMockRecorder) GetNetworkRouterByID(ctx, lockStrength, accountID, routerID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetworkRouterByID", reflect.TypeOf((*MockStore)(nil).GetNetworkRouterByID), ctx, lockStrength, accountID, routerID)
+}
+
+// GetNetworkRoutersByAccountID mocks base method.
+func (m *MockStore) GetNetworkRoutersByAccountID(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types0.NetworkRouter, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetNetworkRoutersByAccountID", ctx, lockStrength, accountID)
+ ret0, _ := ret[0].([]*types0.NetworkRouter)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetNetworkRoutersByAccountID indicates an expected call of GetNetworkRoutersByAccountID.
+func (mr *MockStoreMockRecorder) GetNetworkRoutersByAccountID(ctx, lockStrength, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetworkRoutersByAccountID", reflect.TypeOf((*MockStore)(nil).GetNetworkRoutersByAccountID), ctx, lockStrength, accountID)
+}
+
+// GetNetworkRoutersByNetID mocks base method.
+func (m *MockStore) GetNetworkRoutersByNetID(ctx context.Context, lockStrength LockingStrength, accountID, netID string) ([]*types0.NetworkRouter, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetNetworkRoutersByNetID", ctx, lockStrength, accountID, netID)
+ ret0, _ := ret[0].([]*types0.NetworkRouter)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetNetworkRoutersByNetID indicates an expected call of GetNetworkRoutersByNetID.
+func (mr *MockStoreMockRecorder) GetNetworkRoutersByNetID(ctx, lockStrength, accountID, netID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetworkRoutersByNetID", reflect.TypeOf((*MockStore)(nil).GetNetworkRoutersByNetID), ctx, lockStrength, accountID, netID)
+}
+
+// GetPATByHashedToken mocks base method.
+func (m *MockStore) GetPATByHashedToken(ctx context.Context, lockStrength LockingStrength, hashedToken string) (*types2.PersonalAccessToken, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPATByHashedToken", ctx, lockStrength, hashedToken)
+ ret0, _ := ret[0].(*types2.PersonalAccessToken)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPATByHashedToken indicates an expected call of GetPATByHashedToken.
+func (mr *MockStoreMockRecorder) GetPATByHashedToken(ctx, lockStrength, hashedToken interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPATByHashedToken", reflect.TypeOf((*MockStore)(nil).GetPATByHashedToken), ctx, lockStrength, hashedToken)
+}
+
+// GetPATByID mocks base method.
+func (m *MockStore) GetPATByID(ctx context.Context, lockStrength LockingStrength, userID, patID string) (*types2.PersonalAccessToken, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPATByID", ctx, lockStrength, userID, patID)
+ ret0, _ := ret[0].(*types2.PersonalAccessToken)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPATByID indicates an expected call of GetPATByID.
+func (mr *MockStoreMockRecorder) GetPATByID(ctx, lockStrength, userID, patID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPATByID", reflect.TypeOf((*MockStore)(nil).GetPATByID), ctx, lockStrength, userID, patID)
+}
+
+// GetPeerByID mocks base method.
+func (m *MockStore) GetPeerByID(ctx context.Context, lockStrength LockingStrength, accountID, peerID string) (*peer.Peer, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeerByID", ctx, lockStrength, accountID, peerID)
+ ret0, _ := ret[0].(*peer.Peer)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeerByID indicates an expected call of GetPeerByID.
+func (mr *MockStoreMockRecorder) GetPeerByID(ctx, lockStrength, accountID, peerID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerByID", reflect.TypeOf((*MockStore)(nil).GetPeerByID), ctx, lockStrength, accountID, peerID)
+}
+
+// GetPeerByIP mocks base method.
+func (m *MockStore) GetPeerByIP(ctx context.Context, lockStrength LockingStrength, accountID string, ip net.IP) (*peer.Peer, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeerByIP", ctx, lockStrength, accountID, ip)
+ ret0, _ := ret[0].(*peer.Peer)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeerByIP indicates an expected call of GetPeerByIP.
+func (mr *MockStoreMockRecorder) GetPeerByIP(ctx, lockStrength, accountID, ip interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerByIP", reflect.TypeOf((*MockStore)(nil).GetPeerByIP), ctx, lockStrength, accountID, ip)
+}
+
+// GetPeerByPeerPubKey mocks base method.
+func (m *MockStore) GetPeerByPeerPubKey(ctx context.Context, lockStrength LockingStrength, peerKey string) (*peer.Peer, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeerByPeerPubKey", ctx, lockStrength, peerKey)
+ ret0, _ := ret[0].(*peer.Peer)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeerByPeerPubKey indicates an expected call of GetPeerByPeerPubKey.
+func (mr *MockStoreMockRecorder) GetPeerByPeerPubKey(ctx, lockStrength, peerKey interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerByPeerPubKey", reflect.TypeOf((*MockStore)(nil).GetPeerByPeerPubKey), ctx, lockStrength, peerKey)
+}
+
+// GetPeerGroupIDs mocks base method.
+func (m *MockStore) GetPeerGroupIDs(ctx context.Context, lockStrength LockingStrength, accountId, peerId string) ([]string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeerGroupIDs", ctx, lockStrength, accountId, peerId)
+ ret0, _ := ret[0].([]string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeerGroupIDs indicates an expected call of GetPeerGroupIDs.
+func (mr *MockStoreMockRecorder) GetPeerGroupIDs(ctx, lockStrength, accountId, peerId interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerGroupIDs", reflect.TypeOf((*MockStore)(nil).GetPeerGroupIDs), ctx, lockStrength, accountId, peerId)
+}
+
+// GetPeerGroups mocks base method.
+func (m *MockStore) GetPeerGroups(ctx context.Context, lockStrength LockingStrength, accountId, peerId string) ([]*types2.Group, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeerGroups", ctx, lockStrength, accountId, peerId)
+ ret0, _ := ret[0].([]*types2.Group)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeerGroups indicates an expected call of GetPeerGroups.
+func (mr *MockStoreMockRecorder) GetPeerGroups(ctx, lockStrength, accountId, peerId interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerGroups", reflect.TypeOf((*MockStore)(nil).GetPeerGroups), ctx, lockStrength, accountId, peerId)
+}
+
+// GetPeerIDByKey mocks base method.
+func (m *MockStore) GetPeerIDByKey(ctx context.Context, lockStrength LockingStrength, key string) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeerIDByKey", ctx, lockStrength, key)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeerIDByKey indicates an expected call of GetPeerIDByKey.
+func (mr *MockStoreMockRecorder) GetPeerIDByKey(ctx, lockStrength, key interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerIDByKey", reflect.TypeOf((*MockStore)(nil).GetPeerIDByKey), ctx, lockStrength, key)
+}
+
+// GetPeerIdByLabel mocks base method.
+func (m *MockStore) GetPeerIdByLabel(ctx context.Context, lockStrength LockingStrength, accountID, hostname string) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeerIdByLabel", ctx, lockStrength, accountID, hostname)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeerIdByLabel indicates an expected call of GetPeerIdByLabel.
+func (mr *MockStoreMockRecorder) GetPeerIdByLabel(ctx, lockStrength, accountID, hostname interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerIdByLabel", reflect.TypeOf((*MockStore)(nil).GetPeerIdByLabel), ctx, lockStrength, accountID, hostname)
+}
+
+// GetPeerJobByID mocks base method.
+func (m *MockStore) GetPeerJobByID(ctx context.Context, accountID, jobID string) (*types2.Job, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeerJobByID", ctx, accountID, jobID)
+ ret0, _ := ret[0].(*types2.Job)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeerJobByID indicates an expected call of GetPeerJobByID.
+func (mr *MockStoreMockRecorder) GetPeerJobByID(ctx, accountID, jobID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerJobByID", reflect.TypeOf((*MockStore)(nil).GetPeerJobByID), ctx, accountID, jobID)
+}
+
+// GetPeerJobs mocks base method.
+func (m *MockStore) GetPeerJobs(ctx context.Context, accountID, peerID string) ([]*types2.Job, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeerJobs", ctx, accountID, peerID)
+ ret0, _ := ret[0].([]*types2.Job)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeerJobs indicates an expected call of GetPeerJobs.
+func (mr *MockStoreMockRecorder) GetPeerJobs(ctx, accountID, peerID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerJobs", reflect.TypeOf((*MockStore)(nil).GetPeerJobs), ctx, accountID, peerID)
+}
+
+// GetPeerLabelsInAccount mocks base method.
+func (m *MockStore) GetPeerLabelsInAccount(ctx context.Context, lockStrength LockingStrength, accountId, hostname string) ([]string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeerLabelsInAccount", ctx, lockStrength, accountId, hostname)
+ ret0, _ := ret[0].([]string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeerLabelsInAccount indicates an expected call of GetPeerLabelsInAccount.
+func (mr *MockStoreMockRecorder) GetPeerLabelsInAccount(ctx, lockStrength, accountId, hostname interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerLabelsInAccount", reflect.TypeOf((*MockStore)(nil).GetPeerLabelsInAccount), ctx, lockStrength, accountId, hostname)
+}
+
+// GetPeersByGroupIDs mocks base method.
+func (m *MockStore) GetPeersByGroupIDs(ctx context.Context, accountID string, groupIDs []string) ([]*peer.Peer, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeersByGroupIDs", ctx, accountID, groupIDs)
+ ret0, _ := ret[0].([]*peer.Peer)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeersByGroupIDs indicates an expected call of GetPeersByGroupIDs.
+func (mr *MockStoreMockRecorder) GetPeersByGroupIDs(ctx, accountID, groupIDs interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeersByGroupIDs", reflect.TypeOf((*MockStore)(nil).GetPeersByGroupIDs), ctx, accountID, groupIDs)
+}
+
+// GetPeersByIDs mocks base method.
+func (m *MockStore) GetPeersByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, peerIDs []string) (map[string]*peer.Peer, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPeersByIDs", ctx, lockStrength, accountID, peerIDs)
+ ret0, _ := ret[0].(map[string]*peer.Peer)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPeersByIDs indicates an expected call of GetPeersByIDs.
+func (mr *MockStoreMockRecorder) GetPeersByIDs(ctx, lockStrength, accountID, peerIDs interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeersByIDs", reflect.TypeOf((*MockStore)(nil).GetPeersByIDs), ctx, lockStrength, accountID, peerIDs)
+}
+
+// GetPolicyByID mocks base method.
+func (m *MockStore) GetPolicyByID(ctx context.Context, lockStrength LockingStrength, accountID, policyID string) (*types2.Policy, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPolicyByID", ctx, lockStrength, accountID, policyID)
+ ret0, _ := ret[0].(*types2.Policy)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPolicyByID indicates an expected call of GetPolicyByID.
+func (mr *MockStoreMockRecorder) GetPolicyByID(ctx, lockStrength, accountID, policyID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicyByID", reflect.TypeOf((*MockStore)(nil).GetPolicyByID), ctx, lockStrength, accountID, policyID)
+}
+
+// GetPolicyRulesByResourceID mocks base method.
+func (m *MockStore) GetPolicyRulesByResourceID(ctx context.Context, lockStrength LockingStrength, accountID, peerID string) ([]*types2.PolicyRule, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPolicyRulesByResourceID", ctx, lockStrength, accountID, peerID)
+ ret0, _ := ret[0].([]*types2.PolicyRule)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPolicyRulesByResourceID indicates an expected call of GetPolicyRulesByResourceID.
+func (mr *MockStoreMockRecorder) GetPolicyRulesByResourceID(ctx, lockStrength, accountID, peerID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicyRulesByResourceID", reflect.TypeOf((*MockStore)(nil).GetPolicyRulesByResourceID), ctx, lockStrength, accountID, peerID)
+}
+
+// GetPostureCheckByChecksDefinition mocks base method.
+func (m *MockStore) GetPostureCheckByChecksDefinition(accountID string, checks *posture.ChecksDefinition) (*posture.Checks, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPostureCheckByChecksDefinition", accountID, checks)
+ ret0, _ := ret[0].(*posture.Checks)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPostureCheckByChecksDefinition indicates an expected call of GetPostureCheckByChecksDefinition.
+func (mr *MockStoreMockRecorder) GetPostureCheckByChecksDefinition(accountID, checks interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPostureCheckByChecksDefinition", reflect.TypeOf((*MockStore)(nil).GetPostureCheckByChecksDefinition), accountID, checks)
+}
+
+// GetPostureChecksByID mocks base method.
+func (m *MockStore) GetPostureChecksByID(ctx context.Context, lockStrength LockingStrength, accountID, postureCheckID string) (*posture.Checks, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPostureChecksByID", ctx, lockStrength, accountID, postureCheckID)
+ ret0, _ := ret[0].(*posture.Checks)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPostureChecksByID indicates an expected call of GetPostureChecksByID.
+func (mr *MockStoreMockRecorder) GetPostureChecksByID(ctx, lockStrength, accountID, postureCheckID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPostureChecksByID", reflect.TypeOf((*MockStore)(nil).GetPostureChecksByID), ctx, lockStrength, accountID, postureCheckID)
+}
+
+// GetPostureChecksByIDs mocks base method.
+func (m *MockStore) GetPostureChecksByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, postureChecksIDs []string) (map[string]*posture.Checks, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetPostureChecksByIDs", ctx, lockStrength, accountID, postureChecksIDs)
+ ret0, _ := ret[0].(map[string]*posture.Checks)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetPostureChecksByIDs indicates an expected call of GetPostureChecksByIDs.
+func (mr *MockStoreMockRecorder) GetPostureChecksByIDs(ctx, lockStrength, accountID, postureChecksIDs interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPostureChecksByIDs", reflect.TypeOf((*MockStore)(nil).GetPostureChecksByIDs), ctx, lockStrength, accountID, postureChecksIDs)
+}
+
+// GetProxyAccessTokenByHashedToken mocks base method.
+func (m *MockStore) GetProxyAccessTokenByHashedToken(ctx context.Context, lockStrength LockingStrength, hashedToken types2.HashedProxyToken) (*types2.ProxyAccessToken, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetProxyAccessTokenByHashedToken", ctx, lockStrength, hashedToken)
+ ret0, _ := ret[0].(*types2.ProxyAccessToken)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetProxyAccessTokenByHashedToken indicates an expected call of GetProxyAccessTokenByHashedToken.
+func (mr *MockStoreMockRecorder) GetProxyAccessTokenByHashedToken(ctx, lockStrength, hashedToken interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProxyAccessTokenByHashedToken", reflect.TypeOf((*MockStore)(nil).GetProxyAccessTokenByHashedToken), ctx, lockStrength, hashedToken)
+}
+
+// GetResourceGroups mocks base method.
+func (m *MockStore) GetResourceGroups(ctx context.Context, lockStrength LockingStrength, accountID, resourceID string) ([]*types2.Group, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetResourceGroups", ctx, lockStrength, accountID, resourceID)
+ ret0, _ := ret[0].([]*types2.Group)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetResourceGroups indicates an expected call of GetResourceGroups.
+func (mr *MockStoreMockRecorder) GetResourceGroups(ctx, lockStrength, accountID, resourceID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetResourceGroups", reflect.TypeOf((*MockStore)(nil).GetResourceGroups), ctx, lockStrength, accountID, resourceID)
+}
+
+// GetRouteByID mocks base method.
+func (m *MockStore) GetRouteByID(ctx context.Context, lockStrength LockingStrength, accountID, routeID string) (*route.Route, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetRouteByID", ctx, lockStrength, accountID, routeID)
+ ret0, _ := ret[0].(*route.Route)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetRouteByID indicates an expected call of GetRouteByID.
+func (mr *MockStoreMockRecorder) GetRouteByID(ctx, lockStrength, accountID, routeID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRouteByID", reflect.TypeOf((*MockStore)(nil).GetRouteByID), ctx, lockStrength, accountID, routeID)
+}
+
+// GetServiceByDomain mocks base method.
+func (m *MockStore) GetServiceByDomain(ctx context.Context, accountID, domain string) (*reverseproxy.Service, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetServiceByDomain", ctx, accountID, domain)
+ ret0, _ := ret[0].(*reverseproxy.Service)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetServiceByDomain indicates an expected call of GetServiceByDomain.
+func (mr *MockStoreMockRecorder) GetServiceByDomain(ctx, accountID, domain interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetServiceByDomain", reflect.TypeOf((*MockStore)(nil).GetServiceByDomain), ctx, accountID, domain)
+}
+
+// GetServiceByID mocks base method.
+func (m *MockStore) GetServiceByID(ctx context.Context, lockStrength LockingStrength, accountID, serviceID string) (*reverseproxy.Service, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetServiceByID", ctx, lockStrength, accountID, serviceID)
+ ret0, _ := ret[0].(*reverseproxy.Service)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetServiceByID indicates an expected call of GetServiceByID.
+func (mr *MockStoreMockRecorder) GetServiceByID(ctx, lockStrength, accountID, serviceID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetServiceByID", reflect.TypeOf((*MockStore)(nil).GetServiceByID), ctx, lockStrength, accountID, serviceID)
+}
+
+// GetServiceTargetByTargetID mocks base method.
+func (m *MockStore) GetServiceTargetByTargetID(ctx context.Context, lockStrength LockingStrength, accountID, targetID string) (*reverseproxy.Target, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetServiceTargetByTargetID", ctx, lockStrength, accountID, targetID)
+ ret0, _ := ret[0].(*reverseproxy.Target)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetServiceTargetByTargetID indicates an expected call of GetServiceTargetByTargetID.
+func (mr *MockStoreMockRecorder) GetServiceTargetByTargetID(ctx, lockStrength, accountID, targetID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetServiceTargetByTargetID", reflect.TypeOf((*MockStore)(nil).GetServiceTargetByTargetID), ctx, lockStrength, accountID, targetID)
+}
+
+// GetServices mocks base method.
+func (m *MockStore) GetServices(ctx context.Context, lockStrength LockingStrength) ([]*reverseproxy.Service, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetServices", ctx, lockStrength)
+ ret0, _ := ret[0].([]*reverseproxy.Service)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetServices indicates an expected call of GetServices.
+func (mr *MockStoreMockRecorder) GetServices(ctx, lockStrength interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetServices", reflect.TypeOf((*MockStore)(nil).GetServices), ctx, lockStrength)
+}
+
+// GetSetupKeyByID mocks base method.
+func (m *MockStore) GetSetupKeyByID(ctx context.Context, lockStrength LockingStrength, accountID, setupKeyID string) (*types2.SetupKey, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetSetupKeyByID", ctx, lockStrength, accountID, setupKeyID)
+ ret0, _ := ret[0].(*types2.SetupKey)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetSetupKeyByID indicates an expected call of GetSetupKeyByID.
+func (mr *MockStoreMockRecorder) GetSetupKeyByID(ctx, lockStrength, accountID, setupKeyID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSetupKeyByID", reflect.TypeOf((*MockStore)(nil).GetSetupKeyByID), ctx, lockStrength, accountID, setupKeyID)
+}
+
+// GetSetupKeyBySecret mocks base method.
+func (m *MockStore) GetSetupKeyBySecret(ctx context.Context, lockStrength LockingStrength, key string) (*types2.SetupKey, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetSetupKeyBySecret", ctx, lockStrength, key)
+ ret0, _ := ret[0].(*types2.SetupKey)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetSetupKeyBySecret indicates an expected call of GetSetupKeyBySecret.
+func (mr *MockStoreMockRecorder) GetSetupKeyBySecret(ctx, lockStrength, key interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSetupKeyBySecret", reflect.TypeOf((*MockStore)(nil).GetSetupKeyBySecret), ctx, lockStrength, key)
+}
+
+// GetStoreEngine mocks base method.
+func (m *MockStore) GetStoreEngine() types2.Engine {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetStoreEngine")
+ ret0, _ := ret[0].(types2.Engine)
+ return ret0
+}
+
+// GetStoreEngine indicates an expected call of GetStoreEngine.
+func (mr *MockStoreMockRecorder) GetStoreEngine() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStoreEngine", reflect.TypeOf((*MockStore)(nil).GetStoreEngine))
+}
+
+// GetTakenIPs mocks base method.
+func (m *MockStore) GetTakenIPs(ctx context.Context, lockStrength LockingStrength, accountId string) ([]net.IP, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetTakenIPs", ctx, lockStrength, accountId)
+ ret0, _ := ret[0].([]net.IP)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetTakenIPs indicates an expected call of GetTakenIPs.
+func (mr *MockStoreMockRecorder) GetTakenIPs(ctx, lockStrength, accountId interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakenIPs", reflect.TypeOf((*MockStore)(nil).GetTakenIPs), ctx, lockStrength, accountId)
+}
+
+// GetTokenIDByHashedToken mocks base method.
+func (m *MockStore) GetTokenIDByHashedToken(ctx context.Context, secret string) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetTokenIDByHashedToken", ctx, secret)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetTokenIDByHashedToken indicates an expected call of GetTokenIDByHashedToken.
+func (mr *MockStoreMockRecorder) GetTokenIDByHashedToken(ctx, secret interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenIDByHashedToken", reflect.TypeOf((*MockStore)(nil).GetTokenIDByHashedToken), ctx, secret)
+}
+
+// GetUserByPATID mocks base method.
+func (m *MockStore) GetUserByPATID(ctx context.Context, lockStrength LockingStrength, patID string) (*types2.User, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetUserByPATID", ctx, lockStrength, patID)
+ ret0, _ := ret[0].(*types2.User)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetUserByPATID indicates an expected call of GetUserByPATID.
+func (mr *MockStoreMockRecorder) GetUserByPATID(ctx, lockStrength, patID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByPATID", reflect.TypeOf((*MockStore)(nil).GetUserByPATID), ctx, lockStrength, patID)
+}
+
+// GetUserByUserID mocks base method.
+func (m *MockStore) GetUserByUserID(ctx context.Context, lockStrength LockingStrength, userID string) (*types2.User, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetUserByUserID", ctx, lockStrength, userID)
+ ret0, _ := ret[0].(*types2.User)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetUserByUserID indicates an expected call of GetUserByUserID.
+func (mr *MockStoreMockRecorder) GetUserByUserID(ctx, lockStrength, userID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByUserID", reflect.TypeOf((*MockStore)(nil).GetUserByUserID), ctx, lockStrength, userID)
+}
+
+// GetUserIDByPeerKey mocks base method.
+func (m *MockStore) GetUserIDByPeerKey(ctx context.Context, lockStrength LockingStrength, peerKey string) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetUserIDByPeerKey", ctx, lockStrength, peerKey)
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetUserIDByPeerKey indicates an expected call of GetUserIDByPeerKey.
+func (mr *MockStoreMockRecorder) GetUserIDByPeerKey(ctx, lockStrength, peerKey interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserIDByPeerKey", reflect.TypeOf((*MockStore)(nil).GetUserIDByPeerKey), ctx, lockStrength, peerKey)
+}
+
+// GetUserInviteByEmail mocks base method.
+func (m *MockStore) GetUserInviteByEmail(ctx context.Context, lockStrength LockingStrength, accountID, email string) (*types2.UserInviteRecord, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetUserInviteByEmail", ctx, lockStrength, accountID, email)
+ ret0, _ := ret[0].(*types2.UserInviteRecord)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetUserInviteByEmail indicates an expected call of GetUserInviteByEmail.
+func (mr *MockStoreMockRecorder) GetUserInviteByEmail(ctx, lockStrength, accountID, email interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserInviteByEmail", reflect.TypeOf((*MockStore)(nil).GetUserInviteByEmail), ctx, lockStrength, accountID, email)
+}
+
+// GetUserInviteByHashedToken mocks base method.
+func (m *MockStore) GetUserInviteByHashedToken(ctx context.Context, lockStrength LockingStrength, hashedToken string) (*types2.UserInviteRecord, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetUserInviteByHashedToken", ctx, lockStrength, hashedToken)
+ ret0, _ := ret[0].(*types2.UserInviteRecord)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetUserInviteByHashedToken indicates an expected call of GetUserInviteByHashedToken.
+func (mr *MockStoreMockRecorder) GetUserInviteByHashedToken(ctx, lockStrength, hashedToken interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserInviteByHashedToken", reflect.TypeOf((*MockStore)(nil).GetUserInviteByHashedToken), ctx, lockStrength, hashedToken)
+}
+
+// GetUserInviteByID mocks base method.
+func (m *MockStore) GetUserInviteByID(ctx context.Context, lockStrength LockingStrength, accountID, inviteID string) (*types2.UserInviteRecord, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetUserInviteByID", ctx, lockStrength, accountID, inviteID)
+ ret0, _ := ret[0].(*types2.UserInviteRecord)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetUserInviteByID indicates an expected call of GetUserInviteByID.
+func (mr *MockStoreMockRecorder) GetUserInviteByID(ctx, lockStrength, accountID, inviteID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserInviteByID", reflect.TypeOf((*MockStore)(nil).GetUserInviteByID), ctx, lockStrength, accountID, inviteID)
+}
+
+// GetUserPATs mocks base method.
+func (m *MockStore) GetUserPATs(ctx context.Context, lockStrength LockingStrength, userID string) ([]*types2.PersonalAccessToken, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetUserPATs", ctx, lockStrength, userID)
+ ret0, _ := ret[0].([]*types2.PersonalAccessToken)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetUserPATs indicates an expected call of GetUserPATs.
+func (mr *MockStoreMockRecorder) GetUserPATs(ctx, lockStrength, userID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserPATs", reflect.TypeOf((*MockStore)(nil).GetUserPATs), ctx, lockStrength, userID)
+}
+
+// GetUserPeers mocks base method.
+func (m *MockStore) GetUserPeers(ctx context.Context, lockStrength LockingStrength, accountID, userID string) ([]*peer.Peer, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetUserPeers", ctx, lockStrength, accountID, userID)
+ ret0, _ := ret[0].([]*peer.Peer)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetUserPeers indicates an expected call of GetUserPeers.
+func (mr *MockStoreMockRecorder) GetUserPeers(ctx, lockStrength, accountID, userID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserPeers", reflect.TypeOf((*MockStore)(nil).GetUserPeers), ctx, lockStrength, accountID, userID)
+}
+
+// GetZoneByDomain mocks base method.
+func (m *MockStore) GetZoneByDomain(ctx context.Context, accountID, domain string) (*zones.Zone, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetZoneByDomain", ctx, accountID, domain)
+ ret0, _ := ret[0].(*zones.Zone)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetZoneByDomain indicates an expected call of GetZoneByDomain.
+func (mr *MockStoreMockRecorder) GetZoneByDomain(ctx, accountID, domain interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetZoneByDomain", reflect.TypeOf((*MockStore)(nil).GetZoneByDomain), ctx, accountID, domain)
+}
+
+// GetZoneByID mocks base method.
+func (m *MockStore) GetZoneByID(ctx context.Context, lockStrength LockingStrength, accountID, zoneID string) (*zones.Zone, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetZoneByID", ctx, lockStrength, accountID, zoneID)
+ ret0, _ := ret[0].(*zones.Zone)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetZoneByID indicates an expected call of GetZoneByID.
+func (mr *MockStoreMockRecorder) GetZoneByID(ctx, lockStrength, accountID, zoneID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetZoneByID", reflect.TypeOf((*MockStore)(nil).GetZoneByID), ctx, lockStrength, accountID, zoneID)
+}
+
+// GetZoneDNSRecords mocks base method.
+func (m *MockStore) GetZoneDNSRecords(ctx context.Context, lockStrength LockingStrength, accountID, zoneID string) ([]*records.Record, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetZoneDNSRecords", ctx, lockStrength, accountID, zoneID)
+ ret0, _ := ret[0].([]*records.Record)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetZoneDNSRecords indicates an expected call of GetZoneDNSRecords.
+func (mr *MockStoreMockRecorder) GetZoneDNSRecords(ctx, lockStrength, accountID, zoneID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetZoneDNSRecords", reflect.TypeOf((*MockStore)(nil).GetZoneDNSRecords), ctx, lockStrength, accountID, zoneID)
+}
+
+// GetZoneDNSRecordsByName mocks base method.
+func (m *MockStore) GetZoneDNSRecordsByName(ctx context.Context, lockStrength LockingStrength, accountID, zoneID, name string) ([]*records.Record, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetZoneDNSRecordsByName", ctx, lockStrength, accountID, zoneID, name)
+ ret0, _ := ret[0].([]*records.Record)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetZoneDNSRecordsByName indicates an expected call of GetZoneDNSRecordsByName.
+func (mr *MockStoreMockRecorder) GetZoneDNSRecordsByName(ctx, lockStrength, accountID, zoneID, name interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetZoneDNSRecordsByName", reflect.TypeOf((*MockStore)(nil).GetZoneDNSRecordsByName), ctx, lockStrength, accountID, zoneID, name)
+}
+
+// IncrementNetworkSerial mocks base method.
+func (m *MockStore) IncrementNetworkSerial(ctx context.Context, accountId string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "IncrementNetworkSerial", ctx, accountId)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// IncrementNetworkSerial indicates an expected call of IncrementNetworkSerial.
+func (mr *MockStoreMockRecorder) IncrementNetworkSerial(ctx, accountId interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IncrementNetworkSerial", reflect.TypeOf((*MockStore)(nil).IncrementNetworkSerial), ctx, accountId)
+}
+
+// IncrementSetupKeyUsage mocks base method.
+func (m *MockStore) IncrementSetupKeyUsage(ctx context.Context, setupKeyID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "IncrementSetupKeyUsage", ctx, setupKeyID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// IncrementSetupKeyUsage indicates an expected call of IncrementSetupKeyUsage.
+func (mr *MockStoreMockRecorder) IncrementSetupKeyUsage(ctx, setupKeyID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IncrementSetupKeyUsage", reflect.TypeOf((*MockStore)(nil).IncrementSetupKeyUsage), ctx, setupKeyID)
+}
+
+// IsPrimaryAccount mocks base method.
+func (m *MockStore) IsPrimaryAccount(ctx context.Context, accountID string) (bool, string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "IsPrimaryAccount", ctx, accountID)
+ ret0, _ := ret[0].(bool)
+ ret1, _ := ret[1].(string)
+ ret2, _ := ret[2].(error)
+ return ret0, ret1, ret2
+}
+
+// IsPrimaryAccount indicates an expected call of IsPrimaryAccount.
+func (mr *MockStoreMockRecorder) IsPrimaryAccount(ctx, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsPrimaryAccount", reflect.TypeOf((*MockStore)(nil).IsPrimaryAccount), ctx, accountID)
+}
+
+// ListCustomDomains mocks base method.
+func (m *MockStore) ListCustomDomains(ctx context.Context, accountID string) ([]*domain.Domain, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListCustomDomains", ctx, accountID)
+ ret0, _ := ret[0].([]*domain.Domain)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListCustomDomains indicates an expected call of ListCustomDomains.
+func (mr *MockStoreMockRecorder) ListCustomDomains(ctx, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListCustomDomains", reflect.TypeOf((*MockStore)(nil).ListCustomDomains), ctx, accountID)
+}
+
+// ListFreeDomains mocks base method.
+func (m *MockStore) ListFreeDomains(ctx context.Context, accountID string) ([]string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListFreeDomains", ctx, accountID)
+ ret0, _ := ret[0].([]string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListFreeDomains indicates an expected call of ListFreeDomains.
+func (mr *MockStoreMockRecorder) ListFreeDomains(ctx, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListFreeDomains", reflect.TypeOf((*MockStore)(nil).ListFreeDomains), ctx, accountID)
+}
+
+// MarkAccountPrimary mocks base method.
+func (m *MockStore) MarkAccountPrimary(ctx context.Context, accountID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "MarkAccountPrimary", ctx, accountID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// MarkAccountPrimary indicates an expected call of MarkAccountPrimary.
+func (mr *MockStoreMockRecorder) MarkAccountPrimary(ctx, accountID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkAccountPrimary", reflect.TypeOf((*MockStore)(nil).MarkAccountPrimary), ctx, accountID)
+}
+
+// MarkAllPendingJobsAsFailed mocks base method.
+func (m *MockStore) MarkAllPendingJobsAsFailed(ctx context.Context, accountID, peerID, reason string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "MarkAllPendingJobsAsFailed", ctx, accountID, peerID, reason)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// MarkAllPendingJobsAsFailed indicates an expected call of MarkAllPendingJobsAsFailed.
+func (mr *MockStoreMockRecorder) MarkAllPendingJobsAsFailed(ctx, accountID, peerID, reason interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkAllPendingJobsAsFailed", reflect.TypeOf((*MockStore)(nil).MarkAllPendingJobsAsFailed), ctx, accountID, peerID, reason)
+}
+
+// MarkPATUsed mocks base method.
+func (m *MockStore) MarkPATUsed(ctx context.Context, patID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "MarkPATUsed", ctx, patID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// MarkPATUsed indicates an expected call of MarkPATUsed.
+func (mr *MockStoreMockRecorder) MarkPATUsed(ctx, patID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkPATUsed", reflect.TypeOf((*MockStore)(nil).MarkPATUsed), ctx, patID)
+}
+
+// MarkPendingJobsAsFailed mocks base method.
+func (m *MockStore) MarkPendingJobsAsFailed(ctx context.Context, accountID, peerID, jobID, reason string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "MarkPendingJobsAsFailed", ctx, accountID, peerID, jobID, reason)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// MarkPendingJobsAsFailed indicates an expected call of MarkPendingJobsAsFailed.
+func (mr *MockStoreMockRecorder) MarkPendingJobsAsFailed(ctx, accountID, peerID, jobID, reason interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkPendingJobsAsFailed", reflect.TypeOf((*MockStore)(nil).MarkPendingJobsAsFailed), ctx, accountID, peerID, jobID, reason)
+}
+
+// MarkProxyAccessTokenUsed mocks base method.
+func (m *MockStore) MarkProxyAccessTokenUsed(ctx context.Context, tokenID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "MarkProxyAccessTokenUsed", ctx, tokenID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// MarkProxyAccessTokenUsed indicates an expected call of MarkProxyAccessTokenUsed.
+func (mr *MockStoreMockRecorder) MarkProxyAccessTokenUsed(ctx, tokenID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkProxyAccessTokenUsed", reflect.TypeOf((*MockStore)(nil).MarkProxyAccessTokenUsed), ctx, tokenID)
+}
+
+// RemovePeerFromAllGroups mocks base method.
+func (m *MockStore) RemovePeerFromAllGroups(ctx context.Context, peerID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "RemovePeerFromAllGroups", ctx, peerID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// RemovePeerFromAllGroups indicates an expected call of RemovePeerFromAllGroups.
+func (mr *MockStoreMockRecorder) RemovePeerFromAllGroups(ctx, peerID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemovePeerFromAllGroups", reflect.TypeOf((*MockStore)(nil).RemovePeerFromAllGroups), ctx, peerID)
+}
+
+// RemovePeerFromGroup mocks base method.
+func (m *MockStore) RemovePeerFromGroup(ctx context.Context, peerID, groupID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "RemovePeerFromGroup", ctx, peerID, groupID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// RemovePeerFromGroup indicates an expected call of RemovePeerFromGroup.
+func (mr *MockStoreMockRecorder) RemovePeerFromGroup(ctx, peerID, groupID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemovePeerFromGroup", reflect.TypeOf((*MockStore)(nil).RemovePeerFromGroup), ctx, peerID, groupID)
+}
+
+// RemoveResourceFromGroup mocks base method.
+func (m *MockStore) RemoveResourceFromGroup(ctx context.Context, accountId, groupID, resourceID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "RemoveResourceFromGroup", ctx, accountId, groupID, resourceID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// RemoveResourceFromGroup indicates an expected call of RemoveResourceFromGroup.
+func (mr *MockStoreMockRecorder) RemoveResourceFromGroup(ctx, accountId, groupID, resourceID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveResourceFromGroup", reflect.TypeOf((*MockStore)(nil).RemoveResourceFromGroup), ctx, accountId, groupID, resourceID)
+}
+
+// RevokeProxyAccessToken mocks base method.
+func (m *MockStore) RevokeProxyAccessToken(ctx context.Context, tokenID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "RevokeProxyAccessToken", ctx, tokenID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// RevokeProxyAccessToken indicates an expected call of RevokeProxyAccessToken.
+func (mr *MockStoreMockRecorder) RevokeProxyAccessToken(ctx, tokenID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevokeProxyAccessToken", reflect.TypeOf((*MockStore)(nil).RevokeProxyAccessToken), ctx, tokenID)
+}
+
+// SaveAccount mocks base method.
+func (m *MockStore) SaveAccount(ctx context.Context, account *types2.Account) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveAccount", ctx, account)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveAccount indicates an expected call of SaveAccount.
+func (mr *MockStoreMockRecorder) SaveAccount(ctx, account interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveAccount", reflect.TypeOf((*MockStore)(nil).SaveAccount), ctx, account)
+}
+
+// SaveAccountOnboarding mocks base method.
+func (m *MockStore) SaveAccountOnboarding(ctx context.Context, onboarding *types2.AccountOnboarding) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveAccountOnboarding", ctx, onboarding)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveAccountOnboarding indicates an expected call of SaveAccountOnboarding.
+func (mr *MockStoreMockRecorder) SaveAccountOnboarding(ctx, onboarding interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveAccountOnboarding", reflect.TypeOf((*MockStore)(nil).SaveAccountOnboarding), ctx, onboarding)
+}
+
+// SaveAccountSettings mocks base method.
+func (m *MockStore) SaveAccountSettings(ctx context.Context, accountID string, settings *types2.Settings) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveAccountSettings", ctx, accountID, settings)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveAccountSettings indicates an expected call of SaveAccountSettings.
+func (mr *MockStoreMockRecorder) SaveAccountSettings(ctx, accountID, settings interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveAccountSettings", reflect.TypeOf((*MockStore)(nil).SaveAccountSettings), ctx, accountID, settings)
+}
+
+// SaveDNSSettings mocks base method.
+func (m *MockStore) SaveDNSSettings(ctx context.Context, accountID string, settings *types2.DNSSettings) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveDNSSettings", ctx, accountID, settings)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveDNSSettings indicates an expected call of SaveDNSSettings.
+func (mr *MockStoreMockRecorder) SaveDNSSettings(ctx, accountID, settings interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveDNSSettings", reflect.TypeOf((*MockStore)(nil).SaveDNSSettings), ctx, accountID, settings)
+}
+
+// SaveInstallationID mocks base method.
+func (m *MockStore) SaveInstallationID(ctx context.Context, ID string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveInstallationID", ctx, ID)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveInstallationID indicates an expected call of SaveInstallationID.
+func (mr *MockStoreMockRecorder) SaveInstallationID(ctx, ID interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveInstallationID", reflect.TypeOf((*MockStore)(nil).SaveInstallationID), ctx, ID)
+}
+
+// SaveNameServerGroup mocks base method.
+func (m *MockStore) SaveNameServerGroup(ctx context.Context, nameServerGroup *dns.NameServerGroup) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveNameServerGroup", ctx, nameServerGroup)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveNameServerGroup indicates an expected call of SaveNameServerGroup.
+func (mr *MockStoreMockRecorder) SaveNameServerGroup(ctx, nameServerGroup interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveNameServerGroup", reflect.TypeOf((*MockStore)(nil).SaveNameServerGroup), ctx, nameServerGroup)
+}
+
+// SaveNetwork mocks base method.
+func (m *MockStore) SaveNetwork(ctx context.Context, network *types1.Network) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveNetwork", ctx, network)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveNetwork indicates an expected call of SaveNetwork.
+func (mr *MockStoreMockRecorder) SaveNetwork(ctx, network interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveNetwork", reflect.TypeOf((*MockStore)(nil).SaveNetwork), ctx, network)
+}
+
+// SaveNetworkResource mocks base method.
+func (m *MockStore) SaveNetworkResource(ctx context.Context, resource *types.NetworkResource) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveNetworkResource", ctx, resource)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveNetworkResource indicates an expected call of SaveNetworkResource.
+func (mr *MockStoreMockRecorder) SaveNetworkResource(ctx, resource interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveNetworkResource", reflect.TypeOf((*MockStore)(nil).SaveNetworkResource), ctx, resource)
+}
+
+// SaveNetworkRouter mocks base method.
+func (m *MockStore) SaveNetworkRouter(ctx context.Context, router *types0.NetworkRouter) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveNetworkRouter", ctx, router)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveNetworkRouter indicates an expected call of SaveNetworkRouter.
+func (mr *MockStoreMockRecorder) SaveNetworkRouter(ctx, router interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveNetworkRouter", reflect.TypeOf((*MockStore)(nil).SaveNetworkRouter), ctx, router)
+}
+
+// SavePAT mocks base method.
+func (m *MockStore) SavePAT(ctx context.Context, pat *types2.PersonalAccessToken) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SavePAT", ctx, pat)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SavePAT indicates an expected call of SavePAT.
+func (mr *MockStoreMockRecorder) SavePAT(ctx, pat interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePAT", reflect.TypeOf((*MockStore)(nil).SavePAT), ctx, pat)
+}
+
+// SavePeer mocks base method.
+func (m *MockStore) SavePeer(ctx context.Context, accountID string, peer *peer.Peer) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SavePeer", ctx, accountID, peer)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SavePeer indicates an expected call of SavePeer.
+func (mr *MockStoreMockRecorder) SavePeer(ctx, accountID, peer interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePeer", reflect.TypeOf((*MockStore)(nil).SavePeer), ctx, accountID, peer)
+}
+
+// SavePeerLocation mocks base method.
+func (m *MockStore) SavePeerLocation(ctx context.Context, accountID string, peer *peer.Peer) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SavePeerLocation", ctx, accountID, peer)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SavePeerLocation indicates an expected call of SavePeerLocation.
+func (mr *MockStoreMockRecorder) SavePeerLocation(ctx, accountID, peer interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePeerLocation", reflect.TypeOf((*MockStore)(nil).SavePeerLocation), ctx, accountID, peer)
+}
+
+// SavePeerStatus mocks base method.
+func (m *MockStore) SavePeerStatus(ctx context.Context, accountID, peerID string, status peer.PeerStatus) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SavePeerStatus", ctx, accountID, peerID, status)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SavePeerStatus indicates an expected call of SavePeerStatus.
+func (mr *MockStoreMockRecorder) SavePeerStatus(ctx, accountID, peerID, status interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePeerStatus", reflect.TypeOf((*MockStore)(nil).SavePeerStatus), ctx, accountID, peerID, status)
+}
+
+// SavePolicy mocks base method.
+func (m *MockStore) SavePolicy(ctx context.Context, policy *types2.Policy) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SavePolicy", ctx, policy)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SavePolicy indicates an expected call of SavePolicy.
+func (mr *MockStoreMockRecorder) SavePolicy(ctx, policy interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePolicy", reflect.TypeOf((*MockStore)(nil).SavePolicy), ctx, policy)
+}
+
+// SavePostureChecks mocks base method.
+func (m *MockStore) SavePostureChecks(ctx context.Context, postureCheck *posture.Checks) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SavePostureChecks", ctx, postureCheck)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SavePostureChecks indicates an expected call of SavePostureChecks.
+func (mr *MockStoreMockRecorder) SavePostureChecks(ctx, postureCheck interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePostureChecks", reflect.TypeOf((*MockStore)(nil).SavePostureChecks), ctx, postureCheck)
+}
+
+// SaveProxyAccessToken mocks base method.
+func (m *MockStore) SaveProxyAccessToken(ctx context.Context, token *types2.ProxyAccessToken) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveProxyAccessToken", ctx, token)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveProxyAccessToken indicates an expected call of SaveProxyAccessToken.
+func (mr *MockStoreMockRecorder) SaveProxyAccessToken(ctx, token interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveProxyAccessToken", reflect.TypeOf((*MockStore)(nil).SaveProxyAccessToken), ctx, token)
+}
+
+// SaveRoute mocks base method.
+func (m *MockStore) SaveRoute(ctx context.Context, route *route.Route) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveRoute", ctx, route)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveRoute indicates an expected call of SaveRoute.
+func (mr *MockStoreMockRecorder) SaveRoute(ctx, route interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveRoute", reflect.TypeOf((*MockStore)(nil).SaveRoute), ctx, route)
+}
+
+// SaveSetupKey mocks base method.
+func (m *MockStore) SaveSetupKey(ctx context.Context, setupKey *types2.SetupKey) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveSetupKey", ctx, setupKey)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveSetupKey indicates an expected call of SaveSetupKey.
+func (mr *MockStoreMockRecorder) SaveSetupKey(ctx, setupKey interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveSetupKey", reflect.TypeOf((*MockStore)(nil).SaveSetupKey), ctx, setupKey)
+}
+
+// SaveUser mocks base method.
+func (m *MockStore) SaveUser(ctx context.Context, user *types2.User) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveUser", ctx, user)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveUser indicates an expected call of SaveUser.
+func (mr *MockStoreMockRecorder) SaveUser(ctx, user interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveUser", reflect.TypeOf((*MockStore)(nil).SaveUser), ctx, user)
+}
+
+// SaveUserInvite mocks base method.
+func (m *MockStore) SaveUserInvite(ctx context.Context, invite *types2.UserInviteRecord) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveUserInvite", ctx, invite)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveUserInvite indicates an expected call of SaveUserInvite.
+func (mr *MockStoreMockRecorder) SaveUserInvite(ctx, invite interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveUserInvite", reflect.TypeOf((*MockStore)(nil).SaveUserInvite), ctx, invite)
+}
+
+// SaveUserLastLogin mocks base method.
+func (m *MockStore) SaveUserLastLogin(ctx context.Context, accountID, userID string, lastLogin time.Time) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveUserLastLogin", ctx, accountID, userID, lastLogin)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveUserLastLogin indicates an expected call of SaveUserLastLogin.
+func (mr *MockStoreMockRecorder) SaveUserLastLogin(ctx, accountID, userID, lastLogin interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveUserLastLogin", reflect.TypeOf((*MockStore)(nil).SaveUserLastLogin), ctx, accountID, userID, lastLogin)
+}
+
+// SaveUsers mocks base method.
+func (m *MockStore) SaveUsers(ctx context.Context, users []*types2.User) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveUsers", ctx, users)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveUsers indicates an expected call of SaveUsers.
+func (mr *MockStoreMockRecorder) SaveUsers(ctx, users interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveUsers", reflect.TypeOf((*MockStore)(nil).SaveUsers), ctx, users)
+}
+
+// SetFieldEncrypt mocks base method.
+func (m *MockStore) SetFieldEncrypt(enc *crypt.FieldEncrypt) {
+ m.ctrl.T.Helper()
+ m.ctrl.Call(m, "SetFieldEncrypt", enc)
+}
+
+// SetFieldEncrypt indicates an expected call of SetFieldEncrypt.
+func (mr *MockStoreMockRecorder) SetFieldEncrypt(enc interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetFieldEncrypt", reflect.TypeOf((*MockStore)(nil).SetFieldEncrypt), enc)
+}
+
+// UpdateAccountDomainAttributes mocks base method.
+func (m *MockStore) UpdateAccountDomainAttributes(ctx context.Context, accountID, domain, category string, isPrimaryDomain bool) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "UpdateAccountDomainAttributes", ctx, accountID, domain, category, isPrimaryDomain)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// UpdateAccountDomainAttributes indicates an expected call of UpdateAccountDomainAttributes.
+func (mr *MockStoreMockRecorder) UpdateAccountDomainAttributes(ctx, accountID, domain, category, isPrimaryDomain interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAccountDomainAttributes", reflect.TypeOf((*MockStore)(nil).UpdateAccountDomainAttributes), ctx, accountID, domain, category, isPrimaryDomain)
+}
+
+// UpdateAccountNetwork mocks base method.
+func (m *MockStore) UpdateAccountNetwork(ctx context.Context, accountID string, ipNet net.IPNet) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "UpdateAccountNetwork", ctx, accountID, ipNet)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// UpdateAccountNetwork indicates an expected call of UpdateAccountNetwork.
+func (mr *MockStoreMockRecorder) UpdateAccountNetwork(ctx, accountID, ipNet interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAccountNetwork", reflect.TypeOf((*MockStore)(nil).UpdateAccountNetwork), ctx, accountID, ipNet)
+}
+
+// UpdateCustomDomain mocks base method.
+func (m *MockStore) UpdateCustomDomain(ctx context.Context, accountID string, d *domain.Domain) (*domain.Domain, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "UpdateCustomDomain", ctx, accountID, d)
+ ret0, _ := ret[0].(*domain.Domain)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// UpdateCustomDomain indicates an expected call of UpdateCustomDomain.
+func (mr *MockStoreMockRecorder) UpdateCustomDomain(ctx, accountID, d interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateCustomDomain", reflect.TypeOf((*MockStore)(nil).UpdateCustomDomain), ctx, accountID, d)
+}
+
+// UpdateDNSRecord mocks base method.
+func (m *MockStore) UpdateDNSRecord(ctx context.Context, record *records.Record) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "UpdateDNSRecord", ctx, record)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// UpdateDNSRecord indicates an expected call of UpdateDNSRecord.
+func (mr *MockStoreMockRecorder) UpdateDNSRecord(ctx, record interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDNSRecord", reflect.TypeOf((*MockStore)(nil).UpdateDNSRecord), ctx, record)
+}
+
+// UpdateGroup mocks base method.
+func (m *MockStore) UpdateGroup(ctx context.Context, group *types2.Group) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "UpdateGroup", ctx, group)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// UpdateGroup indicates an expected call of UpdateGroup.
+func (mr *MockStoreMockRecorder) UpdateGroup(ctx, group interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateGroup", reflect.TypeOf((*MockStore)(nil).UpdateGroup), ctx, group)
+}
+
+// UpdateGroups mocks base method.
+func (m *MockStore) UpdateGroups(ctx context.Context, accountID string, groups []*types2.Group) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "UpdateGroups", ctx, accountID, groups)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// UpdateGroups indicates an expected call of UpdateGroups.
+func (mr *MockStoreMockRecorder) UpdateGroups(ctx, accountID, groups interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateGroups", reflect.TypeOf((*MockStore)(nil).UpdateGroups), ctx, accountID, groups)
+}
+
+// UpdateService mocks base method.
+func (m *MockStore) UpdateService(ctx context.Context, service *reverseproxy.Service) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "UpdateService", ctx, service)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// UpdateService indicates an expected call of UpdateService.
+func (mr *MockStoreMockRecorder) UpdateService(ctx, service interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateService", reflect.TypeOf((*MockStore)(nil).UpdateService), ctx, service)
+}
+
+// UpdateZone mocks base method.
+func (m *MockStore) UpdateZone(ctx context.Context, zone *zones.Zone) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "UpdateZone", ctx, zone)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// UpdateZone indicates an expected call of UpdateZone.
+func (mr *MockStoreMockRecorder) UpdateZone(ctx, zone interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateZone", reflect.TypeOf((*MockStore)(nil).UpdateZone), ctx, zone)
+}
diff --git a/management/server/types/account.go b/management/server/types/account.go
index 6937b7e83..3208cc89a 100644
--- a/management/server/types/account.go
+++ b/management/server/types/account.go
@@ -374,74 +374,6 @@ func (a *Account) GetPeerNetworkMap(
return nm
}
-// GetProxyConnectionResources returns ACL peers for the proxy-embedded peer based on exposed services.
-// No firewall rules are generated here; the proxy peer is always a new on-demand client with a stateful
-// firewall, so OUT rules are unnecessary. Inbound rules are handled on the target/router peer side.
-func (a *Account) GetProxyConnectionResources(ctx context.Context, exposedServices map[string][]*reverseproxy.Service) []*nbpeer.Peer {
- var aclPeers []*nbpeer.Peer
-
- for _, peerServices := range exposedServices {
- for _, service := range peerServices {
- if !service.Enabled {
- continue
- }
- for _, target := range service.Targets {
- if !target.Enabled {
- continue
- }
- if target.TargetType == reverseproxy.TargetTypePeer {
- tpeer := a.GetPeer(target.TargetId)
- if tpeer == nil {
- continue
- }
- aclPeers = append(aclPeers, tpeer)
- }
- }
- }
- }
-
- return aclPeers
-}
-
-// GetPeerProxyResources returns ACL peers and inbound firewall rules for a peer that is targeted by reverse proxy services.
-// Only IN rules are generated; OUT rules are omitted since proxy peers are always new clients with stateful firewalls.
-// Rules use PortRange only (not the legacy Port field) as this feature only targets current peer versions.
-func (a *Account) GetPeerProxyResources(peerID string, services []*reverseproxy.Service, proxyPeers []*nbpeer.Peer) ([]*nbpeer.Peer, []*FirewallRule) {
- var aclPeers []*nbpeer.Peer
- var firewallRules []*FirewallRule
-
- for _, service := range services {
- if !service.Enabled {
- continue
- }
- for _, target := range service.Targets {
- if !target.Enabled {
- continue
- }
-
- aclPeers = proxyPeers
-
- needsPeerRules := (target.TargetType == reverseproxy.TargetTypePeer && target.TargetId == peerID) ||
- (target.TargetType == reverseproxy.TargetTypeHost || target.TargetType == reverseproxy.TargetTypeSubnet || target.TargetType == reverseproxy.TargetTypeDomain)
-
- if needsPeerRules {
- for _, proxyPeer := range proxyPeers {
- firewallRules = append(firewallRules, &FirewallRule{
- PolicyID: "proxy-" + service.ID,
- PeerIP: proxyPeer.IP.String(),
- Direction: FirewallRuleDirectionIN,
- Action: "allow",
- Protocol: string(PolicyRuleProtocolTCP),
- PortRange: RulePortRange{Start: uint16(target.Port), End: uint16(target.Port)},
- })
- }
- }
- }
- }
-
- return aclPeers, firewallRules
-}
-
func (a *Account) addNetworksRoutingPeers(
networkResourcesRoutes []*route.Route,
peer *nbpeer.Peer,
@@ -1864,71 +1796,6 @@ func (a *Account) GetProxyPeers() map[string][]*nbpeer.Peer {
return proxyPeers
}
-func (a *Account) GetPeerProxyRoutes(ctx context.Context, peer *nbpeer.Peer, proxies map[string][]*reverseproxy.Service, resourcesMap map[string]*resourceTypes.NetworkResource, routers map[string]map[string]*routerTypes.NetworkRouter, proxyPeers []*nbpeer.Peer) ([]*route.Route, []*RouteFirewallRule, []*nbpeer.Peer) {
- sourceRanges := make([]string, 0, len(proxyPeers))
- for _, proxyPeer := range proxyPeers {
- sourceRanges = append(sourceRanges, fmt.Sprintf(AllowedIPsFormat, proxyPeer.IP))
- }
- peers := make(map[string]*nbpeer.Peer, len(resourcesMap))
-
- var routes []*route.Route
- var firewallRules []*RouteFirewallRule
- for _, proxyPerResource := range proxies {
- for _, proxy := range proxyPerResource {
- for _, target := range proxy.Targets {
- if target.TargetType == reverseproxy.TargetTypeHost || target.TargetType == reverseproxy.TargetTypeSubnet || target.TargetType == reverseproxy.TargetTypeDomain {
- resource, ok := resourcesMap[target.TargetId]
- if !ok {
- log.WithContext(ctx).Warnf("proxy target %s not found in resources map", target.TargetId)
- continue
- }
- networkRouters, ok := routers[resource.NetworkID]
- if !ok {
- log.WithContext(ctx).Warnf("proxy target %s not found in routers map", target.TargetId)
- continue
- }
- for peerID, router := range networkRouters {
- routePeer := a.GetPeer(peerID)
- route := resource.ToRoute(routePeer, router)
- routes = append(routes, route)
- rule := RouteFirewallRule{
- PolicyID: fmt.Sprintf("proxy-%s-%s", proxy.ID, route.ID),
- RouteID: route.ID,
- SourceRanges: sourceRanges,
- Action: string(PolicyTrafficActionAccept),
- Destination: route.Network.String(),
- Protocol: string(PolicyRuleProtocolTCP),
- Domains: route.Domains,
- IsDynamic: route.IsDynamic(),
- PortRange: RulePortRange{
- Start: uint16(target.Port),
- End: uint16(target.Port),
- },
- }
- firewallRules = append(firewallRules, &rule)
- peers[peerID] = routePeer
- }
- }
- }
- }
- }
-
- resultPeers := make([]*nbpeer.Peer, 0, len(peers))
- for _, peer := range peers {
- resultPeers = append(resultPeers, peer)
- }
-
- return routes, firewallRules, resultPeers
-}
-
-func (a *Account) GetResourcesMap() map[string]*resourceTypes.NetworkResource {
- resourcesMap := make(map[string]*resourceTypes.NetworkResource, len(a.NetworkResources))
- for _, resource := range a.NetworkResources {
- resourcesMap[resource.ID] = resource
- }
- return resourcesMap
-}
-
func (a *Account) InjectProxyPolicies(ctx context.Context) {
if len(a.Services) == 0 {
return
@@ -1943,62 +1810,83 @@ func (a *Account) InjectProxyPolicies(ctx context.Context) {
if !service.Enabled {
continue
}
- for _, target := range service.Targets {
- if !target.Enabled {
- continue
- }
+ a.injectServiceProxyPolicies(ctx, service, proxyPeersByCluster)
+ }
+}
- for _, proxyPeer := range proxyPeersByCluster[service.ProxyCluster] {
- port := target.Port
- if port == 0 {
- switch target.Protocol {
- case "https":
- port = 443
- case "http":
- port = 80
- default:
- log.WithContext(ctx).Warnf("unsupported protocol %s for proxy target %s, skipping policy injection", target.Protocol, target.TargetId)
- continue
- }
- }
-
- path := ""
- if target.Path != nil {
- path = *target.Path
- }
- policyID := fmt.Sprintf("proxy-access-%s-%s-%s", service.ID, proxyPeer.ID, path)
- a.Policies = append(a.Policies, &Policy{
- ID: policyID,
- Name: fmt.Sprintf("Proxy Access to %s", service.Name),
- Enabled: true,
- Rules: []*PolicyRule{
- {
- ID: policyID,
- PolicyID: policyID,
- Name: fmt.Sprintf("Allow access to %s", service.Name),
- Enabled: true,
- SourceResource: Resource{
- ID: proxyPeer.ID,
- Type: ResourceTypePeer,
- },
- DestinationResource: Resource{
- ID: target.TargetId,
- Type: ResourceType(target.TargetType),
- },
- Bidirectional: false,
- Protocol: PolicyRuleProtocolTCP,
- Action: PolicyTrafficActionAccept,
- PortRanges: []RulePortRange{
- {
- Start: uint16(port),
- End: uint16(port),
- },
- },
- },
- },
- })
- }
+func (a *Account) injectServiceProxyPolicies(ctx context.Context, service *reverseproxy.Service, proxyPeersByCluster map[string][]*nbpeer.Peer) {
+ for _, target := range service.Targets {
+ if !target.Enabled {
+ continue
}
+ a.injectTargetProxyPolicies(ctx, service, target, proxyPeersByCluster[service.ProxyCluster])
+ }
+}
+
+func (a *Account) injectTargetProxyPolicies(ctx context.Context, service *reverseproxy.Service, target *reverseproxy.Target, proxyPeers []*nbpeer.Peer) {
+ port, ok := a.resolveTargetPort(ctx, target)
+ if !ok {
+ return
+ }
+
+ path := ""
+ if target.Path != nil {
+ path = *target.Path
+ }
+
+ for _, proxyPeer := range proxyPeers {
+ policy := a.createProxyPolicy(service, target, proxyPeer, port, path)
+ a.Policies = append(a.Policies, policy)
+ }
+}
+
+func (a *Account) resolveTargetPort(ctx context.Context, target *reverseproxy.Target) (int, bool) {
+ if target.Port != 0 {
+ return target.Port, true
+ }
+
+ switch target.Protocol {
+ case "https":
+ return 443, true
+ case "http":
+ return 80, true
+ default:
+ log.WithContext(ctx).Warnf("unsupported protocol %s for proxy target %s, skipping policy injection", target.Protocol, target.TargetId)
+ return 0, false
+ }
+}
+
+func (a *Account) createProxyPolicy(service *reverseproxy.Service, target *reverseproxy.Target, proxyPeer *nbpeer.Peer, port int, path string) *Policy {
+ policyID := fmt.Sprintf("proxy-access-%s-%s-%s", service.ID, proxyPeer.ID, path)
+ return &Policy{
+ ID: policyID,
+ Name: fmt.Sprintf("Proxy Access to %s", service.Name),
+ Enabled: true,
+ Rules: []*PolicyRule{
+ {
+ ID: policyID,
+ PolicyID: policyID,
+ Name: fmt.Sprintf("Allow access to %s", service.Name),
+ Enabled: true,
+ SourceResource: Resource{
+ ID: proxyPeer.ID,
+ Type: ResourceTypePeer,
+ },
+ DestinationResource: Resource{
+ ID: target.TargetId,
+ Type: ResourceType(target.TargetType),
+ },
+ Bidirectional: false,
+ Protocol: PolicyRuleProtocolTCP,
+ Action: PolicyTrafficActionAccept,
+ PortRanges: []RulePortRange{
+ {
+ Start: uint16(port),
+ End: uint16(port),
+ },
+ },
+ },
+ },
}
}
diff --git a/proxy/cmd/proxy/cmd/root.go b/proxy/cmd/proxy/cmd/root.go
index 00f41aa50..e6593ade5 100644
--- a/proxy/cmd/proxy/cmd/root.go
+++ b/proxy/cmd/proxy/cmd/root.go
@@ -39,10 +39,10 @@ var (
addr string
proxyDomain string
certDir string
- acmeCerts bool
- acmeAddr string
- acmeDir string
- acmeChallengeType string
+ acmeCerts bool
+ acmeAddr string
+ acmeDir string
+ acmeChallengeType string
debugEndpoint bool
debugEndpointAddr string
healthAddr string
@@ -123,7 +123,7 @@ func runServer(cmd *cobra.Command, args []string) error {
_ = util.InitLogger(logger, level, util.LogConsole)
- log.Infof("configured log level: %s", level)
+ logger.Infof("configured log level: %s", level)
switch forwardedProto {
case "auto", "http", "https":
@@ -171,7 +171,7 @@ func runServer(cmd *cobra.Command, args []string) error {
defer stop()
if err := srv.ListenAndServe(ctx, addr); err != nil {
- log.Error(err)
+ logger.Error(err)
return err
}
return nil
diff --git a/proxy/internal/acme/locker.go b/proxy/internal/acme/locker.go
index 1ab330603..2f0f18885 100644
--- a/proxy/internal/acme/locker.go
+++ b/proxy/internal/acme/locker.go
@@ -84,7 +84,7 @@ func (l *flockLocker) Lock(ctx context.Context, domain string) (func(), error) {
// nil lockFile means locking is not supported (non-unix).
if lockFile == nil {
- return func() {}, nil
+ return func() { /* no-op: locking unsupported on this platform */ }, nil
}
return func() {
@@ -98,5 +98,5 @@ type noopLocker struct{}
// Lock is a no-op that always succeeds immediately.
func (noopLocker) Lock(context.Context, string) (func(), error) {
- return func() {}, nil
+ return func() { /* no-op: locker disabled */ }, nil
}
diff --git a/proxy/internal/auth/middleware.go b/proxy/internal/auth/middleware.go
index b6cae365b..8a966faa3 100644
--- a/proxy/internal/auth/middleware.go
+++ b/proxy/internal/auth/middleware.go
@@ -90,10 +90,8 @@ func (mw *Middleware) Protect(next http.Handler) http.Handler {
if err != nil {
host = r.Host
}
- mw.domainsMux.RLock()
- config, exists := mw.domains[host]
- mw.domainsMux.RUnlock()
+ config, exists := mw.getDomainConfig(host)
mw.logger.Debugf("checking authentication for host: %s, exists: %t", host, exists)
// Domains that are not configured here or have no authentication schemes applied should simply pass through.
@@ -103,115 +101,160 @@ func (mw *Middleware) Protect(next http.Handler) http.Handler {
}
// Set account and service IDs in captured data for access logging.
- if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
- cd.SetAccountId(types.AccountID(config.AccountID))
- cd.SetServiceId(config.ServiceID)
- }
+ setCapturedIDs(r, config)
- // Check for error from OAuth callback (e.g., access denied)
- if errCode := r.URL.Query().Get("error"); errCode != "" {
- var requestID string
- if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
- cd.SetOrigin(proxy.OriginAuth)
- cd.SetAuthMethod(auth.MethodOIDC.String())
- requestID = cd.GetRequestID()
- }
- errDesc := r.URL.Query().Get("error_description")
- if errDesc == "" {
- errDesc = "An error occurred during authentication"
- }
- web.ServeAccessDeniedPage(w, r, http.StatusForbidden, "Access Denied", errDesc, requestID)
+ if mw.handleOAuthCallbackError(w, r) {
return
}
- // Check for an existing session cookie (contains JWT)
- if cookie, err := r.Cookie(auth.SessionCookieName); err == nil {
- if userID, method, err := auth.ValidateSessionJWT(cookie.Value, host, config.SessionPublicKey); err == nil {
- if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
- cd.SetUserID(userID)
- cd.SetAuthMethod(method)
- }
- next.ServeHTTP(w, r)
- return
- }
+ if mw.forwardWithSessionCookie(w, r, host, config, next) {
+ return
}
- // Try to authenticate with each scheme.
- methods := make(map[string]string)
- var attemptedMethod string
- for _, scheme := range config.Schemes {
- token, promptData, err := scheme.Authenticate(r)
- if err != nil {
- mw.logger.WithField("scheme", scheme.Type().String()).Warnf("authentication infrastructure error: %v", err)
- if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
- cd.SetOrigin(proxy.OriginAuth)
- }
- http.Error(w, "authentication service unavailable", http.StatusBadGateway)
- return
+ mw.authenticateWithSchemes(w, r, host, config)
+ })
+}
+
+func (mw *Middleware) getDomainConfig(host string) (DomainConfig, bool) {
+ mw.domainsMux.RLock()
+ defer mw.domainsMux.RUnlock()
+ config, exists := mw.domains[host]
+ return config, exists
+}
+
+func setCapturedIDs(r *http.Request, config DomainConfig) {
+ if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
+ cd.SetAccountId(types.AccountID(config.AccountID))
+ cd.SetServiceId(config.ServiceID)
+ }
+}
+
+// handleOAuthCallbackError checks for error query parameters from an OAuth
+// callback and renders the access denied page if present.
+func (mw *Middleware) handleOAuthCallbackError(w http.ResponseWriter, r *http.Request) bool {
+ errCode := r.URL.Query().Get("error")
+ if errCode == "" {
+ return false
+ }
+
+ var requestID string
+ if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
+ cd.SetOrigin(proxy.OriginAuth)
+ cd.SetAuthMethod(auth.MethodOIDC.String())
+ requestID = cd.GetRequestID()
+ }
+ errDesc := r.URL.Query().Get("error_description")
+ if errDesc == "" {
+ errDesc = "An error occurred during authentication"
+ }
+ web.ServeAccessDeniedPage(w, r, http.StatusForbidden, "Access Denied", errDesc, requestID)
+ return true
+}
+
+// forwardWithSessionCookie checks for a valid session cookie and, if found,
+// sets the user identity on the request context and forwards to the next handler.
+func (mw *Middleware) forwardWithSessionCookie(w http.ResponseWriter, r *http.Request, host string, config DomainConfig, next http.Handler) bool {
+ cookie, err := r.Cookie(auth.SessionCookieName)
+ if err != nil {
+ return false
+ }
+ userID, method, err := auth.ValidateSessionJWT(cookie.Value, host, config.SessionPublicKey)
+ if err != nil {
+ return false
+ }
+ if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
+ cd.SetUserID(userID)
+ cd.SetAuthMethod(method)
+ }
+ next.ServeHTTP(w, r)
+ return true
+}
+
+// authenticateWithSchemes tries each configured auth scheme in order.
+// On success it sets a session cookie and redirects; on failure it renders the login page.
+func (mw *Middleware) authenticateWithSchemes(w http.ResponseWriter, r *http.Request, host string, config DomainConfig) {
+ methods := make(map[string]string)
+ var attemptedMethod string
+
+ for _, scheme := range config.Schemes {
+ token, promptData, err := scheme.Authenticate(r)
+ if err != nil {
+ mw.logger.WithField("scheme", scheme.Type().String()).Warnf("authentication infrastructure error: %v", err)
+ if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
+ cd.SetOrigin(proxy.OriginAuth)
}
-
- // Track if credentials were submitted but auth failed
- if token == "" && wasCredentialSubmitted(r, scheme.Type()) {
- attemptedMethod = scheme.Type().String()
- }
-
- if token != "" {
- result, err := mw.validateSessionToken(r.Context(), host, token, config.SessionPublicKey, scheme.Type())
- if err != nil {
- if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
- cd.SetOrigin(proxy.OriginAuth)
- cd.SetAuthMethod(scheme.Type().String())
- }
- http.Error(w, err.Error(), http.StatusBadRequest)
- return
- }
- if !result.Valid {
- var requestID string
- if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
- cd.SetOrigin(proxy.OriginAuth)
- cd.SetUserID(result.UserID)
- cd.SetAuthMethod(scheme.Type().String())
- requestID = cd.GetRequestID()
- }
- web.ServeAccessDeniedPage(w, r, http.StatusForbidden, "Access Denied", "You are not authorized to access this service", requestID)
- return
- }
-
- expiration := config.SessionExpiration
- if expiration == 0 {
- expiration = auth.DefaultSessionExpiry
- }
- http.SetCookie(w, &http.Cookie{
- Name: auth.SessionCookieName,
- Value: token,
- HttpOnly: true,
- Secure: true,
- SameSite: http.SameSiteLaxMode,
- MaxAge: int(expiration.Seconds()),
- })
-
- // Redirect instead of forwarding the auth POST to the backend.
- // The browser will follow with a GET carrying the new session cookie.
- if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
- cd.SetOrigin(proxy.OriginAuth)
- cd.SetUserID(result.UserID)
- cd.SetAuthMethod(scheme.Type().String())
- }
- redirectURL := stripSessionTokenParam(r.URL)
- http.Redirect(w, r, redirectURL, http.StatusSeeOther)
- return
- }
- methods[scheme.Type().String()] = promptData
+ http.Error(w, "authentication service unavailable", http.StatusBadGateway)
+ return
}
+ // Track if credentials were submitted but auth failed
+ if token == "" && wasCredentialSubmitted(r, scheme.Type()) {
+ attemptedMethod = scheme.Type().String()
+ }
+
+ if token != "" {
+ mw.handleAuthenticatedToken(w, r, host, token, config, scheme)
+ return
+ }
+ methods[scheme.Type().String()] = promptData
+ }
+
+ if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
+ cd.SetOrigin(proxy.OriginAuth)
+ if attemptedMethod != "" {
+ cd.SetAuthMethod(attemptedMethod)
+ }
+ }
+ web.ServeHTTP(w, r, map[string]any{"methods": methods}, http.StatusUnauthorized)
+}
+
+// handleAuthenticatedToken validates the token, handles denied access, and on
+// success sets a session cookie and redirects to the original URL.
+func (mw *Middleware) handleAuthenticatedToken(w http.ResponseWriter, r *http.Request, host, token string, config DomainConfig, scheme Scheme) {
+ result, err := mw.validateSessionToken(r.Context(), host, token, config.SessionPublicKey, scheme.Type())
+ if err != nil {
if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
cd.SetOrigin(proxy.OriginAuth)
- if attemptedMethod != "" {
- cd.SetAuthMethod(attemptedMethod)
- }
+ cd.SetAuthMethod(scheme.Type().String())
}
- web.ServeHTTP(w, r, map[string]any{"methods": methods}, http.StatusUnauthorized)
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ if !result.Valid {
+ var requestID string
+ if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
+ cd.SetOrigin(proxy.OriginAuth)
+ cd.SetUserID(result.UserID)
+ cd.SetAuthMethod(scheme.Type().String())
+ requestID = cd.GetRequestID()
+ }
+ web.ServeAccessDeniedPage(w, r, http.StatusForbidden, "Access Denied", "You are not authorized to access this service", requestID)
+ return
+ }
+
+ expiration := config.SessionExpiration
+ if expiration == 0 {
+ expiration = auth.DefaultSessionExpiry
+ }
+ http.SetCookie(w, &http.Cookie{
+ Name: auth.SessionCookieName,
+ Value: token,
+ HttpOnly: true,
+ Secure: true,
+ SameSite: http.SameSiteLaxMode,
+ MaxAge: int(expiration.Seconds()),
})
+
+ // Redirect instead of forwarding the auth POST to the backend.
+ // The browser will follow with a GET carrying the new session cookie.
+ if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
+ cd.SetOrigin(proxy.OriginAuth)
+ cd.SetUserID(result.UserID)
+ cd.SetAuthMethod(scheme.Type().String())
+ }
+ redirectURL := stripSessionTokenParam(r.URL)
+ http.Redirect(w, r, redirectURL, http.StatusSeeOther)
}
// wasCredentialSubmitted checks if credentials were submitted for the given auth method.
diff --git a/proxy/internal/debug/client.go b/proxy/internal/debug/client.go
index f3b0f0e97..885c574bc 100644
--- a/proxy/internal/debug/client.go
+++ b/proxy/internal/debug/client.go
@@ -83,6 +83,10 @@ func (c *Client) printHealth(data map[string]any) {
}
}
+ c.printHealthClients(data)
+}
+
+func (c *Client) printHealthClients(data map[string]any) {
clients, ok := data["clients"].(map[string]any)
if !ok || len(clients) == 0 {
return
diff --git a/proxy/internal/debug/client_test.go b/proxy/internal/debug/client_test.go
new file mode 100644
index 000000000..0d627a94e
--- /dev/null
+++ b/proxy/internal/debug/client_test.go
@@ -0,0 +1,71 @@
+package debug
+
+import (
+ "bytes"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPrintHealth_WithCertsAndClients(t *testing.T) {
+ var buf bytes.Buffer
+ c := NewClient("localhost:8444", false, &buf)
+
+ data := map[string]any{
+ "status": "ok",
+ "uptime": "1h30m",
+ "management_connected": true,
+ "all_clients_healthy": true,
+ "certs_total": float64(3),
+ "certs_ready": float64(2),
+ "certs_pending": float64(1),
+ "certs_failed": float64(0),
+ "certs_ready_domains": []any{"a.example.com", "b.example.com"},
+ "certs_pending_domains": []any{"c.example.com"},
+ "clients": map[string]any{
+ "acc-1": map[string]any{
+ "healthy": true,
+ "management_connected": true,
+ "signal_connected": true,
+ "relays_connected": float64(1),
+ "relays_total": float64(2),
+ "peers_connected": float64(3),
+ "peers_total": float64(5),
+ "peers_p2p": float64(2),
+ "peers_relayed": float64(1),
+ "peers_degraded": float64(0),
+ },
+ },
+ }
+
+ c.printHealth(data)
+ out := buf.String()
+
+ assert.Contains(t, out, "Status: ok")
+ assert.Contains(t, out, "Uptime: 1h30m")
+ assert.Contains(t, out, "yes") // management_connected
+ assert.Contains(t, out, "2 ready, 1 pending, 0 failed (3 total)")
+ assert.Contains(t, out, "a.example.com")
+ assert.Contains(t, out, "c.example.com")
+ assert.Contains(t, out, "acc-1")
+}
+
+func TestPrintHealth_Minimal(t *testing.T) {
+ var buf bytes.Buffer
+ c := NewClient("localhost:8444", false, &buf)
+
+ data := map[string]any{
+ "status": "ok",
+ "uptime": "5m",
+ "management_connected": false,
+ "all_clients_healthy": false,
+ }
+
+ c.printHealth(data)
+ out := buf.String()
+
+ assert.Contains(t, out, "Status: ok")
+ assert.Contains(t, out, "Uptime: 5m")
+ assert.NotContains(t, out, "Certificates")
+ assert.NotContains(t, out, "ACCOUNT ID")
+}
diff --git a/proxy/internal/health/health.go b/proxy/internal/health/health.go
index ac5061a23..60ce7f8ef 100644
--- a/proxy/internal/health/health.go
+++ b/proxy/internal/health/health.go
@@ -323,7 +323,7 @@ func NewServer(addr string, checker *Checker, logger *log.Logger, metricsHandler
if metricsHandler != nil {
mux := http.NewServeMux()
mux.Handle("/metrics", metricsHandler)
- mux.Handle("/", checker.Handler())
+ mux.Handle("/", handler)
handler = mux
}
diff --git a/proxy/internal/health/health_test.go b/proxy/internal/health/health_test.go
index ddc27beb0..47b5f250f 100644
--- a/proxy/internal/health/health_test.go
+++ b/proxy/internal/health/health_test.go
@@ -404,3 +404,70 @@ func TestChecker_Handler_Full(t *testing.T) {
// Clients may be empty map when no clients exist.
assert.Empty(t, resp.Clients)
}
+
+func TestChecker_SetShuttingDown(t *testing.T) {
+ checker := NewChecker(nil, &mockClientProvider{})
+ checker.SetManagementConnected(true)
+
+ assert.True(t, checker.ReadinessProbe(), "should be ready before shutdown")
+
+ checker.SetShuttingDown()
+
+ assert.False(t, checker.ReadinessProbe(), "should not be ready after shutdown")
+}
+
+func TestChecker_Handler_Readiness_ShuttingDown(t *testing.T) {
+ checker := NewChecker(nil, &mockClientProvider{})
+ checker.SetManagementConnected(true)
+ checker.SetShuttingDown()
+ handler := checker.Handler()
+
+ req := httptest.NewRequest(http.MethodGet, "/healthz/ready", nil)
+ rec := httptest.NewRecorder()
+ handler.ServeHTTP(rec, req)
+
+ assert.Equal(t, http.StatusServiceUnavailable, rec.Code)
+
+ var resp ProbeResponse
+ require.NoError(t, json.NewDecoder(rec.Body).Decode(&resp))
+ assert.Equal(t, "fail", resp.Status)
+}
+
+func TestNewServer_WithMetricsHandler(t *testing.T) {
+ checker := NewChecker(nil, &mockClientProvider{})
+ checker.SetManagementConnected(true)
+
+ metricsHandler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
+ w.WriteHeader(http.StatusOK)
+ _, _ = w.Write([]byte("metrics"))
+ })
+
+ srv := NewServer(":0", checker, nil, metricsHandler)
+ require.NotNil(t, srv)
+
+ // Verify health endpoint still works through the mux.
+ req := httptest.NewRequest(http.MethodGet, "/healthz/live", nil)
+ rec := httptest.NewRecorder()
+ srv.server.Handler.ServeHTTP(rec, req)
+ assert.Equal(t, http.StatusOK, rec.Code)
+
+ // Verify metrics endpoint is mounted.
+ req = httptest.NewRequest(http.MethodGet, "/metrics", nil)
+ rec = httptest.NewRecorder()
+ srv.server.Handler.ServeHTTP(rec, req)
+ assert.Equal(t, http.StatusOK, rec.Code)
+ assert.Equal(t, "metrics", rec.Body.String())
+}
+
+func TestNewServer_WithoutMetricsHandler(t *testing.T) {
+ checker := NewChecker(nil, &mockClientProvider{})
+ checker.SetManagementConnected(true)
+
+ srv := NewServer(":0", checker, nil, nil)
+ require.NotNil(t, srv)
+
+ req := httptest.NewRequest(http.MethodGet, "/healthz/live", nil)
+ rec := httptest.NewRecorder()
+ srv.server.Handler.ServeHTTP(rec, req)
+ assert.Equal(t, http.StatusOK, rec.Code)
+}
diff --git a/proxy/internal/proxy/reverseproxy.go b/proxy/internal/proxy/reverseproxy.go
index 2e601e231..e8bd804ba 100644
--- a/proxy/internal/proxy/reverseproxy.go
+++ b/proxy/internal/proxy/reverseproxy.go
@@ -320,7 +320,8 @@ func getRequestID(r *http.Request) string {
// status code, and component status based on the error type.
func classifyProxyError(err error) (title, message string, code int, status web.ErrorStatus) {
switch {
- case errors.Is(err, context.DeadlineExceeded):
+ case errors.Is(err, context.DeadlineExceeded),
+ isNetTimeout(err):
return "Request Timeout",
"The request timed out while trying to reach the service. Please refresh the page and try again.",
http.StatusGatewayTimeout,
@@ -356,12 +357,6 @@ func classifyProxyError(err error) (title, message string, code int, status web.
"The connection to the peer could not be established. Please ensure the peer is running and connected to the NetBird network.",
http.StatusBadGateway,
web.ErrorStatus{Proxy: true, Destination: false}
-
- case isNetTimeout(err):
- return "Request Timeout",
- "The request timed out while trying to reach the service. Please refresh the page and try again.",
- http.StatusGatewayTimeout,
- web.ErrorStatus{Proxy: true, Destination: false}
}
return "Connection Error",
diff --git a/proxy/internal/roundtrip/netbird.go b/proxy/internal/roundtrip/netbird.go
index c32e6ee0c..00531a25c 100644
--- a/proxy/internal/roundtrip/netbird.go
+++ b/proxy/internal/roundtrip/netbird.go
@@ -38,6 +38,11 @@ type domainInfo struct {
serviceID string
}
+type domainNotification struct {
+ domain domain.Domain
+ serviceID string
+}
+
// clientEntry holds an embedded NetBird client and tracks which domains use it.
type clientEntry struct {
client *embed.Client
@@ -114,6 +119,30 @@ func (n *NetBird) AddPeer(ctx context.Context, accountID types.AccountID, d doma
return nil
}
+ entry, err := n.createClientEntry(ctx, accountID, d, authToken, serviceID)
+ if err != nil {
+ n.clientsMux.Unlock()
+ return err
+ }
+
+ n.clients[accountID] = entry
+ n.clientsMux.Unlock()
+
+ n.logger.WithFields(log.Fields{
+ "account_id": accountID,
+ "domain": d,
+ }).Info("created new client for account")
+
+ // Attempt to start the client in the background; if this fails we will
+ // retry on the first request via RoundTrip.
+ go n.runClientStartup(ctx, accountID, entry.client)
+
+ return nil
+}
+
+// createClientEntry generates a WireGuard keypair, authenticates with management,
+// and creates an embedded NetBird client. Must be called with clientsMux held.
+func (n *NetBird) createClientEntry(ctx context.Context, accountID types.AccountID, d domain.Domain, authToken, serviceID string) (*clientEntry, error) {
n.logger.WithFields(log.Fields{
"account_id": accountID,
"service_id": serviceID,
@@ -121,8 +150,7 @@ func (n *NetBird) AddPeer(ctx context.Context, accountID types.AccountID, d doma
privateKey, err := wgtypes.GeneratePrivateKey()
if err != nil {
- n.clientsMux.Unlock()
- return fmt.Errorf("generate wireguard private key: %w", err)
+ return nil, fmt.Errorf("generate wireguard private key: %w", err)
}
publicKey := privateKey.PublicKey()
@@ -132,7 +160,6 @@ func (n *NetBird) AddPeer(ctx context.Context, accountID types.AccountID, d doma
"public_key": publicKey.String(),
}).Debug("authenticating new proxy peer with management")
- // Authenticate with management using the one-time token and send public key
resp, err := n.mgmtClient.CreateProxyPeer(ctx, &proto.CreateProxyPeerRequest{
ServiceId: serviceID,
AccountId: string(accountID),
@@ -141,16 +168,14 @@ func (n *NetBird) AddPeer(ctx context.Context, accountID types.AccountID, d doma
Cluster: n.proxyAddr,
})
if err != nil {
- n.clientsMux.Unlock()
- return fmt.Errorf("authenticate proxy peer with management: %w", err)
+ return nil, fmt.Errorf("authenticate proxy peer with management: %w", err)
}
if resp != nil && !resp.GetSuccess() {
- n.clientsMux.Unlock()
errMsg := "unknown error"
if resp.ErrorMessage != nil {
errMsg = *resp.ErrorMessage
}
- return fmt.Errorf("proxy peer authentication failed: %s", errMsg)
+ return nil, fmt.Errorf("proxy peer authentication failed: %s", errMsg)
}
n.logger.WithFields(log.Fields{
@@ -176,14 +201,13 @@ func (n *NetBird) AddPeer(ctx context.Context, accountID types.AccountID, d doma
WireguardPort: &n.wgPort,
})
if err != nil {
- n.clientsMux.Unlock()
- return fmt.Errorf("create netbird client: %w", err)
+ return nil, fmt.Errorf("create netbird client: %w", err)
}
// Create a transport using the client dialer. We do this instead of using
// the client's HTTPClient to avoid issues with request validation that do
// not work with reverse proxied requests.
- entry = &clientEntry{
+ return &clientEntry{
client: client,
domains: map[domain.Domain]domainInfo{d: {serviceID: serviceID}},
transport: &http.Transport{
@@ -196,75 +220,53 @@ func (n *NetBird) AddPeer(ctx context.Context, accountID types.AccountID, d doma
},
createdAt: time.Now(),
started: false,
+ }, nil
+}
+
+// runClientStartup starts the client and notifies registered domains on success.
+func (n *NetBird) runClientStartup(ctx context.Context, accountID types.AccountID, client *embed.Client) {
+ startCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+
+ if err := client.Start(startCtx); err != nil {
+ if errors.Is(err, context.DeadlineExceeded) {
+ n.logger.WithField("account_id", accountID).Warn("netbird client start timed out, will retry on first request")
+ } else {
+ n.logger.WithField("account_id", accountID).WithError(err).Error("failed to start netbird client")
+ }
+ return
+ }
+
+ // Mark client as started and collect domains to notify outside the lock.
+ n.clientsMux.Lock()
+ entry, exists := n.clients[accountID]
+ if exists {
+ entry.started = true
+ }
+ var domainsToNotify []domainNotification
+ if exists {
+ for dom, info := range entry.domains {
+ domainsToNotify = append(domainsToNotify, domainNotification{domain: dom, serviceID: info.serviceID})
+ }
}
- n.clients[accountID] = entry
n.clientsMux.Unlock()
- n.logger.WithFields(log.Fields{
- "account_id": accountID,
- "domain": d,
- }).Info("created new client for account")
-
- // Attempt to start the client in the background, if this fails
- // then it is not ideal, but it isn't the end of the world because
- // we will try to start the client again before we use it.
- go func() {
- startCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
- defer cancel()
-
- if err := client.Start(startCtx); err != nil {
- if errors.Is(err, context.DeadlineExceeded) {
- n.logger.WithFields(log.Fields{
- "account_id": accountID,
- }).Warn("netbird client start timed out, will retry on first request")
- } else {
- n.logger.WithFields(log.Fields{
- "account_id": accountID,
- }).WithError(err).Error("failed to start netbird client")
- }
- return
+ if n.statusNotifier == nil {
+ return
+ }
+ for _, dn := range domainsToNotify {
+ if err := n.statusNotifier.NotifyStatus(ctx, string(accountID), dn.serviceID, string(dn.domain), true); err != nil {
+ n.logger.WithFields(log.Fields{
+ "account_id": accountID,
+ "domain": dn.domain,
+ }).WithError(err).Warn("failed to notify tunnel connection status")
+ } else {
+ n.logger.WithFields(log.Fields{
+ "account_id": accountID,
+ "domain": dn.domain,
+ }).Info("notified management about tunnel connection")
}
-
- // Mark client as started and notify all registered domains
- n.clientsMux.Lock()
- entry, exists := n.clients[accountID]
- if exists {
- entry.started = true
- }
- // Copy domain info while holding lock
- var domainsToNotify []struct {
- domain domain.Domain
- serviceID string
- }
- if exists {
- for dom, info := range entry.domains {
- domainsToNotify = append(domainsToNotify, struct {
- domain domain.Domain
- serviceID string
- }{domain: dom, serviceID: info.serviceID})
- }
- }
- n.clientsMux.Unlock()
-
- // Notify all domains that they're connected
- if n.statusNotifier != nil {
- for _, domInfo := range domainsToNotify {
- if err := n.statusNotifier.NotifyStatus(ctx, string(accountID), domInfo.serviceID, string(domInfo.domain), true); err != nil {
- n.logger.WithFields(log.Fields{
- "account_id": accountID,
- "domain": domInfo.domain,
- }).WithError(err).Warn("failed to notify tunnel connection status")
- } else {
- n.logger.WithFields(log.Fields{
- "account_id": accountID,
- "domain": domInfo.domain,
- }).Info("notified management about tunnel connection")
- }
- }
- }
- }()
-
- return nil
+ }
}
// RemovePeer unregisters a domain from an account. The client is only stopped
diff --git a/proxy/internal/roundtrip/netbird_test.go b/proxy/internal/roundtrip/netbird_test.go
index fb7e7fa01..3e76af9da 100644
--- a/proxy/internal/roundtrip/netbird_test.go
+++ b/proxy/internal/roundtrip/netbird_test.go
@@ -3,6 +3,7 @@ package roundtrip
import (
"context"
"net/http"
+ "sync"
"testing"
"github.com/stretchr/testify/assert"
@@ -20,6 +21,31 @@ func (m *mockMgmtClient) CreateProxyPeer(_ context.Context, _ *proto.CreateProxy
return &proto.CreateProxyPeerResponse{Success: true}, nil
}
+type mockStatusNotifier struct {
+ mu sync.Mutex
+ statuses []statusCall
+}
+
+type statusCall struct {
+ accountID string
+ serviceID string
+ domain string
+ connected bool
+}
+
+func (m *mockStatusNotifier) NotifyStatus(_ context.Context, accountID, serviceID, domain string, connected bool) error {
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ m.statuses = append(m.statuses, statusCall{accountID, serviceID, domain, connected})
+ return nil
+}
+
+func (m *mockStatusNotifier) calls() []statusCall {
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ return append([]statusCall{}, m.statuses...)
+}
+
// mockNetBird creates a NetBird instance for testing without actually connecting.
// It uses an invalid management URL to prevent real connections.
func mockNetBird() *NetBird {
@@ -253,3 +279,50 @@ func TestNetBird_RoundTrip_RequiresExistingClient(t *testing.T) {
assert.Error(t, err)
assert.Contains(t, err.Error(), "no peer connection found for account")
}
+
+func TestNetBird_AddPeer_ExistingStartedClient_NotifiesStatus(t *testing.T) {
+ notifier := &mockStatusNotifier{}
+ nb := NewNetBird("http://invalid.test:9999", "test-proxy", "invalid.test", 0, nil, notifier, &mockMgmtClient{})
+ accountID := types.AccountID("account-1")
+
+ // Add first domain — creates a new client entry.
+ err := nb.AddPeer(context.Background(), accountID, domain.Domain("domain1.test"), "key-1", "svc-1")
+ require.NoError(t, err)
+
+ // Manually mark client as started to simulate background startup completing.
+ nb.clientsMux.Lock()
+ nb.clients[accountID].started = true
+ nb.clientsMux.Unlock()
+
+ // Add second domain — should notify immediately since client is already started.
+ err = nb.AddPeer(context.Background(), accountID, domain.Domain("domain2.test"), "key-1", "svc-2")
+ require.NoError(t, err)
+
+ calls := notifier.calls()
+ require.Len(t, calls, 1)
+ assert.Equal(t, string(accountID), calls[0].accountID)
+ assert.Equal(t, "svc-2", calls[0].serviceID)
+ assert.Equal(t, "domain2.test", calls[0].domain)
+ assert.True(t, calls[0].connected)
+}
+
+func TestNetBird_RemovePeer_NotifiesDisconnection(t *testing.T) {
+ notifier := &mockStatusNotifier{}
+ nb := NewNetBird("http://invalid.test:9999", "test-proxy", "invalid.test", 0, nil, notifier, &mockMgmtClient{})
+ accountID := types.AccountID("account-1")
+
+ err := nb.AddPeer(context.Background(), accountID, domain.Domain("domain1.test"), "key-1", "svc-1")
+ require.NoError(t, err)
+ err = nb.AddPeer(context.Background(), accountID, domain.Domain("domain2.test"), "key-1", "svc-2")
+ require.NoError(t, err)
+
+ // Remove one domain — client stays, but disconnection notification fires.
+ err = nb.RemovePeer(context.Background(), accountID, "domain1.test")
+ require.NoError(t, err)
+ assert.True(t, nb.HasClient(accountID))
+
+ calls := notifier.calls()
+ require.Len(t, calls, 1)
+ assert.Equal(t, "domain1.test", calls[0].domain)
+ assert.False(t, calls[0].connected)
+}
diff --git a/proxy/server.go b/proxy/server.go
index 3de8bd24c..c1be69529 100644
--- a/proxy/server.go
+++ b/proxy/server.go
@@ -157,41 +157,9 @@ func (s *Server) ListenAndServe(ctx context.Context, addr string) (err error) {
reg := prometheus.NewRegistry()
s.meter = metrics.New(reg)
- // The very first thing to do should be to connect to the Management server.
- // Without this connection, the Proxy cannot do anything.
- mgmtURL, err := url.Parse(s.ManagementAddress)
+ mgmtConn, err := s.dialManagement()
if err != nil {
- return fmt.Errorf("parse management address: %w", err)
- }
- creds := insecure.NewCredentials()
- // Simple TLS check using management URL.
- // Assume management TLS is enabled for gRPC as well if using HTTPS for the API.
- if mgmtURL.Scheme == "https" {
- certPool, err := x509.SystemCertPool()
- if err != nil || certPool == nil {
- // Fall back to embedded CAs if no OS-provided ones are available.
- certPool = embeddedroots.Get()
- }
-
- creds = credentials.NewTLS(&tls.Config{
- RootCAs: certPool,
- })
- }
- s.Logger.WithFields(log.Fields{
- "gRPC_address": mgmtURL.Host,
- "TLS_enabled": mgmtURL.Scheme == "https",
- }).Debug("starting management gRPC client")
- mgmtConn, err := grpc.NewClient(mgmtURL.Host,
- grpc.WithTransportCredentials(creds),
- grpc.WithKeepaliveParams(keepalive.ClientParameters{
- Time: 20 * time.Second,
- Timeout: 10 * time.Second,
- PermitWithoutStream: true,
- }),
- proxygrpc.WithProxyToken(s.ProxyToken),
- )
- if err != nil {
- return fmt.Errorf("could not create management connection: %w", err)
+ return err
}
defer func() {
if err := mgmtConn.Close(); err != nil {
@@ -205,54 +173,9 @@ func (s *Server) ListenAndServe(ctx context.Context, addr string) (err error) {
// to proxy over.
s.netbird = roundtrip.NewNetBird(s.ManagementAddress, s.ID, s.ProxyURL, s.WireguardPort, s.Logger, s, s.mgmtClient)
- // When generating ACME certificates, start a challenge server.
- tlsConfig := &tls.Config{}
- if s.GenerateACMECertificates {
- // Default to TLS-ALPN-01 challenge if not specified
- if s.ACMEChallengeType == "" {
- s.ACMEChallengeType = "tls-alpn-01"
- }
- s.Logger.WithFields(log.Fields{
- "acme_server": s.ACMEDirectory,
- "challenge_type": s.ACMEChallengeType,
- }).Debug("ACME certificates enabled, configuring certificate manager")
- s.acme = acme.NewManager(s.CertificateDirectory, s.ACMEDirectory, s, s.Logger, s.CertLockMethod)
-
- // Only start HTTP server for HTTP-01 challenge type
- if s.ACMEChallengeType == "http-01" {
- s.http = &http.Server{
- Addr: s.ACMEChallengeAddress,
- Handler: s.acme.HTTPHandler(nil),
- ErrorLog: newHTTPServerLogger(s.Logger, logtagValueACME),
- }
- go func() {
- if err := s.http.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
- s.Logger.WithError(err).Error("ACME HTTP-01 challenge server failed")
- }
- }()
- }
- tlsConfig = s.acme.TLSConfig()
-
- // ServerName needs to be set to allow for ACME to work correctly
- // when using CNAME URLs to access the proxy.
- tlsConfig.ServerName = s.ProxyURL
-
- s.Logger.WithFields(log.Fields{
- "ServerName": s.ProxyURL,
- "challenge_type": s.ACMEChallengeType,
- }).Debug("ACME certificate manager configured")
- } else {
- s.Logger.Debug("ACME certificates disabled, using static certificates with file watching")
- certPath := filepath.Join(s.CertificateDirectory, s.CertificateFile)
- keyPath := filepath.Join(s.CertificateDirectory, s.CertificateKeyFile)
-
- certWatcher, err := certwatch.NewWatcher(certPath, keyPath, s.Logger)
- if err != nil {
- return fmt.Errorf("initialize certificate watcher: %w", err)
- }
- go certWatcher.Watch(ctx)
-
- tlsConfig.GetCertificate = certWatcher.GetCertificate
+ tlsConfig, err := s.configureTLS(ctx)
+ if err != nil {
+ return err
}
// Configure the reverse proxy using NetBird's HTTP Client Transport for proxying.
@@ -343,6 +266,92 @@ const (
shutdownServiceTimeout = 5 * time.Second
)
+func (s *Server) dialManagement() (*grpc.ClientConn, error) {
+ mgmtURL, err := url.Parse(s.ManagementAddress)
+ if err != nil {
+ return nil, fmt.Errorf("parse management address: %w", err)
+ }
+ creds := insecure.NewCredentials()
+ // Assume management TLS is enabled for gRPC as well if using HTTPS for the API.
+ if mgmtURL.Scheme == "https" {
+ certPool, err := x509.SystemCertPool()
+ if err != nil || certPool == nil {
+ // Fall back to embedded CAs if no OS-provided ones are available.
+ certPool = embeddedroots.Get()
+ }
+ creds = credentials.NewTLS(&tls.Config{
+ RootCAs: certPool,
+ })
+ }
+ s.Logger.WithFields(log.Fields{
+ "gRPC_address": mgmtURL.Host,
+ "TLS_enabled": mgmtURL.Scheme == "https",
+ }).Debug("starting management gRPC client")
+ conn, err := grpc.NewClient(mgmtURL.Host,
+ grpc.WithTransportCredentials(creds),
+ grpc.WithKeepaliveParams(keepalive.ClientParameters{
+ Time: 20 * time.Second,
+ Timeout: 10 * time.Second,
+ PermitWithoutStream: true,
+ }),
+ proxygrpc.WithProxyToken(s.ProxyToken),
+ )
+ if err != nil {
+ return nil, fmt.Errorf("create management connection: %w", err)
+ }
+ return conn, nil
+}
+
+func (s *Server) configureTLS(ctx context.Context) (*tls.Config, error) {
+ tlsConfig := &tls.Config{}
+ if !s.GenerateACMECertificates {
+ s.Logger.Debug("ACME certificates disabled, using static certificates with file watching")
+ certPath := filepath.Join(s.CertificateDirectory, s.CertificateFile)
+ keyPath := filepath.Join(s.CertificateDirectory, s.CertificateKeyFile)
+
+ certWatcher, err := certwatch.NewWatcher(certPath, keyPath, s.Logger)
+ if err != nil {
+ return nil, fmt.Errorf("initialize certificate watcher: %w", err)
+ }
+ go certWatcher.Watch(ctx)
+ tlsConfig.GetCertificate = certWatcher.GetCertificate
+ return tlsConfig, nil
+ }
+
+ if s.ACMEChallengeType == "" {
+ s.ACMEChallengeType = "tls-alpn-01"
+ }
+ s.Logger.WithFields(log.Fields{
+ "acme_server": s.ACMEDirectory,
+ "challenge_type": s.ACMEChallengeType,
+ }).Debug("ACME certificates enabled, configuring certificate manager")
+ s.acme = acme.NewManager(s.CertificateDirectory, s.ACMEDirectory, s, s.Logger, s.CertLockMethod)
+
+ if s.ACMEChallengeType == "http-01" {
+ s.http = &http.Server{
+ Addr: s.ACMEChallengeAddress,
+ Handler: s.acme.HTTPHandler(nil),
+ ErrorLog: newHTTPServerLogger(s.Logger, logtagValueACME),
+ }
+ go func() {
+ if err := s.http.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
+ s.Logger.WithError(err).Error("ACME HTTP-01 challenge server failed")
+ }
+ }()
+ }
+ tlsConfig = s.acme.TLSConfig()
+
+ // ServerName needs to be set to allow for ACME to work correctly
+ // when using CNAME URLs to access the proxy.
+ tlsConfig.ServerName = s.ProxyURL
+
+ s.Logger.WithFields(log.Fields{
+ "ServerName": s.ProxyURL,
+ "challenge_type": s.ACMEChallengeType,
+ }).Debug("ACME certificate manager configured")
+ return tlsConfig, nil
+}
+
// gracefulShutdown performs a zero-downtime shutdown sequence. It marks the
// readiness probe as failing, waits for load balancer propagation, drains
// in-flight connections, and then stops all background services.
@@ -495,36 +504,7 @@ func (s *Server) handleMappingStream(ctx context.Context, mappingClient proto.Pr
return fmt.Errorf("receive msg: %w", err)
}
s.Logger.Debug("Received mapping update, starting processing")
- // Process msg updates sequentially to avoid conflict, so block
- // additional receiving until this processing is completed.
- for _, mapping := range msg.GetMapping() {
- s.Logger.WithFields(log.Fields{
- "type": mapping.GetType(),
- "domain": mapping.GetDomain(),
- "path": mapping.GetPath(),
- "id": mapping.GetId(),
- }).Debug("Processing mapping update")
- switch mapping.GetType() {
- case proto.ProxyMappingUpdateType_UPDATE_TYPE_CREATED:
- if err := s.addMapping(ctx, mapping); err != nil {
- // TODO: Retry this? Or maybe notify the management server that this mapping has failed?
- s.Logger.WithFields(log.Fields{
- "service_id": mapping.GetId(),
- "domain": mapping.GetDomain(),
- "error": err,
- }).Error("Error adding new mapping, ignoring this mapping and continuing processing")
- }
- case proto.ProxyMappingUpdateType_UPDATE_TYPE_MODIFIED:
- if err := s.updateMapping(ctx, mapping); err != nil {
- s.Logger.WithFields(log.Fields{
- "service_id": mapping.GetId(),
- "domain": mapping.GetDomain(),
- }).Errorf("failed to update mapping: %v", err)
- }
- case proto.ProxyMappingUpdateType_UPDATE_TYPE_REMOVED:
- s.removeMapping(ctx, mapping)
- }
- }
+ s.processMappings(ctx, msg.GetMapping())
s.Logger.Debug("Processing mapping update completed")
if !*initialSyncDone && msg.GetInitialSyncComplete() {
@@ -538,6 +518,37 @@ func (s *Server) handleMappingStream(ctx context.Context, mappingClient proto.Pr
}
}
+func (s *Server) processMappings(ctx context.Context, mappings []*proto.ProxyMapping) {
+ for _, mapping := range mappings {
+ s.Logger.WithFields(log.Fields{
+ "type": mapping.GetType(),
+ "domain": mapping.GetDomain(),
+ "path": mapping.GetPath(),
+ "id": mapping.GetId(),
+ }).Debug("Processing mapping update")
+ switch mapping.GetType() {
+ case proto.ProxyMappingUpdateType_UPDATE_TYPE_CREATED:
+ if err := s.addMapping(ctx, mapping); err != nil {
+ // TODO: Retry this? Or maybe notify the management server that this mapping has failed?
+ s.Logger.WithFields(log.Fields{
+ "service_id": mapping.GetId(),
+ "domain": mapping.GetDomain(),
+ "error": err,
+ }).Error("Error adding new mapping, ignoring this mapping and continuing processing")
+ }
+ case proto.ProxyMappingUpdateType_UPDATE_TYPE_MODIFIED:
+ if err := s.updateMapping(ctx, mapping); err != nil {
+ s.Logger.WithFields(log.Fields{
+ "service_id": mapping.GetId(),
+ "domain": mapping.GetDomain(),
+ }).Errorf("failed to update mapping: %v", err)
+ }
+ case proto.ProxyMappingUpdateType_UPDATE_TYPE_REMOVED:
+ s.removeMapping(ctx, mapping)
+ }
+ }
+}
+
func (s *Server) addMapping(ctx context.Context, mapping *proto.ProxyMapping) error {
d := domain.Domain(mapping.GetDomain())
accountID := types.AccountID(mapping.GetAccountId())