diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 5e552cac..a04c2c43 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -32,7 +32,7 @@ jobs: - name: Build for Linux/macOS x86_64 if: startsWith(matrix.os, 'windows-') != true run: | - go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo + go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo cd tests/eventsearcher go build -trimpath -ldflags "-s -w" -o eventsearcher cd - @@ -44,7 +44,7 @@ jobs: - name: Build for macOS arm64 if: startsWith(matrix.os, 'macos-') == true - run: CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo_arm64 + run: CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo_arm64 - name: Build for Windows if: startsWith(matrix.os, 'windows-') @@ -57,7 +57,7 @@ jobs: $FILE_VERSION = $LATEST_TAG.substring(1) + "." + $COMMITS_FROM_TAG go install github.com/tc-hib/go-winres@latest go-winres simply --arch amd64 --product-version $LATEST_TAG-dev-$GIT_COMMIT --file-version $FILE_VERSION --file-description "SFTPGo server" --product-name SFTPGo --copyright "AGPL-3.0" --original-filename sftpgo.exe --icon .\windows-installer\icon.ico - go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/version.date=$DATE_TIME" -o sftpgo.exe + go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/internal/version.date=$DATE_TIME" -o sftpgo.exe cd tests/eventsearcher go build -trimpath -ldflags "-s -w" -o eventsearcher.exe cd ../.. @@ -69,11 +69,11 @@ jobs: $Env:GOOS='windows' $Env:GOARCH='arm64' go-winres simply --arch arm64 --product-version $LATEST_TAG-dev-$GIT_COMMIT --file-version $FILE_VERSION --file-description "SFTPGo server" --product-name SFTPGo --copyright "AGPL-3.0" --original-filename sftpgo.exe --icon .\windows-installer\icon.ico - go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/version.date=$DATE_TIME" -o .\arm64\sftpgo.exe + go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/internal/version.date=$DATE_TIME" -o .\arm64\sftpgo.exe mkdir x86 $Env:GOARCH='386' go-winres simply --arch 386 --product-version $LATEST_TAG-dev-$GIT_COMMIT --file-version $FILE_VERSION --file-description "SFTPGo server" --product-name SFTPGo --copyright "AGPL-3.0" --original-filename sftpgo.exe --icon .\windows-installer\icon.ico - go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/version.date=$DATE_TIME" -o .\x86\sftpgo.exe + go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/internal/version.date=$DATE_TIME" -o .\x86\sftpgo.exe Remove-Item Env:\CGO_ENABLED Remove-Item Env:\GOOS Remove-Item Env:\GOARCH @@ -90,15 +90,15 @@ jobs: - name: Run test cases using bolt provider run: | - go test -v -p 1 -timeout 2m ./config -covermode=atomic - go test -v -p 1 -timeout 5m ./common -covermode=atomic - go test -v -p 1 -timeout 5m ./httpd -covermode=atomic - go test -v -p 1 -timeout 8m ./sftpd -covermode=atomic - go test -v -p 1 -timeout 5m ./ftpd -covermode=atomic - go test -v -p 1 -timeout 5m ./webdavd -covermode=atomic - go test -v -p 1 -timeout 2m ./telemetry -covermode=atomic - go test -v -p 1 -timeout 2m ./mfa -covermode=atomic - go test -v -p 1 -timeout 2m ./command -covermode=atomic + go test -v -p 1 -timeout 2m ./internal/config -covermode=atomic + go test -v -p 1 -timeout 5m ./internal/common -covermode=atomic + go test -v -p 1 -timeout 5m ./internal/httpd -covermode=atomic + go test -v -p 1 -timeout 8m ./internal/sftpd -covermode=atomic + go test -v -p 1 -timeout 5m ./internal/ftpd -covermode=atomic + go test -v -p 1 -timeout 5m ./internal/webdavd -covermode=atomic + go test -v -p 1 -timeout 2m ./internal/telemetry -covermode=atomic + go test -v -p 1 -timeout 2m ./internal/mfa -covermode=atomic + go test -v -p 1 -timeout 2m ./internal/command -covermode=atomic env: SFTPGO_DATA_PROVIDER__DRIVER: bolt SFTPGO_DATA_PROVIDER__NAME: 'sftpgo_bolt.db' @@ -310,7 +310,7 @@ jobs: - name: Build run: | - go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo + go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo cd tests/eventsearcher go build -trimpath -ldflags "-s -w" -o eventsearcher cd - @@ -410,7 +410,7 @@ jobs: - name: Build on amd64 if: ${{ matrix.arch == 'amd64' }} run: | - go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo + go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo mkdir -p output/{init,bash_completion,zsh_completion} cp sftpgo.json output/ cp -r templates output/ @@ -457,7 +457,7 @@ jobs: then export GOARM=7 fi - go build -buildvcs=false -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo + go build -buildvcs=false -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo mkdir -p output/{init,bash_completion,zsh_completion} cp sftpgo.json output/ cp -r templates output/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8bc88030..062f422b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -71,11 +71,11 @@ jobs: - name: Build for macOS x86_64 if: startsWith(matrix.os, 'windows-') != true - run: go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo + run: go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo - name: Build for macOS arm64 if: startsWith(matrix.os, 'macos-') == true - run: CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo_arm64 + run: CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo_arm64 - name: Build for Windows if: startsWith(matrix.os, 'windows-') @@ -85,17 +85,17 @@ jobs: $FILE_VERSION = $Env:SFTPGO_VERSION.substring(1) + ".0" go install github.com/tc-hib/go-winres@latest go-winres simply --arch amd64 --product-version $Env:SFTPGO_VERSION-$GIT_COMMIT --file-version $FILE_VERSION --file-description "SFTPGo server" --product-name SFTPGo --copyright "AGPL-3.0" --original-filename sftpgo.exe --icon .\windows-installer\icon.ico - go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/version.date=$DATE_TIME" -o sftpgo.exe + go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/internal/version.date=$DATE_TIME" -o sftpgo.exe mkdir arm64 $Env:CGO_ENABLED='0' $Env:GOOS='windows' $Env:GOARCH='arm64' go-winres simply --arch arm64 --product-version $Env:SFTPGO_VERSION-$GIT_COMMIT --file-version $FILE_VERSION --file-description "SFTPGo server" --product-name SFTPGo --copyright "AGPL-3.0" --original-filename sftpgo.exe --icon .\windows-installer\icon.ico - go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/version.date=$DATE_TIME" -o .\arm64\sftpgo.exe + go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/internal/version.date=$DATE_TIME" -o .\arm64\sftpgo.exe mkdir x86 $Env:GOARCH='386' go-winres simply --arch 386 --product-version $Env:SFTPGO_VERSION-$GIT_COMMIT --file-version $FILE_VERSION --file-description "SFTPGo server" --product-name SFTPGo --copyright "AGPL-3.0" --original-filename sftpgo.exe --icon .\windows-installer\icon.ico - go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/version.date=$DATE_TIME" -o .\x86\sftpgo.exe + go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/internal/version.date=$DATE_TIME" -o .\x86\sftpgo.exe Remove-Item Env:\CGO_ENABLED Remove-Item Env:\GOOS Remove-Item Env:\GOARCH @@ -302,7 +302,7 @@ jobs: - name: Build on amd64 if: ${{ matrix.arch == 'amd64' }} run: | - go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo + go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo mkdir -p output/{init,sqlite,bash_completion,zsh_completion} echo "For documentation please take a look here:" > output/README.txt echo "" >> output/README.txt @@ -350,7 +350,7 @@ jobs: tar -C /usr/local -xzf go.tar.gz run: | export PATH=$PATH:/usr/local/go/bin - go build -buildvcs=false -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo + go build -buildvcs=false -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo mkdir -p output/{init,sqlite,bash_completion,zsh_completion} echo "For documentation please take a look here:" > output/README.txt echo "" >> output/README.txt diff --git a/Dockerfile b/Dockerfile index 4bc9d6fc..18b06bfa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ COPY . . RUN set -xe && \ export COMMIT_SHA=${COMMIT_SHA:-$(git describe --always --dirty)} && \ - go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=${COMMIT_SHA} -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -v -o sftpgo + go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=${COMMIT_SHA} -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -v -o sftpgo FROM debian:bullseye-slim diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 19452483..4ac4dfc0 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -23,7 +23,7 @@ COPY . . RUN set -xe && \ export COMMIT_SHA=${COMMIT_SHA:-$(git describe --always --dirty)} && \ - go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=${COMMIT_SHA} -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -v -o sftpgo + go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=${COMMIT_SHA} -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -v -o sftpgo FROM alpine:3.16 diff --git a/Dockerfile.distroless b/Dockerfile.distroless index 97ce4824..9dd1d4a2 100644 --- a/Dockerfile.distroless +++ b/Dockerfile.distroless @@ -21,7 +21,7 @@ COPY . . RUN set -xe && \ export COMMIT_SHA=${COMMIT_SHA:-$(git describe --always --dirty)} && \ - go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=${COMMIT_SHA} -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -v -o sftpgo + go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=${COMMIT_SHA} -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -v -o sftpgo # Modify the default configuration file RUN sed -i 's|"users_base_dir": "",|"users_base_dir": "/srv/sftpgo/data",|' sftpgo.json && \ diff --git a/docs/build-from-source.md b/docs/build-from-source.md index 95c6be5d..218ad0ed 100644 --- a/docs/build-from-source.md +++ b/docs/build-from-source.md @@ -23,13 +23,13 @@ The compiler is a build time only dependency. It is not required at runtime. Version info, such as git commit and build date, can be embedded setting the following string variables at build time: -- `github.com/drakkan/sftpgo/v2/version.commit` -- `github.com/drakkan/sftpgo/v2/version.date` +- `github.com/drakkan/sftpgo/v2/internal/version.commit` +- `github.com/drakkan/sftpgo/v2/internal/version.date` For example, you can build using the following command: ```bash -go build -tags nogcs,nos3,nosqlite -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo +go build -tags nogcs,nos3,nosqlite -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo ``` You should get a version that includes git commit, build date and available features like this one: diff --git a/acme/account.go b/internal/acme/account.go similarity index 100% rename from acme/account.go rename to internal/acme/account.go diff --git a/acme/acme.go b/internal/acme/acme.go similarity index 98% rename from acme/acme.go rename to internal/acme/acme.go index a0eafddc..82b20fc3 100644 --- a/acme/acme.go +++ b/internal/acme/acme.go @@ -45,13 +45,13 @@ import ( "github.com/go-acme/lego/v4/registration" "github.com/robfig/cron/v3" - "github.com/drakkan/sftpgo/v2/ftpd" - "github.com/drakkan/sftpgo/v2/httpd" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/telemetry" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/webdavd" + "github.com/drakkan/sftpgo/v2/internal/ftpd" + "github.com/drakkan/sftpgo/v2/internal/httpd" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/telemetry" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/webdavd" ) const ( diff --git a/cmd/acme.go b/internal/cmd/acme.go similarity index 91% rename from cmd/acme.go rename to internal/cmd/acme.go index 4b580556..e27fdf15 100644 --- a/cmd/acme.go +++ b/internal/cmd/acme.go @@ -20,10 +20,10 @@ import ( "github.com/rs/zerolog" "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/acme" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/acme" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/cmd/awscontainer.go b/internal/cmd/awscontainer.go similarity index 100% rename from cmd/awscontainer.go rename to internal/cmd/awscontainer.go diff --git a/cmd/awscontainer_disabled.go b/internal/cmd/awscontainer_disabled.go similarity index 100% rename from cmd/awscontainer_disabled.go rename to internal/cmd/awscontainer_disabled.go diff --git a/cmd/gen.go b/internal/cmd/gen.go similarity index 100% rename from cmd/gen.go rename to internal/cmd/gen.go diff --git a/cmd/gencompletion.go b/internal/cmd/gencompletion.go similarity index 100% rename from cmd/gencompletion.go rename to internal/cmd/gencompletion.go diff --git a/cmd/genman.go b/internal/cmd/genman.go similarity index 95% rename from cmd/genman.go rename to internal/cmd/genman.go index 2e7b8063..179812a7 100644 --- a/cmd/genman.go +++ b/internal/cmd/genman.go @@ -24,8 +24,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/cobra/doc" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/version" ) var ( diff --git a/cmd/initprovider.go b/internal/cmd/initprovider.go similarity index 93% rename from cmd/initprovider.go rename to internal/cmd/initprovider.go index cbb04e06..ec1afeae 100644 --- a/cmd/initprovider.go +++ b/internal/cmd/initprovider.go @@ -21,11 +21,11 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/service" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/service" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/cmd/install_windows.go b/internal/cmd/install_windows.go similarity index 97% rename from cmd/install_windows.go rename to internal/cmd/install_windows.go index 8f8aaba1..02fa174e 100644 --- a/cmd/install_windows.go +++ b/internal/cmd/install_windows.go @@ -21,8 +21,8 @@ import ( "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/service" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/service" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/cmd/portable.go b/internal/cmd/portable.go similarity index 98% rename from cmd/portable.go rename to internal/cmd/portable.go index 80ad425a..01976731 100644 --- a/cmd/portable.go +++ b/internal/cmd/portable.go @@ -27,13 +27,13 @@ import ( "github.com/sftpgo/sdk" "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/service" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/service" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) var ( diff --git a/cmd/portable_disabled.go b/internal/cmd/portable_disabled.go similarity index 93% rename from cmd/portable_disabled.go rename to internal/cmd/portable_disabled.go index 90263b6b..e2bc6359 100644 --- a/cmd/portable_disabled.go +++ b/internal/cmd/portable_disabled.go @@ -17,7 +17,7 @@ package cmd -import "github.com/drakkan/sftpgo/v2/version" +import "github.com/drakkan/sftpgo/v2/internal/version" func init() { version.AddFeature("-portable") diff --git a/cmd/reload_windows.go b/internal/cmd/reload_windows.go similarity index 96% rename from cmd/reload_windows.go rename to internal/cmd/reload_windows.go index 355968c8..716c7925 100644 --- a/cmd/reload_windows.go +++ b/internal/cmd/reload_windows.go @@ -20,7 +20,7 @@ import ( "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/service" + "github.com/drakkan/sftpgo/v2/internal/service" ) var ( diff --git a/cmd/resetprovider.go b/internal/cmd/resetprovider.go similarity index 93% rename from cmd/resetprovider.go rename to internal/cmd/resetprovider.go index 93660a42..d274ecda 100644 --- a/cmd/resetprovider.go +++ b/internal/cmd/resetprovider.go @@ -23,10 +23,10 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/cmd/revertprovider.go b/internal/cmd/revertprovider.go similarity index 92% rename from cmd/revertprovider.go rename to internal/cmd/revertprovider.go index 34271557..7414a632 100644 --- a/cmd/revertprovider.go +++ b/internal/cmd/revertprovider.go @@ -21,10 +21,10 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/cmd/root.go b/internal/cmd/root.go similarity index 99% rename from cmd/root.go rename to internal/cmd/root.go index 47c82081..f6463258 100644 --- a/cmd/root.go +++ b/internal/cmd/root.go @@ -22,7 +22,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/version" ) const ( diff --git a/cmd/rotatelogs_windows.go b/internal/cmd/rotatelogs_windows.go similarity index 96% rename from cmd/rotatelogs_windows.go rename to internal/cmd/rotatelogs_windows.go index 1d2926a0..77b7f0d9 100644 --- a/cmd/rotatelogs_windows.go +++ b/internal/cmd/rotatelogs_windows.go @@ -20,7 +20,7 @@ import ( "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/service" + "github.com/drakkan/sftpgo/v2/internal/service" ) var ( diff --git a/cmd/serve.go b/internal/cmd/serve.go similarity index 95% rename from cmd/serve.go rename to internal/cmd/serve.go index 91fba0bc..1b7373f6 100644 --- a/cmd/serve.go +++ b/internal/cmd/serve.go @@ -19,8 +19,8 @@ import ( "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/service" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/service" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/cmd/service_windows.go b/internal/cmd/service_windows.go similarity index 100% rename from cmd/service_windows.go rename to internal/cmd/service_windows.go diff --git a/cmd/smtptest.go b/internal/cmd/smtptest.go similarity index 92% rename from cmd/smtptest.go rename to internal/cmd/smtptest.go index a5b13d9f..7e82c578 100644 --- a/cmd/smtptest.go +++ b/internal/cmd/smtptest.go @@ -20,10 +20,10 @@ import ( "github.com/rs/zerolog" "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/cmd/start_windows.go b/internal/cmd/start_windows.go similarity index 94% rename from cmd/start_windows.go rename to internal/cmd/start_windows.go index a9b09466..7edd391e 100644 --- a/cmd/start_windows.go +++ b/internal/cmd/start_windows.go @@ -21,8 +21,8 @@ import ( "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/service" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/service" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/cmd/startsubsys.go b/internal/cmd/startsubsys.go similarity index 95% rename from cmd/startsubsys.go rename to internal/cmd/startsubsys.go index ca41a335..15c21549 100644 --- a/cmd/startsubsys.go +++ b/internal/cmd/startsubsys.go @@ -25,13 +25,13 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/version" ) var ( diff --git a/cmd/status_windows.go b/internal/cmd/status_windows.go similarity index 96% rename from cmd/status_windows.go rename to internal/cmd/status_windows.go index cccc6ec5..d75ade16 100644 --- a/cmd/status_windows.go +++ b/internal/cmd/status_windows.go @@ -20,7 +20,7 @@ import ( "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/service" + "github.com/drakkan/sftpgo/v2/internal/service" ) var ( diff --git a/cmd/stop_windows.go b/internal/cmd/stop_windows.go similarity index 96% rename from cmd/stop_windows.go rename to internal/cmd/stop_windows.go index dc811e74..b1525fc5 100644 --- a/cmd/stop_windows.go +++ b/internal/cmd/stop_windows.go @@ -20,7 +20,7 @@ import ( "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/service" + "github.com/drakkan/sftpgo/v2/internal/service" ) var ( diff --git a/cmd/uninstall_windows.go b/internal/cmd/uninstall_windows.go similarity index 96% rename from cmd/uninstall_windows.go rename to internal/cmd/uninstall_windows.go index 51b21bd5..cbe01795 100644 --- a/cmd/uninstall_windows.go +++ b/internal/cmd/uninstall_windows.go @@ -20,7 +20,7 @@ import ( "github.com/spf13/cobra" - "github.com/drakkan/sftpgo/v2/service" + "github.com/drakkan/sftpgo/v2/internal/service" ) var ( diff --git a/command/command.go b/internal/command/command.go similarity index 100% rename from command/command.go rename to internal/command/command.go diff --git a/command/command_test.go b/internal/command/command_test.go similarity index 100% rename from command/command_test.go rename to internal/command/command_test.go diff --git a/common/actions.go b/internal/common/actions.go similarity index 97% rename from common/actions.go rename to internal/common/actions.go index 59cb0dee..cf6b026b 100644 --- a/common/actions.go +++ b/internal/common/actions.go @@ -31,12 +31,12 @@ import ( "github.com/sftpgo/sdk" "github.com/sftpgo/sdk/plugin/notifier" - "github.com/drakkan/sftpgo/v2/command" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/command" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/common/actions_test.go b/internal/common/actions_test.go similarity index 98% rename from common/actions_test.go rename to internal/common/actions_test.go index d9d4c186..d2d32272 100644 --- a/common/actions_test.go +++ b/internal/common/actions_test.go @@ -29,9 +29,9 @@ import ( "github.com/sftpgo/sdk/plugin/notifier" "github.com/stretchr/testify/assert" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) func TestNewActionNotification(t *testing.T) { diff --git a/common/clientsmap.go b/internal/common/clientsmap.go similarity index 97% rename from common/clientsmap.go rename to internal/common/clientsmap.go index f2375060..8955c873 100644 --- a/common/clientsmap.go +++ b/internal/common/clientsmap.go @@ -18,7 +18,7 @@ import ( "sync" "sync/atomic" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) // clienstMap is a struct containing the map of the connected clients diff --git a/common/clientsmap_test.go b/internal/common/clientsmap_test.go similarity index 100% rename from common/clientsmap_test.go rename to internal/common/clientsmap_test.go diff --git a/common/common.go b/internal/common/common.go similarity index 99% rename from common/common.go rename to internal/common/common.go index c865db4e..e9d074f3 100644 --- a/common/common.go +++ b/internal/common/common.go @@ -33,14 +33,14 @@ import ( "github.com/pires/go-proxyproto" - "github.com/drakkan/sftpgo/v2/command" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/command" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // constants diff --git a/common/common_test.go b/internal/common/common_test.go similarity index 98% rename from common/common_test.go rename to internal/common/common_test.go index b3918849..5fc85f02 100644 --- a/common/common_test.go +++ b/internal/common/common_test.go @@ -35,21 +35,24 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/crypto/bcrypt" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( logSenderTest = "common_test" httpAddr = "127.0.0.1:9999" - configDir = ".." osWindows = "windows" userTestUsername = "common_test_username" ) +var ( + configDir = filepath.Join(".", "..", "..") +) + type fakeConnection struct { *BaseConnection command string @@ -149,7 +152,7 @@ func TestDefenderIntegration(t *testing.T) { pluginsConfig := []plugin.Config{ { Type: "ipfilter", - Cmd: filepath.Join(wdPath, "..", "tests", "ipfilter", "ipfilter"), + Cmd: filepath.Join(wdPath, "..", "..", "tests", "ipfilter", "ipfilter"), AutoMTLS: true, }, } diff --git a/common/connection.go b/internal/common/connection.go similarity index 99% rename from common/connection.go rename to internal/common/connection.go index e55d825c..06a6e8ca 100644 --- a/common/connection.go +++ b/internal/common/connection.go @@ -28,10 +28,10 @@ import ( "github.com/pkg/sftp" "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // BaseConnection defines common fields for a connection using any supported protocol diff --git a/common/connection_test.go b/internal/common/connection_test.go similarity index 98% rename from common/connection_test.go rename to internal/common/connection_test.go index 04f106c2..22256245 100644 --- a/common/connection_test.go +++ b/internal/common/connection_test.go @@ -27,10 +27,10 @@ import ( "github.com/sftpgo/sdk" "github.com/stretchr/testify/assert" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // MockOsFs mockable OsFs diff --git a/common/dataretention.go b/internal/common/dataretention.go similarity index 98% rename from common/dataretention.go rename to internal/common/dataretention.go index 2d84260a..0f73ddbb 100644 --- a/common/dataretention.go +++ b/internal/common/dataretention.go @@ -29,12 +29,12 @@ import ( "sync" "time" - "github.com/drakkan/sftpgo/v2/command" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/command" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" ) // RetentionCheckNotification defines the supported notification methods for a retention check result diff --git a/common/dataretention_test.go b/internal/common/dataretention_test.go similarity index 97% rename from common/dataretention_test.go rename to internal/common/dataretention_test.go index 73a02f96..1c66b20d 100644 --- a/common/dataretention_test.go +++ b/internal/common/dataretention_test.go @@ -26,8 +26,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/smtp" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/smtp" ) func TestRetentionValidation(t *testing.T) { @@ -94,7 +94,7 @@ func TestRetentionValidation(t *testing.T) { Port: 25, TemplatesPath: "templates", } - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) err = check.Validate() @@ -106,7 +106,7 @@ func TestRetentionValidation(t *testing.T) { assert.NoError(t, err) smtpCfg = smtp.Config{} - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) check.Notifications = []RetentionCheckNotification{RetentionCheckNotificationHook} @@ -126,7 +126,7 @@ func TestRetentionEmailNotifications(t *testing.T) { Port: 2525, TemplatesPath: "templates", } - err := smtpCfg.Initialize("..") + err := smtpCfg.Initialize(configDir) require.NoError(t, err) user := dataprovider.User{ @@ -160,13 +160,13 @@ func TestRetentionEmailNotifications(t *testing.T) { assert.NoError(t, err) smtpCfg.Port = 2626 - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) err = check.sendEmailNotification(1*time.Second, nil) assert.Error(t, err) smtpCfg = smtp.Config{} - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) err = check.sendEmailNotification(1*time.Second, nil) assert.Error(t, err) diff --git a/common/defender.go b/internal/common/defender.go similarity index 98% rename from common/defender.go rename to internal/common/defender.go index 04755d46..ed709121 100644 --- a/common/defender.go +++ b/internal/common/defender.go @@ -25,9 +25,9 @@ import ( "github.com/yl2chen/cidranger" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) // HostEvent is the enumerable for the supported host events diff --git a/common/defender_test.go b/internal/common/defender_test.go similarity index 100% rename from common/defender_test.go rename to internal/common/defender_test.go diff --git a/common/defenderdb.go b/internal/common/defenderdb.go similarity index 97% rename from common/defenderdb.go rename to internal/common/defenderdb.go index c9bcdecf..4f4a2b32 100644 --- a/common/defenderdb.go +++ b/internal/common/defenderdb.go @@ -17,9 +17,9 @@ package common import ( "time" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) type dbDefender struct { diff --git a/common/defenderdb_test.go b/internal/common/defenderdb_test.go similarity index 99% rename from common/defenderdb_test.go rename to internal/common/defenderdb_test.go index 93e4b109..3e6cb3fe 100644 --- a/common/defenderdb_test.go +++ b/internal/common/defenderdb_test.go @@ -24,8 +24,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/util" ) func TestBasicDbDefender(t *testing.T) { diff --git a/common/defendermem.go b/internal/common/defendermem.go similarity index 98% rename from common/defendermem.go rename to internal/common/defendermem.go index 50569eb0..dce3c809 100644 --- a/common/defendermem.go +++ b/internal/common/defendermem.go @@ -18,8 +18,8 @@ import ( "sort" "time" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/util" ) type memoryDefender struct { diff --git a/common/httpauth.go b/internal/common/httpauth.go similarity index 97% rename from common/httpauth.go rename to internal/common/httpauth.go index c3acb251..0ec30dad 100644 --- a/common/httpauth.go +++ b/internal/common/httpauth.go @@ -24,8 +24,8 @@ import ( "github.com/GehirnInc/crypt/md5_crypt" "golang.org/x/crypto/bcrypt" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/common/httpauth_test.go b/internal/common/httpauth_test.go similarity index 100% rename from common/httpauth_test.go rename to internal/common/httpauth_test.go diff --git a/common/protocol_test.go b/internal/common/protocol_test.go similarity index 99% rename from common/protocol_test.go rename to internal/common/protocol_test.go index 3044145e..ec149e58 100644 --- a/common/protocol_test.go +++ b/internal/common/protocol_test.go @@ -46,21 +46,20 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/crypto/ssh" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/httpdtest" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/httpdtest" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( - configDir = ".." httpAddr = "127.0.0.1:9999" httpProxyAddr = "127.0.0.1:7777" sftpServerAddr = "127.0.0.1:4022" @@ -74,6 +73,7 @@ const ( ) var ( + configDir = filepath.Join(".", "..", "..") allPerms = []string{dataprovider.PermAny} homeBasePath string logFilePath string @@ -2827,7 +2827,7 @@ func TestEventRule(t *testing.T) { From: "notification@example.com", TemplatesPath: "templates", } - err := smtpCfg.Initialize("..") + err := smtpCfg.Initialize(configDir) require.NoError(t, err) a1 := dataprovider.BaseEventAction{ @@ -3086,7 +3086,7 @@ func TestEventRule(t *testing.T) { assert.NoError(t, err) smtpCfg = smtp.Config{} - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) } diff --git a/common/ratelimiter.go b/internal/common/ratelimiter.go similarity index 99% rename from common/ratelimiter.go rename to internal/common/ratelimiter.go index db7e06e5..2dd74f80 100644 --- a/common/ratelimiter.go +++ b/internal/common/ratelimiter.go @@ -25,7 +25,7 @@ import ( "golang.org/x/time/rate" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/common/ratelimiter_test.go b/internal/common/ratelimiter_test.go similarity index 99% rename from common/ratelimiter_test.go rename to internal/common/ratelimiter_test.go index d13bdd37..744d02d5 100644 --- a/common/ratelimiter_test.go +++ b/internal/common/ratelimiter_test.go @@ -21,7 +21,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/util" ) func TestRateLimiterConfig(t *testing.T) { diff --git a/common/tlsutils.go b/internal/common/tlsutils.go similarity index 98% rename from common/tlsutils.go rename to internal/common/tlsutils.go index 18b731ff..df7730a4 100644 --- a/common/tlsutils.go +++ b/internal/common/tlsutils.go @@ -25,8 +25,8 @@ import ( "sync" "time" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/common/tlsutils_test.go b/internal/common/tlsutils_test.go similarity index 100% rename from common/tlsutils_test.go rename to internal/common/tlsutils_test.go diff --git a/common/transfer.go b/internal/common/transfer.go similarity index 98% rename from common/transfer.go rename to internal/common/transfer.go index ed47f064..e9458041 100644 --- a/common/transfer.go +++ b/internal/common/transfer.go @@ -21,10 +21,10 @@ import ( "sync/atomic" "time" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) var ( diff --git a/common/transfer_test.go b/internal/common/transfer_test.go similarity index 99% rename from common/transfer_test.go rename to internal/common/transfer_test.go index 660379fc..1106133f 100644 --- a/common/transfer_test.go +++ b/internal/common/transfer_test.go @@ -25,9 +25,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) func TestTransferUpdateQuota(t *testing.T) { diff --git a/common/transferschecker.go b/internal/common/transferschecker.go similarity index 98% rename from common/transferschecker.go rename to internal/common/transferschecker.go index e797272f..16ea8533 100644 --- a/common/transferschecker.go +++ b/internal/common/transferschecker.go @@ -19,9 +19,9 @@ import ( "sync" "time" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) type overquotaTransfer struct { diff --git a/common/transferschecker_test.go b/internal/common/transferschecker_test.go similarity index 99% rename from common/transferschecker_test.go rename to internal/common/transferschecker_test.go index 2b66c745..2f9c236d 100644 --- a/common/transferschecker_test.go +++ b/internal/common/transferschecker_test.go @@ -29,9 +29,9 @@ import ( "github.com/sftpgo/sdk" "github.com/stretchr/testify/assert" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) func TestTransfersCheckerDiskQuota(t *testing.T) { diff --git a/config/config.go b/internal/config/config.go similarity index 98% rename from config/config.go rename to internal/config/config.go index 8c1dc835..a4710fa1 100644 --- a/config/config.go +++ b/internal/config/config.go @@ -25,23 +25,23 @@ import ( "github.com/spf13/viper" - "github.com/drakkan/sftpgo/v2/acme" - "github.com/drakkan/sftpgo/v2/command" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/ftpd" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/httpd" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/telemetry" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/webdavd" + "github.com/drakkan/sftpgo/v2/internal/acme" + "github.com/drakkan/sftpgo/v2/internal/command" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/ftpd" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/httpd" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/telemetry" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/webdavd" ) const ( diff --git a/config/config_linux.go b/internal/config/config_linux.go similarity index 100% rename from config/config_linux.go rename to internal/config/config_linux.go diff --git a/config/config_nolinux.go b/internal/config/config_nolinux.go similarity index 100% rename from config/config_nolinux.go rename to internal/config/config_nolinux.go diff --git a/config/config_test.go b/internal/config/config_test.go similarity index 98% rename from config/config_test.go rename to internal/config/config_test.go index 83170978..e0f6de1c 100644 --- a/config/config_test.go +++ b/internal/config/config_test.go @@ -26,24 +26,28 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/drakkan/sftpgo/v2/command" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/ftpd" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/httpd" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/command" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/ftpd" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/httpd" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( tempConfigName = "temp" ) +var ( + configDir = filepath.Join(".", "..", "..") +) + func reset() { viper.Reset() config.Init() @@ -52,7 +56,6 @@ func reset() { func TestLoadConfigTest(t *testing.T) { reset() - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) assert.NotEqual(t, httpd.Conf{}, config.GetHTTPConfig()) @@ -89,7 +92,6 @@ func TestLoadConfigFileNotFound(t *testing.T) { func TestEmptyBanner(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) err := config.LoadConfig(configDir, "") @@ -126,7 +128,6 @@ func TestEmptyBanner(t *testing.T) { func TestEnabledSSHCommands(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) err := config.LoadConfig(configDir, "") @@ -155,7 +156,6 @@ func TestEnabledSSHCommands(t *testing.T) { func TestInvalidUploadMode(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) err := config.LoadConfig(configDir, "") @@ -178,7 +178,6 @@ func TestInvalidUploadMode(t *testing.T) { func TestInvalidExternalAuthScope(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) err := config.LoadConfig(configDir, "") @@ -201,7 +200,6 @@ func TestInvalidExternalAuthScope(t *testing.T) { func TestInvalidProxyProtocol(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) err := config.LoadConfig(configDir, "") @@ -224,7 +222,6 @@ func TestInvalidProxyProtocol(t *testing.T) { func TestInvalidUsersBaseDir(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) err := config.LoadConfig(configDir, "") @@ -247,7 +244,6 @@ func TestInvalidUsersBaseDir(t *testing.T) { func TestInvalidInstallationHint(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) err := config.LoadConfig(configDir, "") @@ -278,7 +274,6 @@ func TestDefenderProviderDriver(t *testing.T) { } reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) providerConf := config.GetProviderConf() @@ -358,7 +353,6 @@ func TestSetGetConfig(t *testing.T) { func TestServiceToStart(t *testing.T) { reset() - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) assert.True(t, config.HasServicesToStart()) @@ -392,7 +386,6 @@ func TestSSHCommandsFromEnv(t *testing.T) { os.Unsetenv("SFTPGO_SFTPD__ENABLED_SSH_COMMANDS") }) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) @@ -413,7 +406,6 @@ func TestSMTPFromEnv(t *testing.T) { os.Unsetenv("SFTPGO_SMTP__PORT") }) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) smtpConfig := config.GetSMTPConfig() @@ -435,7 +427,6 @@ func TestMFAFromEnv(t *testing.T) { os.Unsetenv("SFTPGO_MFA__TOTP__1__ALGO") }) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) mfaConf := config.GetMFAConfig() @@ -451,7 +442,6 @@ func TestMFAFromEnv(t *testing.T) { func TestDisabledMFAConfig(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) @@ -491,7 +481,6 @@ func TestFTPDOverridesFromEnv(t *testing.T) { } t.Cleanup(cleanup) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) ftpdConf := config.GetFTPDConfig() @@ -552,7 +541,6 @@ func TestHTTPDSubObjectsFromEnv(t *testing.T) { } t.Cleanup(cleanup) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) httpdConf := config.GetHTTPDConfig() @@ -628,7 +616,6 @@ func TestPluginsFromEnv(t *testing.T) { os.Unsetenv("SFTPGO_PLUGINS__0__AUTH_OPTIONS__SCOPE") }) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) pluginsConf := config.GetPluginsConfig() @@ -727,7 +714,6 @@ func TestRateLimitersFromEnv(t *testing.T) { os.Unsetenv("SFTPGO_COMMON__RATE_LIMITERS__8__ALLOW_LIST") }) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) limiters := config.GetCommonConfig().RateLimitersConfig @@ -780,7 +766,6 @@ func TestSFTPDBindingsFromEnv(t *testing.T) { os.Unsetenv("SFTPGO_SFTPD__BINDINGS__3__PORT") }) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) bindings := config.GetSFTPDConfig().Bindings @@ -796,7 +781,6 @@ func TestSFTPDBindingsFromEnv(t *testing.T) { func TestCommandsFromEnv(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) err := config.LoadConfig(configDir, "") @@ -903,7 +887,6 @@ func TestFTPDBindingsFromEnv(t *testing.T) { os.Unsetenv("SFTPGO_FTPD__BINDINGS__9__CERTIFICATE_KEY_FILE") }) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) bindings := config.GetFTPDConfig().Bindings @@ -979,7 +962,6 @@ func TestWebDAVBindingsFromEnv(t *testing.T) { os.Unsetenv("SFTPGO_WEBDAVD__BINDINGS__2__CERTIFICATE_KEY_FILE") }) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) bindings := config.GetWebDAVDConfig().Bindings @@ -1152,7 +1134,6 @@ func TestHTTPDBindingsFromEnv(t *testing.T) { os.Unsetenv("SFTPGO_HTTPD__BINDINGS__2__CERTIFICATE_KEY_FILE") }) - configDir := ".." err := config.LoadConfig(configDir, "") assert.NoError(t, err) bindings := config.GetHTTPDConfig().Bindings @@ -1260,7 +1241,6 @@ func TestHTTPDBindingsFromEnv(t *testing.T) { func TestHTTPClientCertificatesFromEnv(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) err := config.LoadConfig(configDir, "") @@ -1321,7 +1301,6 @@ func TestHTTPClientCertificatesFromEnv(t *testing.T) { func TestHTTPClientHeadersFromEnv(t *testing.T) { reset() - configDir := ".." confName := tempConfigName + ".json" configFilePath := filepath.Join(configDir, confName) err := config.LoadConfig(configDir, "") diff --git a/dataprovider/actions.go b/internal/dataprovider/actions.go similarity index 95% rename from dataprovider/actions.go rename to internal/dataprovider/actions.go index 5a98abf4..e95f87cf 100644 --- a/dataprovider/actions.go +++ b/internal/dataprovider/actions.go @@ -26,11 +26,11 @@ import ( "github.com/sftpgo/sdk/plugin/notifier" - "github.com/drakkan/sftpgo/v2/command" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/command" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/dataprovider/admin.go b/internal/dataprovider/admin.go similarity index 98% rename from dataprovider/admin.go rename to internal/dataprovider/admin.go index 77b628e0..6ec1c116 100644 --- a/dataprovider/admin.go +++ b/internal/dataprovider/admin.go @@ -28,10 +28,10 @@ import ( passwordvalidator "github.com/wagslane/go-password-validator" "golang.org/x/crypto/bcrypt" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/util" ) // Available permissions for SFTPGo admins diff --git a/dataprovider/apikey.go b/internal/dataprovider/apikey.go similarity index 98% rename from dataprovider/apikey.go rename to internal/dataprovider/apikey.go index a2d50a03..eab563a7 100644 --- a/dataprovider/apikey.go +++ b/internal/dataprovider/apikey.go @@ -23,8 +23,8 @@ import ( "github.com/alexedwards/argon2id" "golang.org/x/crypto/bcrypt" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) // APIKeyScope defines the supported API key scopes diff --git a/dataprovider/bolt.go b/internal/dataprovider/bolt.go similarity index 99% rename from dataprovider/bolt.go rename to internal/dataprovider/bolt.go index dabbb40b..eb56e0aa 100644 --- a/dataprovider/bolt.go +++ b/internal/dataprovider/bolt.go @@ -28,10 +28,10 @@ import ( bolt "go.etcd.io/bbolt" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/dataprovider/bolt_disabled.go b/internal/dataprovider/bolt_disabled.go similarity index 94% rename from dataprovider/bolt_disabled.go rename to internal/dataprovider/bolt_disabled.go index 4a8f517f..d6fcfb28 100644 --- a/dataprovider/bolt_disabled.go +++ b/internal/dataprovider/bolt_disabled.go @@ -20,7 +20,7 @@ package dataprovider import ( "errors" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/version" ) func init() { diff --git a/dataprovider/cachedpassword.go b/internal/dataprovider/cachedpassword.go similarity index 100% rename from dataprovider/cachedpassword.go rename to internal/dataprovider/cachedpassword.go diff --git a/dataprovider/cacheduser.go b/internal/dataprovider/cacheduser.go similarity index 97% rename from dataprovider/cacheduser.go rename to internal/dataprovider/cacheduser.go index d532cb11..3363fed7 100644 --- a/dataprovider/cacheduser.go +++ b/internal/dataprovider/cacheduser.go @@ -20,8 +20,8 @@ import ( "golang.org/x/net/webdav" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/dataprovider/dataprovider.go b/internal/dataprovider/dataprovider.go similarity index 99% rename from dataprovider/dataprovider.go rename to internal/dataprovider/dataprovider.go index 3f21438a..ef339bb4 100644 --- a/dataprovider/dataprovider.go +++ b/internal/dataprovider/dataprovider.go @@ -61,14 +61,14 @@ import ( "golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/ssh" - "github.com/drakkan/sftpgo/v2/command" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/command" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/dataprovider/eventrule.go b/internal/dataprovider/eventrule.go similarity index 99% rename from dataprovider/eventrule.go rename to internal/dataprovider/eventrule.go index a3e34d93..191b89df 100644 --- a/dataprovider/eventrule.go +++ b/internal/dataprovider/eventrule.go @@ -32,11 +32,11 @@ import ( "github.com/robfig/cron/v3" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // Supported event actions diff --git a/dataprovider/eventruleutil.go b/internal/dataprovider/eventruleutil.go similarity index 98% rename from dataprovider/eventruleutil.go rename to internal/dataprovider/eventruleutil.go index c838fe18..b0e1cf9e 100644 --- a/dataprovider/eventruleutil.go +++ b/internal/dataprovider/eventruleutil.go @@ -23,9 +23,9 @@ import ( "github.com/robfig/cron/v3" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/dataprovider/group.go b/internal/dataprovider/group.go similarity index 97% rename from dataprovider/group.go rename to internal/dataprovider/group.go index ee593a01..a22e7824 100644 --- a/dataprovider/group.go +++ b/internal/dataprovider/group.go @@ -22,10 +22,10 @@ import ( "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // GroupUserSettings defines the settings to apply to users diff --git a/dataprovider/memory.go b/internal/dataprovider/memory.go similarity index 99% rename from dataprovider/memory.go rename to internal/dataprovider/memory.go index 3d5ac776..385aee49 100644 --- a/dataprovider/memory.go +++ b/internal/dataprovider/memory.go @@ -24,9 +24,9 @@ import ( "sync" "time" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) var ( diff --git a/dataprovider/mysql.go b/internal/dataprovider/mysql.go similarity index 99% rename from dataprovider/mysql.go rename to internal/dataprovider/mysql.go index 97af5876..1b6edbef 100644 --- a/dataprovider/mysql.go +++ b/internal/dataprovider/mysql.go @@ -30,9 +30,9 @@ import ( "github.com/go-sql-driver/mysql" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/dataprovider/mysql_disabled.go b/internal/dataprovider/mysql_disabled.go similarity index 94% rename from dataprovider/mysql_disabled.go rename to internal/dataprovider/mysql_disabled.go index ff4c34c8..dd39cd4a 100644 --- a/dataprovider/mysql_disabled.go +++ b/internal/dataprovider/mysql_disabled.go @@ -20,7 +20,7 @@ package dataprovider import ( "errors" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/version" ) func init() { diff --git a/dataprovider/pgsql.go b/internal/dataprovider/pgsql.go similarity index 99% rename from dataprovider/pgsql.go rename to internal/dataprovider/pgsql.go index f56bf605..8bdad150 100644 --- a/dataprovider/pgsql.go +++ b/internal/dataprovider/pgsql.go @@ -29,9 +29,9 @@ import ( // we import lib/pq here to be able to disable PostgreSQL support using a build tag _ "github.com/lib/pq" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/dataprovider/pgsql_disabled.go b/internal/dataprovider/pgsql_disabled.go similarity index 94% rename from dataprovider/pgsql_disabled.go rename to internal/dataprovider/pgsql_disabled.go index 573f19bb..f46ccb41 100644 --- a/dataprovider/pgsql_disabled.go +++ b/internal/dataprovider/pgsql_disabled.go @@ -20,7 +20,7 @@ package dataprovider import ( "errors" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/version" ) func init() { diff --git a/dataprovider/quota.go b/internal/dataprovider/quota.go similarity index 98% rename from dataprovider/quota.go rename to internal/dataprovider/quota.go index 615891ff..cdcba099 100644 --- a/dataprovider/quota.go +++ b/internal/dataprovider/quota.go @@ -18,7 +18,7 @@ import ( "sync" "time" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/dataprovider/quotaupdater.go b/internal/dataprovider/quotaupdater.go similarity index 99% rename from dataprovider/quotaupdater.go rename to internal/dataprovider/quotaupdater.go index 954210bc..cf9643be 100644 --- a/dataprovider/quotaupdater.go +++ b/internal/dataprovider/quotaupdater.go @@ -18,7 +18,7 @@ import ( "sync" "time" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) var delayedQuotaUpdater quotaUpdater diff --git a/dataprovider/scheduler.go b/internal/dataprovider/scheduler.go similarity index 96% rename from dataprovider/scheduler.go rename to internal/dataprovider/scheduler.go index d34287c6..7cb7ad03 100644 --- a/dataprovider/scheduler.go +++ b/internal/dataprovider/scheduler.go @@ -21,9 +21,9 @@ import ( "github.com/robfig/cron/v3" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/dataprovider/session.go b/internal/dataprovider/session.go similarity index 100% rename from dataprovider/session.go rename to internal/dataprovider/session.go diff --git a/dataprovider/share.go b/internal/dataprovider/share.go similarity index 99% rename from dataprovider/share.go rename to internal/dataprovider/share.go index e0699458..4741bdcf 100644 --- a/dataprovider/share.go +++ b/internal/dataprovider/share.go @@ -24,8 +24,8 @@ import ( "github.com/alexedwards/argon2id" "golang.org/x/crypto/bcrypt" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) // ShareScope defines the supported share scopes diff --git a/dataprovider/sqlcommon.go b/internal/dataprovider/sqlcommon.go similarity index 99% rename from dataprovider/sqlcommon.go rename to internal/dataprovider/sqlcommon.go index 1a38bb61..617ebbe6 100644 --- a/dataprovider/sqlcommon.go +++ b/internal/dataprovider/sqlcommon.go @@ -28,9 +28,9 @@ import ( "github.com/cockroachdb/cockroach-go/v2/crdb" "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/dataprovider/sqlite.go b/internal/dataprovider/sqlite.go similarity index 99% rename from dataprovider/sqlite.go rename to internal/dataprovider/sqlite.go index de12d3c0..95d177d9 100644 --- a/dataprovider/sqlite.go +++ b/internal/dataprovider/sqlite.go @@ -30,10 +30,10 @@ import ( // we import go-sqlite3 here to be able to disable SQLite support using a build tag _ "github.com/mattn/go-sqlite3" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/dataprovider/sqlite_disabled.go b/internal/dataprovider/sqlite_disabled.go similarity index 94% rename from dataprovider/sqlite_disabled.go rename to internal/dataprovider/sqlite_disabled.go index 1e43cd2e..f2e90a7a 100644 --- a/dataprovider/sqlite_disabled.go +++ b/internal/dataprovider/sqlite_disabled.go @@ -20,7 +20,7 @@ package dataprovider import ( "errors" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/version" ) func init() { diff --git a/dataprovider/sqlqueries.go b/internal/dataprovider/sqlqueries.go similarity index 99% rename from dataprovider/sqlqueries.go rename to internal/dataprovider/sqlqueries.go index a595142f..a68a3df8 100644 --- a/dataprovider/sqlqueries.go +++ b/internal/dataprovider/sqlqueries.go @@ -19,7 +19,7 @@ import ( "strconv" "strings" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/dataprovider/user.go b/internal/dataprovider/user.go similarity index 99% rename from dataprovider/user.go rename to internal/dataprovider/user.go index 84a3c8a2..cd3edf47 100644 --- a/dataprovider/user.go +++ b/internal/dataprovider/user.go @@ -29,12 +29,12 @@ import ( "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // Available permissions for SFTPGo users diff --git a/ftpd/cryptfs_test.go b/internal/ftpd/cryptfs_test.go similarity index 98% rename from ftpd/cryptfs_test.go rename to internal/ftpd/cryptfs_test.go index 14591a6d..e533c670 100644 --- a/ftpd/cryptfs_test.go +++ b/internal/ftpd/cryptfs_test.go @@ -30,10 +30,10 @@ import ( "github.com/sftpgo/sdk" "github.com/stretchr/testify/assert" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpdtest" - "github.com/drakkan/sftpgo/v2/kms" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpdtest" + "github.com/drakkan/sftpgo/v2/internal/kms" ) func TestBasicFTPHandlingCryptFs(t *testing.T) { diff --git a/ftpd/ftpd.go b/internal/ftpd/ftpd.go similarity index 99% rename from ftpd/ftpd.go rename to internal/ftpd/ftpd.go index 77f5aadb..175046b5 100644 --- a/ftpd/ftpd.go +++ b/internal/ftpd/ftpd.go @@ -24,9 +24,9 @@ import ( ftpserver "github.com/fclairamb/ftpserverlib" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/ftpd/ftpd_test.go b/internal/ftpd/ftpd_test.go similarity index 99% rename from ftpd/ftpd_test.go rename to internal/ftpd/ftpd_test.go index d6bfa578..59b8d5b0 100644 --- a/ftpd/ftpd_test.go +++ b/internal/ftpd/ftpd_test.go @@ -45,16 +45,16 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/ftpd" - "github.com/drakkan/sftpgo/v2/httpdtest" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/ftpd" + "github.com/drakkan/sftpgo/v2/internal/httpdtest" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( @@ -64,7 +64,6 @@ const ( ftpSrvAddrTLS = "127.0.0.1:2124" // ftp server with implicit tls defaultUsername = "test_user_ftp" defaultPassword = "test_password" - configDir = ".." osWindows = "windows" ftpsCert = `-----BEGIN CERTIFICATE----- MIICHTCCAaKgAwIBAgIUHnqw7QnB1Bj9oUsNpdb+ZkFPOxMwCgYIKoZIzj0EAwIw @@ -249,6 +248,7 @@ XMf5HU3ThYqYn3bYypZZ8nQ7BXVh4LqGNqG29wR4v6l+dLO6odXnLzfApGD9e+d4 ) var ( + configDir = filepath.Join(".", "..", "..") allPerms = []string{dataprovider.PermAny} homeBasePath string hookCmdPath string diff --git a/ftpd/handler.go b/internal/ftpd/handler.go similarity index 98% rename from ftpd/handler.go rename to internal/ftpd/handler.go index 969e6b9a..2a2d5e13 100644 --- a/ftpd/handler.go +++ b/internal/ftpd/handler.go @@ -26,10 +26,10 @@ import ( ftpserver "github.com/fclairamb/ftpserverlib" "github.com/spf13/afero" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) var ( diff --git a/ftpd/internal_test.go b/internal/ftpd/internal_test.go similarity index 99% rename from ftpd/internal_test.go rename to internal/ftpd/internal_test.go index 0c18b7f5..f795c2fa 100644 --- a/ftpd/internal_test.go +++ b/internal/ftpd/internal_test.go @@ -34,14 +34,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( - configDir = ".." - ftpsCert = `-----BEGIN CERTIFICATE----- + ftpsCert = `-----BEGIN CERTIFICATE----- MIICHTCCAaKgAwIBAgIUHnqw7QnB1Bj9oUsNpdb+ZkFPOxMwCgYIKoZIzj0EAwIw RTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGElu dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMDAyMDQwOTUzMDRaFw0zMDAyMDEw @@ -268,6 +267,10 @@ xr5cb9VBRBtB9aOKVfuRhpatAfS2Pzm2Htae9lFn7slGPUmu2hkjDw== -----END RSA PRIVATE KEY-----` ) +var ( + configDir = filepath.Join(".", "..", "..") +) + type mockFTPClientContext struct { lastDataChannel ftpserver.DataChannel remoteIP string diff --git a/ftpd/server.go b/internal/ftpd/server.go similarity index 98% rename from ftpd/server.go rename to internal/ftpd/server.go index 9c2f839b..6a09aeb3 100644 --- a/ftpd/server.go +++ b/internal/ftpd/server.go @@ -26,12 +26,12 @@ import ( ftpserver "github.com/fclairamb/ftpserverlib" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" ) // Server implements the ftpserverlib MainDriver interface diff --git a/ftpd/transfer.go b/internal/ftpd/transfer.go similarity index 97% rename from ftpd/transfer.go rename to internal/ftpd/transfer.go index ab2737f3..b6bfa289 100644 --- a/ftpd/transfer.go +++ b/internal/ftpd/transfer.go @@ -21,8 +21,8 @@ import ( "github.com/eikenb/pipeat" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // transfer contains the transfer details for an upload or a download. diff --git a/httpclient/httpclient.go b/internal/httpclient/httpclient.go similarity index 98% rename from httpclient/httpclient.go rename to internal/httpclient/httpclient.go index 8618693e..90d3b142 100644 --- a/httpclient/httpclient.go +++ b/internal/httpclient/httpclient.go @@ -27,8 +27,8 @@ import ( "github.com/hashicorp/go-retryablehttp" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) // TLSKeyPair defines the paths for a TLS key pair diff --git a/httpd/api_admin.go b/internal/httpd/api_admin.go similarity index 98% rename from httpd/api_admin.go rename to internal/httpd/api_admin.go index d4768212..bca8c222 100644 --- a/httpd/api_admin.go +++ b/internal/httpd/api_admin.go @@ -22,9 +22,9 @@ import ( "github.com/go-chi/jwtauth/v5" "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" ) func getAdmins(w http.ResponseWriter, r *http.Request) { diff --git a/httpd/api_defender.go b/internal/httpd/api_defender.go similarity index 95% rename from httpd/api_defender.go rename to internal/httpd/api_defender.go index 7667a271..f5426c37 100644 --- a/httpd/api_defender.go +++ b/internal/httpd/api_defender.go @@ -23,8 +23,8 @@ import ( "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" ) func getDefenderHosts(w http.ResponseWriter, r *http.Request) { diff --git a/httpd/api_eventrule.go b/internal/httpd/api_eventrule.go similarity index 98% rename from httpd/api_eventrule.go rename to internal/httpd/api_eventrule.go index 8c5beedc..197065c3 100644 --- a/httpd/api_eventrule.go +++ b/internal/httpd/api_eventrule.go @@ -20,8 +20,8 @@ import ( "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/util" ) func getEventActions(w http.ResponseWriter, r *http.Request) { diff --git a/httpd/api_events.go b/internal/httpd/api_events.go similarity index 97% rename from httpd/api_events.go rename to internal/httpd/api_events.go index 851393ea..530eac51 100644 --- a/httpd/api_events.go +++ b/internal/httpd/api_events.go @@ -21,9 +21,9 @@ import ( "github.com/sftpgo/sdk/plugin/eventsearcher" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" ) func getCommonSearchParamsFromRequest(r *http.Request) (eventsearcher.CommonSearchParams, error) { diff --git a/httpd/api_folder.go b/internal/httpd/api_folder.go similarity index 97% rename from httpd/api_folder.go rename to internal/httpd/api_folder.go index 3132866c..03fad5bd 100644 --- a/httpd/api_folder.go +++ b/internal/httpd/api_folder.go @@ -20,9 +20,9 @@ import ( "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) func getFolders(w http.ResponseWriter, r *http.Request) { diff --git a/httpd/api_group.go b/internal/httpd/api_group.go similarity index 97% rename from httpd/api_group.go rename to internal/httpd/api_group.go index 4ac78db2..d0e63119 100644 --- a/httpd/api_group.go +++ b/internal/httpd/api_group.go @@ -20,9 +20,9 @@ import ( "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) func getGroups(w http.ResponseWriter, r *http.Request) { diff --git a/httpd/api_http_user.go b/internal/httpd/api_http_user.go similarity index 98% rename from httpd/api_http_user.go rename to internal/httpd/api_http_user.go index 2d1a4872..9fd7cbd9 100644 --- a/httpd/api_http_user.go +++ b/internal/httpd/api_http_user.go @@ -28,10 +28,10 @@ import ( "github.com/go-chi/render" "github.com/rs/xid" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) func getUserConnection(w http.ResponseWriter, r *http.Request) (*Connection, error) { diff --git a/httpd/api_keys.go b/internal/httpd/api_keys.go similarity index 97% rename from httpd/api_keys.go rename to internal/httpd/api_keys.go index 9c6a9f5f..2e81923d 100644 --- a/httpd/api_keys.go +++ b/internal/httpd/api_keys.go @@ -21,8 +21,8 @@ import ( "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/util" ) func getAPIKeys(w http.ResponseWriter, r *http.Request) { diff --git a/httpd/api_maintenance.go b/internal/httpd/api_maintenance.go similarity index 98% rename from httpd/api_maintenance.go rename to internal/httpd/api_maintenance.go index e971d381..bbf86804 100644 --- a/httpd/api_maintenance.go +++ b/internal/httpd/api_maintenance.go @@ -27,10 +27,10 @@ import ( "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) func validateBackupFile(outputFile string) (string, error) { diff --git a/httpd/api_metadata.go b/internal/httpd/api_metadata.go similarity index 95% rename from httpd/api_metadata.go rename to internal/httpd/api_metadata.go index 5ddbc979..7bce3c9d 100644 --- a/httpd/api_metadata.go +++ b/internal/httpd/api_metadata.go @@ -22,9 +22,9 @@ import ( "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/httpd/api_mfa.go b/internal/httpd/api_mfa.go similarity index 97% rename from httpd/api_mfa.go rename to internal/httpd/api_mfa.go index 4ac1fb60..bbab7418 100644 --- a/httpd/api_mfa.go +++ b/internal/httpd/api_mfa.go @@ -21,10 +21,10 @@ import ( "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/util" ) type generateTOTPRequest struct { diff --git a/httpd/api_quota.go b/internal/httpd/api_quota.go similarity index 98% rename from httpd/api_quota.go rename to internal/httpd/api_quota.go index e8e9723e..c675a97c 100644 --- a/httpd/api_quota.go +++ b/internal/httpd/api_quota.go @@ -21,9 +21,9 @@ import ( "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/httpd/api_retention.go b/internal/httpd/api_retention.go similarity index 95% rename from httpd/api_retention.go rename to internal/httpd/api_retention.go index 78f1ca32..ff98cbff 100644 --- a/httpd/api_retention.go +++ b/internal/httpd/api_retention.go @@ -20,8 +20,8 @@ import ( "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" ) func getRetentionChecks(w http.ResponseWriter, r *http.Request) { diff --git a/httpd/api_shares.go b/internal/httpd/api_shares.go similarity index 98% rename from httpd/api_shares.go rename to internal/httpd/api_shares.go index 810f4aa5..233c1a69 100644 --- a/httpd/api_shares.go +++ b/internal/httpd/api_shares.go @@ -27,10 +27,10 @@ import ( "github.com/rs/xid" "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) func getShares(w http.ResponseWriter, r *http.Request) { diff --git a/httpd/api_user.go b/internal/httpd/api_user.go similarity index 97% rename from httpd/api_user.go rename to internal/httpd/api_user.go index 79a1bacf..74fa9837 100644 --- a/httpd/api_user.go +++ b/internal/httpd/api_user.go @@ -23,12 +23,12 @@ import ( "github.com/go-chi/render" "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) func getUsers(w http.ResponseWriter, r *http.Request) { diff --git a/httpd/api_utils.go b/internal/httpd/api_utils.go similarity index 98% rename from httpd/api_utils.go rename to internal/httpd/api_utils.go index d3c0c9d8..55ec124c 100644 --- a/httpd/api_utils.go +++ b/internal/httpd/api_utils.go @@ -35,13 +35,13 @@ import ( "github.com/go-chi/render" "github.com/klauspost/compress/zip" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" ) type pwdChange struct { diff --git a/httpd/auth_utils.go b/internal/httpd/auth_utils.go similarity index 98% rename from httpd/auth_utils.go rename to internal/httpd/auth_utils.go index e1fcfce6..8ee0459b 100644 --- a/httpd/auth_utils.go +++ b/internal/httpd/auth_utils.go @@ -24,9 +24,9 @@ import ( "github.com/lestrrat-go/jwx/jwt" "github.com/rs/xid" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) type tokenAudience = string diff --git a/httpd/file.go b/internal/httpd/file.go similarity index 97% rename from httpd/file.go rename to internal/httpd/file.go index 1aeb8d69..f79abf37 100644 --- a/httpd/file.go +++ b/internal/httpd/file.go @@ -20,8 +20,8 @@ import ( "github.com/eikenb/pipeat" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) type httpdFile struct { diff --git a/httpd/flash.go b/internal/httpd/flash.go similarity index 100% rename from httpd/flash.go rename to internal/httpd/flash.go diff --git a/httpd/flash_test.go b/internal/httpd/flash_test.go similarity index 100% rename from httpd/flash_test.go rename to internal/httpd/flash_test.go diff --git a/httpd/handler.go b/internal/httpd/handler.go similarity index 97% rename from httpd/handler.go rename to internal/httpd/handler.go index 1ed5a498..85bdda8d 100644 --- a/httpd/handler.go +++ b/internal/httpd/handler.go @@ -24,11 +24,11 @@ import ( "sync/atomic" "time" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // Connection details for a HTTP connection used to inteact with an SFTPGo filesystem diff --git a/httpd/httpd.go b/internal/httpd/httpd.go similarity index 98% rename from httpd/httpd.go rename to internal/httpd/httpd.go index 7a7227db..6ea2e738 100644 --- a/httpd/httpd.go +++ b/internal/httpd/httpd.go @@ -34,14 +34,14 @@ import ( "github.com/go-chi/jwtauth/v5" "github.com/lestrrat-go/jwx/jwa" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/ftpd" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/webdavd" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/ftpd" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/webdavd" ) const ( @@ -1013,7 +1013,7 @@ func updateWebAdminURLs(baseURL string) { // GetHTTPRouter returns an HTTP handler suitable to use for test cases func GetHTTPRouter(b Binding) http.Handler { - server := newHttpdServer(b, "../static", "", CorsConfig{}, "../openapi") + server := newHttpdServer(b, filepath.Join("..", "..", "static"), "", CorsConfig{}, filepath.Join("..", "..", "openapi")) server.initializeRouter() return server.router } diff --git a/httpd/httpd_test.go b/internal/httpd/httpd_test.go similarity index 99% rename from httpd/httpd_test.go rename to internal/httpd/httpd_test.go index e3ac7a93..423427f5 100644 --- a/httpd/httpd_test.go +++ b/internal/httpd/httpd_test.go @@ -56,20 +56,20 @@ import ( "golang.org/x/crypto/bcrypt" "golang.org/x/net/html" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/httpd" - "github.com/drakkan/sftpgo/v2/httpdtest" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/httpd" + "github.com/drakkan/sftpgo/v2/internal/httpdtest" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( @@ -182,7 +182,6 @@ const ( defaultRemoteAddr = "127.0.0.1:1234" sftpServerAddr = "127.0.0.1:8022" smtpServerAddr = "127.0.0.1:3525" - configDir = ".." httpsCert = `-----BEGIN CERTIFICATE----- MIICHTCCAaKgAwIBAgIUHnqw7QnB1Bj9oUsNpdb+ZkFPOxMwCgYIKoZIzj0EAwIw RTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGElu @@ -232,6 +231,7 @@ qwlk5iw/jQekxThg== ) var ( + configDir = filepath.Join(".", "..", "..") defaultPerms = []string{dataprovider.PermAny} homeBasePath string backupsPath string @@ -313,7 +313,7 @@ func TestMain(m *testing.M) { pluginsConfig := []plugin.Config{ { Type: "eventsearcher", - Cmd: filepath.Join(wdPath, "..", "tests", "eventsearcher", "eventsearcher"), + Cmd: filepath.Join(wdPath, "..", "..", "tests", "eventsearcher", "eventsearcher"), AutoMTLS: true, }, } @@ -5027,7 +5027,7 @@ func TestNamingRules(t *testing.T) { Port: 3525, TemplatesPath: "templates", } - err := smtpCfg.Initialize("..") + err := smtpCfg.Initialize(configDir) require.NoError(t, err) err = dataprovider.Close() assert.NoError(t, err) @@ -5233,7 +5233,7 @@ func TestNamingRules(t *testing.T) { assert.NoError(t, err) smtpCfg = smtp.Config{} - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) } @@ -10464,7 +10464,7 @@ func TestMaxSessions(t *testing.T) { Port: 3525, TemplatesPath: "templates", } - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) assert.NoError(t, err) csrfToken, err := getCSRFToken(httpBaseURL + webLoginPath) @@ -10493,7 +10493,7 @@ func TestMaxSessions(t *testing.T) { assert.Contains(t, rr.Body.String(), "Password reset successfully but unable to login") smtpCfg = smtp.Config{} - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) common.Connections.Remove(connection.GetID()) @@ -10541,7 +10541,7 @@ func TestSFTPLoopError(t *testing.T) { Port: 3525, TemplatesPath: "templates", } - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) assert.NoError(t, err) csrfToken, err := getCSRFToken(httpBaseURL + webLoginPath) @@ -10570,7 +10570,7 @@ func TestSFTPLoopError(t *testing.T) { assert.Contains(t, rr.Body.String(), "Password reset successfully but unable to login") smtpCfg = smtp.Config{} - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) _, err = httpdtest.RemoveUser(user1, http.StatusOK) @@ -19658,7 +19658,7 @@ func TestAdminForgotPassword(t *testing.T) { Port: 3525, TemplatesPath: "templates", } - err := smtpCfg.Initialize("..") + err := smtpCfg.Initialize(configDir) require.NoError(t, err) a := getTestAdmin() @@ -19763,7 +19763,7 @@ func TestAdminForgotPassword(t *testing.T) { Port: 3526, TemplatesPath: "templates", } - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) form = make(url.Values) @@ -19778,7 +19778,7 @@ func TestAdminForgotPassword(t *testing.T) { assert.Contains(t, rr.Body.String(), "Unable to send confirmation code via email") smtpCfg = smtp.Config{} - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) form.Set("username", altAdminUsername) @@ -19811,7 +19811,7 @@ func TestUserForgotPassword(t *testing.T) { Port: 3525, TemplatesPath: "templates", } - err := smtpCfg.Initialize("..") + err := smtpCfg.Initialize(configDir) require.NoError(t, err) u := getTestUser() @@ -19924,7 +19924,7 @@ func TestUserForgotPassword(t *testing.T) { assert.GreaterOrEqual(t, len(lastResetCode), 20) smtpCfg = smtp.Config{} - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) req, err = http.NewRequest(http.MethodGet, webClientForgotPwdPath, nil) @@ -19961,7 +19961,7 @@ func TestAPIForgotPassword(t *testing.T) { Port: 3525, TemplatesPath: "templates", } - err := smtpCfg.Initialize("..") + err := smtpCfg.Initialize(configDir) require.NoError(t, err) a := getTestAdmin() @@ -20106,7 +20106,7 @@ func TestAPIForgotPassword(t *testing.T) { assert.GreaterOrEqual(t, len(lastResetCode), 20) smtpCfg = smtp.Config{} - err = smtpCfg.Initialize("..") + err = smtpCfg.Initialize(configDir) require.NoError(t, err) // without an smtp configuration reset password is not available diff --git a/httpd/internal_test.go b/internal/httpd/internal_test.go similarity index 99% rename from httpd/internal_test.go rename to internal/httpd/internal_test.go index 6723d5ce..0567b636 100644 --- a/httpd/internal_test.go +++ b/internal/httpd/internal_test.go @@ -47,12 +47,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( @@ -284,6 +284,10 @@ xr5cb9VBRBtB9aOKVfuRhpatAfS2Pzm2Htae9lFn7slGPUmu2hkjDw== defaultAdminUsername = "admin" ) +var ( + configDir = filepath.Join(".", "..", "..") +) + type failingWriter struct { } @@ -2541,7 +2545,7 @@ func TestWebAdminSetupWithInstallCode(t *testing.T) { providerConf.CreateDefaultAdmin = false err = dataprovider.Close() assert.NoError(t, err) - err = dataprovider.Initialize(providerConf, "..", true) + err = dataprovider.Initialize(providerConf, configDir, true) assert.NoError(t, err) server := httpdServer{ @@ -2599,7 +2603,7 @@ func TestWebAdminSetupWithInstallCode(t *testing.T) { err = dataprovider.Close() assert.NoError(t, err) - err = dataprovider.Initialize(providerConf, "..", true) + err = dataprovider.Initialize(providerConf, configDir, true) assert.NoError(t, err) SetInstallationCodeResolver(func(defaultInstallationCode string) string { @@ -2652,7 +2656,7 @@ func TestWebAdminSetupWithInstallCode(t *testing.T) { err = dataprovider.Close() assert.NoError(t, err) providerConf.CreateDefaultAdmin = true - err = dataprovider.Initialize(providerConf, "..", true) + err = dataprovider.Initialize(providerConf, configDir, true) assert.NoError(t, err) installationCode = "" SetInstallationCodeResolver(nil) diff --git a/httpd/middleware.go b/internal/httpd/middleware.go similarity index 98% rename from httpd/middleware.go rename to internal/httpd/middleware.go index d920ee7b..30a01748 100644 --- a/httpd/middleware.go +++ b/internal/httpd/middleware.go @@ -25,10 +25,10 @@ import ( "github.com/rs/xid" "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/httpd/oidc.go b/internal/httpd/oidc.go similarity index 98% rename from httpd/oidc.go rename to internal/httpd/oidc.go index 89a86f18..9d4118e5 100644 --- a/httpd/oidc.go +++ b/internal/httpd/oidc.go @@ -27,11 +27,11 @@ import ( "github.com/rs/xid" "golang.org/x/oauth2" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/httpd/oidc_test.go b/internal/httpd/oidc_test.go similarity index 99% rename from httpd/oidc_test.go rename to internal/httpd/oidc_test.go index dfd48327..ae28cd30 100644 --- a/httpd/oidc_test.go +++ b/internal/httpd/oidc_test.go @@ -39,11 +39,11 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/oauth2" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( @@ -1051,7 +1051,7 @@ func TestOIDCPreLoginHook(t *testing.T) { assert.NoError(t, err) newProviderConf := providerConf newProviderConf.PreLoginHook = preLoginPath - err = dataprovider.Initialize(newProviderConf, "..", true) + err = dataprovider.Initialize(newProviderConf, configDir, true) assert.NoError(t, err) server := getTestOIDCServer() server.binding.OIDC.CustomFields = []string{"field1", "field2"} @@ -1133,7 +1133,7 @@ func TestOIDCPreLoginHook(t *testing.T) { err = dataprovider.Close() assert.NoError(t, err) - err = dataprovider.Initialize(providerConf, "..", true) + err = dataprovider.Initialize(providerConf, configDir, true) assert.NoError(t, err) err = os.Remove(preLoginPath) assert.NoError(t, err) diff --git a/httpd/oidcmanager.go b/internal/httpd/oidcmanager.go similarity index 97% rename from httpd/oidcmanager.go rename to internal/httpd/oidcmanager.go index 0b71dd33..3a0172f1 100644 --- a/httpd/oidcmanager.go +++ b/internal/httpd/oidcmanager.go @@ -20,9 +20,9 @@ import ( "sync" "time" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/httpd/resetcode.go b/internal/httpd/resetcode.go similarity index 96% rename from httpd/resetcode.go rename to internal/httpd/resetcode.go index 271c1731..29965f70 100644 --- a/httpd/resetcode.go +++ b/internal/httpd/resetcode.go @@ -19,9 +19,9 @@ import ( "sync" "time" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/httpd/server.go b/internal/httpd/server.go similarity index 99% rename from httpd/server.go rename to internal/httpd/server.go index ed47128a..102e81a2 100644 --- a/httpd/server.go +++ b/internal/httpd/server.go @@ -37,13 +37,13 @@ import ( "github.com/sftpgo/sdk" "github.com/unrolled/secure" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" ) var ( diff --git a/httpd/web.go b/internal/httpd/web.go similarity index 100% rename from httpd/web.go rename to internal/httpd/web.go diff --git a/httpd/webadmin.go b/internal/httpd/webadmin.go similarity index 99% rename from httpd/webadmin.go rename to internal/httpd/webadmin.go index 5a19e918..1567ea52 100644 --- a/httpd/webadmin.go +++ b/internal/httpd/webadmin.go @@ -31,14 +31,14 @@ import ( "github.com/sftpgo/sdk" sdkkms "github.com/sftpgo/sdk/kms" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) type userPageMode int diff --git a/httpd/webclient.go b/internal/httpd/webclient.go similarity index 99% rename from httpd/webclient.go rename to internal/httpd/webclient.go index d2e9095c..b3447d2f 100644 --- a/httpd/webclient.go +++ b/internal/httpd/webclient.go @@ -34,13 +34,13 @@ import ( "github.com/rs/xid" "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/smtp" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/smtp" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/httpdtest/httpdtest.go b/internal/httpdtest/httpdtest.go similarity index 99% rename from httpdtest/httpdtest.go rename to internal/httpdtest/httpdtest.go index 5ad98c59..d1e3d209 100644 --- a/httpdtest/httpdtest.go +++ b/internal/httpdtest/httpdtest.go @@ -31,14 +31,14 @@ import ( "github.com/go-chi/render" "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/httpd" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/httpd" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/httpdtest/httpfsimpl.go b/internal/httpdtest/httpfsimpl.go similarity index 99% rename from httpdtest/httpfsimpl.go rename to internal/httpdtest/httpfsimpl.go index 52dc6d7d..84323a4a 100644 --- a/httpdtest/httpfsimpl.go +++ b/internal/httpdtest/httpfsimpl.go @@ -33,7 +33,7 @@ import ( "github.com/go-chi/render" "github.com/shirou/gopsutil/v3/disk" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/kms/basesecret.go b/internal/kms/basesecret.go similarity index 100% rename from kms/basesecret.go rename to internal/kms/basesecret.go diff --git a/kms/builtin.go b/internal/kms/builtin.go similarity index 100% rename from kms/builtin.go rename to internal/kms/builtin.go diff --git a/kms/kms.go b/internal/kms/kms.go similarity index 99% rename from kms/kms.go rename to internal/kms/kms.go index 2a9b85c6..0f159726 100644 --- a/kms/kms.go +++ b/internal/kms/kms.go @@ -24,7 +24,7 @@ import ( sdkkms "github.com/sftpgo/sdk/kms" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) // SecretProvider defines the interface for a KMS secrets provider diff --git a/kms/local.go b/internal/kms/local.go similarity index 100% rename from kms/local.go rename to internal/kms/local.go diff --git a/logger/hclog.go b/internal/logger/hclog.go similarity index 100% rename from logger/hclog.go rename to internal/logger/hclog.go diff --git a/logger/journald.go b/internal/logger/journald.go similarity index 100% rename from logger/journald.go rename to internal/logger/journald.go diff --git a/logger/journald_nolinux.go b/internal/logger/journald_nolinux.go similarity index 100% rename from logger/journald_nolinux.go rename to internal/logger/journald_nolinux.go diff --git a/logger/lego.go b/internal/logger/lego.go similarity index 100% rename from logger/lego.go rename to internal/logger/lego.go diff --git a/logger/logger.go b/internal/logger/logger.go similarity index 100% rename from logger/logger.go rename to internal/logger/logger.go diff --git a/logger/request_logger.go b/internal/logger/request_logger.go similarity index 98% rename from logger/request_logger.go rename to internal/logger/request_logger.go index 0cf50399..4fd43337 100644 --- a/logger/request_logger.go +++ b/internal/logger/request_logger.go @@ -23,7 +23,7 @@ import ( "github.com/go-chi/chi/v5/middleware" "github.com/rs/zerolog" - "github.com/drakkan/sftpgo/v2/metric" + "github.com/drakkan/sftpgo/v2/internal/metric" ) // StructuredLogger defines a simple wrapper around zerolog logger. diff --git a/logger/sync_wrapper.go b/internal/logger/sync_wrapper.go similarity index 100% rename from logger/sync_wrapper.go rename to internal/logger/sync_wrapper.go diff --git a/metric/metric.go b/internal/metric/metric.go similarity index 99% rename from metric/metric.go rename to internal/metric/metric.go index 221699e0..660b4231 100644 --- a/metric/metric.go +++ b/internal/metric/metric.go @@ -24,7 +24,7 @@ import ( "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promhttp" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/version" ) const ( diff --git a/metric/metric_disabled.go b/internal/metric/metric_disabled.go similarity index 98% rename from metric/metric_disabled.go rename to internal/metric/metric_disabled.go index 33f7862d..854cd0eb 100644 --- a/metric/metric_disabled.go +++ b/internal/metric/metric_disabled.go @@ -6,7 +6,7 @@ package metric import ( "github.com/go-chi/chi/v5" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/version" ) func init() { diff --git a/mfa/mfa.go b/internal/mfa/mfa.go similarity index 100% rename from mfa/mfa.go rename to internal/mfa/mfa.go diff --git a/mfa/mfa_test.go b/internal/mfa/mfa_test.go similarity index 100% rename from mfa/mfa_test.go rename to internal/mfa/mfa_test.go diff --git a/mfa/totp.go b/internal/mfa/totp.go similarity index 100% rename from mfa/totp.go rename to internal/mfa/totp.go diff --git a/plugin/auth.go b/internal/plugin/auth.go similarity index 99% rename from plugin/auth.go rename to internal/plugin/auth.go index f0e676c9..d6b5446d 100644 --- a/plugin/auth.go +++ b/internal/plugin/auth.go @@ -24,7 +24,7 @@ import ( "github.com/hashicorp/go-plugin" "github.com/sftpgo/sdk/plugin/auth" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) // Supported auth scopes diff --git a/plugin/ipfilter.go b/internal/plugin/ipfilter.go similarity index 98% rename from plugin/ipfilter.go rename to internal/plugin/ipfilter.go index 1def39c3..e0274e1c 100644 --- a/plugin/ipfilter.go +++ b/internal/plugin/ipfilter.go @@ -23,7 +23,7 @@ import ( "github.com/hashicorp/go-plugin" "github.com/sftpgo/sdk/plugin/ipfilter" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) type ipFilterPlugin struct { diff --git a/plugin/kms.go b/internal/plugin/kms.go similarity index 97% rename from plugin/kms.go rename to internal/plugin/kms.go index cb3073c5..db46a986 100644 --- a/plugin/kms.go +++ b/internal/plugin/kms.go @@ -25,9 +25,9 @@ import ( sdkkms "github.com/sftpgo/sdk/kms" kmsplugin "github.com/sftpgo/sdk/plugin/kms" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) var ( diff --git a/plugin/metadata.go b/internal/plugin/metadata.go similarity index 98% rename from plugin/metadata.go rename to internal/plugin/metadata.go index 74f164ed..e48cf0da 100644 --- a/plugin/metadata.go +++ b/internal/plugin/metadata.go @@ -23,7 +23,7 @@ import ( "github.com/hashicorp/go-plugin" "github.com/sftpgo/sdk/plugin/metadata" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) type metadataPlugin struct { diff --git a/plugin/notifier.go b/internal/plugin/notifier.go similarity index 98% rename from plugin/notifier.go rename to internal/plugin/notifier.go index e8760901..9a1d1745 100644 --- a/plugin/notifier.go +++ b/internal/plugin/notifier.go @@ -25,8 +25,8 @@ import ( "github.com/hashicorp/go-plugin" "github.com/sftpgo/sdk/plugin/notifier" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) // NotifierConfig defines configuration parameters for notifiers plugins diff --git a/plugin/plugin.go b/internal/plugin/plugin.go similarity index 99% rename from plugin/plugin.go rename to internal/plugin/plugin.go index 9741b25a..57101b9d 100644 --- a/plugin/plugin.go +++ b/internal/plugin/plugin.go @@ -31,9 +31,9 @@ import ( "github.com/sftpgo/sdk/plugin/metadata" "github.com/sftpgo/sdk/plugin/notifier" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/plugin/searcher.go b/internal/plugin/searcher.go similarity index 98% rename from plugin/searcher.go rename to internal/plugin/searcher.go index e4e1d26e..abeb7688 100644 --- a/plugin/searcher.go +++ b/internal/plugin/searcher.go @@ -23,7 +23,7 @@ import ( "github.com/hashicorp/go-plugin" "github.com/sftpgo/sdk/plugin/eventsearcher" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) type searcherPlugin struct { diff --git a/plugin/util.go b/internal/plugin/util.go similarity index 95% rename from plugin/util.go rename to internal/plugin/util.go index e3b692e1..ef7a52ad 100644 --- a/plugin/util.go +++ b/internal/plugin/util.go @@ -17,7 +17,7 @@ package plugin import ( "github.com/shirou/gopsutil/v3/process" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) func killProcess(processPath string) { diff --git a/service/awscontainer.go b/internal/service/awscontainer.go similarity index 96% rename from service/awscontainer.go rename to internal/service/awscontainer.go index 3047a472..fee4a5e7 100644 --- a/service/awscontainer.go +++ b/internal/service/awscontainer.go @@ -30,11 +30,11 @@ import ( "github.com/aws/aws-sdk-go-v2/service/secretsmanager" "github.com/google/uuid" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpd" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpd" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/service/awscontainer_disabled.go b/internal/service/awscontainer_disabled.go similarity index 100% rename from service/awscontainer_disabled.go rename to internal/service/awscontainer_disabled.go diff --git a/service/service.go b/internal/service/service.go similarity index 97% rename from service/service.go rename to internal/service/service.go index b0696088..78d374a3 100644 --- a/service/service.go +++ b/internal/service/service.go @@ -23,14 +23,14 @@ import ( "github.com/rs/zerolog" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpd" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpd" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" ) const ( diff --git a/service/service_portable.go b/internal/service/service_portable.go similarity index 96% rename from service/service_portable.go rename to internal/service/service_portable.go index 411782c1..5a01a092 100644 --- a/service/service_portable.go +++ b/internal/service/service_portable.go @@ -29,15 +29,15 @@ import ( "github.com/grandcat/zeroconf" "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/ftpd" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" - "github.com/drakkan/sftpgo/v2/webdavd" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/ftpd" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" + "github.com/drakkan/sftpgo/v2/internal/webdavd" ) // StartPortableMode starts the service in portable mode diff --git a/service/service_windows.go b/internal/service/service_windows.go similarity index 95% rename from service/service_windows.go rename to internal/service/service_windows.go index 3f706954..228b6b42 100644 --- a/service/service_windows.go +++ b/internal/service/service_windows.go @@ -25,15 +25,15 @@ import ( "golang.org/x/sys/windows/svc/eventlog" "golang.org/x/sys/windows/svc/mgr" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/ftpd" - "github.com/drakkan/sftpgo/v2/httpd" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/telemetry" - "github.com/drakkan/sftpgo/v2/webdavd" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/ftpd" + "github.com/drakkan/sftpgo/v2/internal/httpd" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/telemetry" + "github.com/drakkan/sftpgo/v2/internal/webdavd" ) const ( diff --git a/service/signals_unix.go b/internal/service/signals_unix.go similarity index 84% rename from service/signals_unix.go rename to internal/service/signals_unix.go index 756f3308..5c387194 100644 --- a/service/signals_unix.go +++ b/internal/service/signals_unix.go @@ -22,15 +22,15 @@ import ( "os/signal" "syscall" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/ftpd" - "github.com/drakkan/sftpgo/v2/httpd" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/telemetry" - "github.com/drakkan/sftpgo/v2/webdavd" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/ftpd" + "github.com/drakkan/sftpgo/v2/internal/httpd" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/telemetry" + "github.com/drakkan/sftpgo/v2/internal/webdavd" ) func registerSignals() { diff --git a/service/signals_windows.go b/internal/service/signals_windows.go similarity index 90% rename from service/signals_windows.go rename to internal/service/signals_windows.go index caabf1eb..06bfe1d2 100644 --- a/service/signals_windows.go +++ b/internal/service/signals_windows.go @@ -18,8 +18,8 @@ import ( "os" "os/signal" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/plugin" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/plugin" ) func registerSignals() { diff --git a/sftpd/cmd_unix.go b/internal/sftpd/cmd_unix.go similarity index 100% rename from sftpd/cmd_unix.go rename to internal/sftpd/cmd_unix.go diff --git a/sftpd/cmd_windows.go b/internal/sftpd/cmd_windows.go similarity index 100% rename from sftpd/cmd_windows.go rename to internal/sftpd/cmd_windows.go diff --git a/sftpd/cryptfs_test.go b/internal/sftpd/cryptfs_test.go similarity index 98% rename from sftpd/cryptfs_test.go rename to internal/sftpd/cryptfs_test.go index e0238fc0..cd1068de 100644 --- a/sftpd/cryptfs_test.go +++ b/internal/sftpd/cryptfs_test.go @@ -28,10 +28,10 @@ import ( "github.com/sftpgo/sdk" "github.com/stretchr/testify/assert" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpdtest" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpdtest" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/sftpd/handler.go b/internal/sftpd/handler.go similarity index 98% rename from sftpd/handler.go rename to internal/sftpd/handler.go index 6cdc3dc9..107aad89 100644 --- a/sftpd/handler.go +++ b/internal/sftpd/handler.go @@ -24,11 +24,11 @@ import ( "github.com/pkg/sftp" "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // Connection details for an authenticated user diff --git a/sftpd/httpfs_test.go b/internal/sftpd/httpfs_test.go similarity index 98% rename from sftpd/httpfs_test.go rename to internal/sftpd/httpfs_test.go index a5cb015f..cfee8fab 100644 --- a/sftpd/httpfs_test.go +++ b/internal/sftpd/httpfs_test.go @@ -31,10 +31,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpdtest" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpdtest" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/sftpd/internal_test.go b/internal/sftpd/internal_test.go similarity index 99% rename from sftpd/internal_test.go rename to internal/sftpd/internal_test.go index 3bdb6b6c..ac44c2a8 100644 --- a/sftpd/internal_test.go +++ b/internal/sftpd/internal_test.go @@ -34,14 +34,20 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/crypto/ssh" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) -const osWindows = "windows" +const ( + osWindows = "windows" +) + +var ( + configDir = filepath.Join(".", "..", "..") +) type MockChannel struct { Buffer *bytes.Buffer @@ -1912,7 +1918,6 @@ func TestSupportedSecurityOptions(t *testing.T) { } func TestLoadHostKeys(t *testing.T) { - configDir := ".." serverConfig := &ssh.ServerConfig{} c := Configuration{} c.HostKeys = []string{".", "missing file"} diff --git a/sftpd/internal_unix_test.go b/internal/sftpd/internal_unix_test.go similarity index 100% rename from sftpd/internal_unix_test.go rename to internal/sftpd/internal_unix_test.go diff --git a/sftpd/lister.go b/internal/sftpd/lister.go similarity index 100% rename from sftpd/lister.go rename to internal/sftpd/lister.go diff --git a/sftpd/middleware.go b/internal/sftpd/middleware.go similarity index 99% rename from sftpd/middleware.go rename to internal/sftpd/middleware.go index 6b54e0b6..c508bdf7 100644 --- a/sftpd/middleware.go +++ b/internal/sftpd/middleware.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/sftp" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // Middleware defines the interface for SFTP middlewares diff --git a/sftpd/middleware_test.go b/internal/sftpd/middleware_test.go similarity index 99% rename from sftpd/middleware_test.go rename to internal/sftpd/middleware_test.go index e8980568..7d3cf790 100644 --- a/sftpd/middleware_test.go +++ b/internal/sftpd/middleware_test.go @@ -22,7 +22,7 @@ import ( "github.com/pkg/sftp" "github.com/stretchr/testify/suite" - "github.com/drakkan/sftpgo/v2/sftpd/mocks" + "github.com/drakkan/sftpgo/v2/internal/sftpd/mocks" ) type PrefixMiddlewareSuite struct { diff --git a/sftpd/mocks/middleware.go b/internal/sftpd/mocks/middleware.go similarity index 100% rename from sftpd/mocks/middleware.go rename to internal/sftpd/mocks/middleware.go diff --git a/sftpd/scp.go b/internal/sftpd/scp.go similarity index 99% rename from sftpd/scp.go rename to internal/sftpd/scp.go index c33b8a7a..e7dc1093 100644 --- a/sftpd/scp.go +++ b/internal/sftpd/scp.go @@ -26,11 +26,11 @@ import ( "strconv" "strings" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) var ( diff --git a/sftpd/server.go b/internal/sftpd/server.go similarity index 99% rename from sftpd/server.go rename to internal/sftpd/server.go index 86dde346..0ec0fe5b 100644 --- a/sftpd/server.go +++ b/internal/sftpd/server.go @@ -34,12 +34,12 @@ import ( "github.com/pkg/sftp" "golang.org/x/crypto/ssh" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/sftpd/sftpd.go b/internal/sftpd/sftpd.go similarity index 100% rename from sftpd/sftpd.go rename to internal/sftpd/sftpd.go diff --git a/sftpd/sftpd_test.go b/internal/sftpd/sftpd_test.go similarity index 99% rename from sftpd/sftpd_test.go rename to internal/sftpd/sftpd_test.go index ea46d1aa..edbb92eb 100644 --- a/sftpd/sftpd_test.go +++ b/internal/sftpd/sftpd_test.go @@ -57,16 +57,16 @@ import ( "github.com/stretchr/testify/assert" "golang.org/x/crypto/ssh" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpdtest" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/mfa" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpdtest" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/mfa" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( @@ -148,13 +148,13 @@ qwlk5iw/jQekxThg== // this is testPubKey signed without a principal // ssh-keygen -s ca_user_key -I test_user_sftp -V always:forever -O source-address=127.0.0.1 -z 1 /tmp/test.pub testCertNoPrincipals = "ssh-rsa-cert-v01@openssh.com AAAAHHNzaC1yc2EtY2VydC12MDFAb3BlbnNzaC5jb20AAAAg2Bx0s8nafJtriqoBuQfbFByhdQMkjDIZhV90JZSGN8AAAAADAQABAAABgQC03jj0D+djk7pxIf/0OhrxrchJTRZklofJ1NoIu4752Sq02mdXmarMVsqJ1cAjV5LBVy3D1F5U6XW4rppkXeVtd04Pxb09ehtH0pRRPaoHHlALiJt8CoMpbKYMA8b3KXPPriGxgGomvtU2T2RMURSwOZbMtpsugfjYSWenyYX+VORYhylWnSXL961LTyC21ehd6d6QnW9G7E5hYMITMY9TuQZz3bROYzXiTsgN0+g6Hn7exFQp50p45StUMfV/SftCMdCxlxuyGny2CrN/vfjO7xxOo2uv7q1qm10Q46KPWJQv+pgZ/OfL+EDjy07n5QVSKHlbx+2nT4Q0EgOSQaCTYwn3YjtABfIxWwgAFdyj6YlPulCL22qU4MYhDcA6PSBwDdf8hvxBfvsiHdM+JcSHvv8/VeJhk6CmnZxGY0fxBupov27z3yEO8nAg8k+6PaUiW1MSUfuGMF/ktB8LOstXsEPXSszuyXiOv4DaryOXUiSn7bmRqKcEFlJusO6aZP0AAAAAAAAAAQAAAAEAAAAOdGVzdF91c2VyX3NmdHAAAAAAAAAAAAAAAAD//////////wAAACMAAAAOc291cmNlLWFkZHJlc3MAAAANAAAACTEyNy4wLjAuMQAAAIIAAAAVcGVybWl0LVgxMS1mb3J3YXJkaW5nAAAAAAAAABdwZXJtaXQtYWdlbnQtZm9yd2FyZGluZwAAAAAAAAAWcGVybWl0LXBvcnQtZm9yd2FyZGluZwAAAAAAAAAKcGVybWl0LXB0eQAAAAAAAAAOcGVybWl0LXVzZXItcmMAAAAAAAAAAAAAAZcAAAAHc3NoLXJzYQAAAAMBAAEAAAGBAMXl9zBkeLKLGacToiU5kmlmFZeiHraA37Jp0ADQYnnT1IARplUs8M/xLlGwTyZSKRHfDHKdWyHEd6oyGuRL5GU1uFKU5cN02D3jJOur/EXxn8+ApEie95/viTmLtsAjK3NruMRHMUn+6NMTLfnftPmTkRhAnXllAa6/PKdJ2/7qj31KMjiMWmXJA5nZBxhsQCaEebkaBCUiIQUb9GUO0uSw66UpnE5jeo/M/QDJDG1klef/m8bjRpb0tNvDEImpaWCuQVcyoABUJu5TliynCGJeYq3U+yV2JfDbeiWhrhxoIo3WPNsWIa5k1cRTYRvHski+NAI9pRjAuMRuREPEOo3++bBmoG4piK4b0Rp/H6cVJCSvtBhvlv6ZP7/UgUeeZ5EaffzvfWQGq0fu2nML+36yhFf2nYe0kz70xiFuU7Y6pNI8ZOXGKFZSTKJEF6SkCFqIeV3XpOwb4Dds4keuiMZxf7mDqgZqsoYsAxzKQvVf6tmpP33cyjp3Znurjcw5cQAAAZQAAAAMcnNhLXNoYTItNTEyAAABgHgax/++NA5YZXDHH180BcQtDBve8Vc+XJzqQUe8xBiqd+KJnas6He7vW62qMaAfu63i0Uycj2Djfjy5dyx1GB9wup8YuP5mXlmJTx+7UPPjwbfrZWtk8iJ7KhFAwjh0KRZD4uIvoeecK8QE9zh64k2LNVqlWbFTdoPulRC29cGcXDpMU2eToFEyWbceHOZyyifXf98ZMZbaQzWzwSZ5rFucJ1b0aeT6aAJWB+Dq7mIQWf/jCWr8kNaeCzMKJsFQkQEfmHls29ChV92sNRhngUDxll0Ir0wpPea1fFEBnUhLRTLC8GhDDbWAzsZtXqx9fjoAkb/gwsU6TGxevuOMxEABjDA9PyJiTXJI9oTUCwDIAUVVFLsCEum3o/BblngXajUGibaif5ZSKBocpP70oTeAngQYB7r1/vquQzGsGFhTN4FUXLSpLu9Zqi1z58/qa7SgKSfNp98X/4zrhltAX73ZEvg0NUMv2HwlwlqHdpF3FYolAxInp7c2jBTncQ2l3w== nicola@p1" - configDir = ".." osWindows = "windows" testFileName = "test_file_sftp.dat" testDLFileName = "test_download_sftp.dat" ) var ( + configDir = filepath.Join(".", "..", "..") allPerms = []string{dataprovider.PermAny} homeBasePath string scpPath string diff --git a/sftpd/ssh_cmd.go b/internal/sftpd/ssh_cmd.go similarity index 98% rename from sftpd/ssh_cmd.go rename to internal/sftpd/ssh_cmd.go index 5ded511a..d6b67a47 100644 --- a/sftpd/ssh_cmd.go +++ b/internal/sftpd/ssh_cmd.go @@ -35,12 +35,12 @@ import ( "github.com/sftpgo/sdk" "golang.org/x/crypto/ssh" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/sftpd/subsystem.go b/internal/sftpd/subsystem.go similarity index 94% rename from sftpd/subsystem.go rename to internal/sftpd/subsystem.go index e76e5e03..85fad63b 100644 --- a/sftpd/subsystem.go +++ b/internal/sftpd/subsystem.go @@ -20,9 +20,9 @@ import ( "github.com/pkg/sftp" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" ) type subsystemChannel struct { diff --git a/sftpd/transfer.go b/internal/sftpd/transfer.go similarity index 97% rename from sftpd/transfer.go rename to internal/sftpd/transfer.go index cef4d5bd..ce0e0178 100644 --- a/sftpd/transfer.go +++ b/internal/sftpd/transfer.go @@ -21,9 +21,9 @@ import ( "github.com/eikenb/pipeat" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) type writerAtCloser interface { diff --git a/smtp/smtp.go b/internal/smtp/smtp.go similarity index 98% rename from smtp/smtp.go rename to internal/smtp/smtp.go index 9593dbe7..c216f700 100644 --- a/smtp/smtp.go +++ b/internal/smtp/smtp.go @@ -25,8 +25,8 @@ import ( mail "github.com/xhit/go-simple-mail/v2" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/telemetry/router.go b/internal/telemetry/router.go similarity index 93% rename from telemetry/router.go rename to internal/telemetry/router.go index d1e49440..39ccf0e6 100644 --- a/telemetry/router.go +++ b/internal/telemetry/router.go @@ -21,9 +21,9 @@ import ( "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/render" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" ) func initializeRouter(enableProfiler bool) { diff --git a/telemetry/telemetry.go b/internal/telemetry/telemetry.go similarity index 97% rename from telemetry/telemetry.go rename to internal/telemetry/telemetry.go index fd5cda2d..76adf40b 100644 --- a/telemetry/telemetry.go +++ b/internal/telemetry/telemetry.go @@ -28,9 +28,9 @@ import ( "github.com/go-chi/chi/v5" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/telemetry/telemetry_test.go b/internal/telemetry/telemetry_test.go similarity index 99% rename from telemetry/telemetry_test.go rename to internal/telemetry/telemetry_test.go index 3fa71c40..d8731da1 100644 --- a/telemetry/telemetry_test.go +++ b/internal/telemetry/telemetry_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/drakkan/sftpgo/v2/common" + "github.com/drakkan/sftpgo/v2/internal/common" ) const ( diff --git a/util/errors.go b/internal/util/errors.go similarity index 100% rename from util/errors.go rename to internal/util/errors.go diff --git a/util/timeoutlistener.go b/internal/util/timeoutlistener.go similarity index 100% rename from util/timeoutlistener.go rename to internal/util/timeoutlistener.go diff --git a/util/util.go b/internal/util/util.go similarity index 99% rename from util/util.go rename to internal/util/util.go index 3f534ee9..78a3b692 100644 --- a/util/util.go +++ b/internal/util/util.go @@ -46,7 +46,7 @@ import ( "github.com/rs/xid" "golang.org/x/crypto/ssh" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) const ( diff --git a/version/version.go b/internal/version/version.go similarity index 100% rename from version/version.go rename to internal/version/version.go diff --git a/vfs/azblobfs.go b/internal/vfs/azblobfs.go similarity index 99% rename from vfs/azblobfs.go rename to internal/vfs/azblobfs.go index ba8f02d6..dc9508f3 100644 --- a/vfs/azblobfs.go +++ b/internal/vfs/azblobfs.go @@ -40,11 +40,11 @@ import ( "github.com/eikenb/pipeat" "github.com/pkg/sftp" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" ) const ( diff --git a/vfs/azblobfs_disabled.go b/internal/vfs/azblobfs_disabled.go similarity index 95% rename from vfs/azblobfs_disabled.go rename to internal/vfs/azblobfs_disabled.go index d3e6d312..690e1408 100644 --- a/vfs/azblobfs_disabled.go +++ b/internal/vfs/azblobfs_disabled.go @@ -20,7 +20,7 @@ package vfs import ( "errors" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/version" ) func init() { diff --git a/vfs/cryptfs.go b/internal/vfs/cryptfs.go similarity index 99% rename from vfs/cryptfs.go rename to internal/vfs/cryptfs.go index 7a1515af..388c9f54 100644 --- a/vfs/cryptfs.go +++ b/internal/vfs/cryptfs.go @@ -27,7 +27,7 @@ import ( "github.com/minio/sio" "golang.org/x/crypto/hkdf" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) const ( diff --git a/vfs/fileinfo.go b/internal/vfs/fileinfo.go similarity index 100% rename from vfs/fileinfo.go rename to internal/vfs/fileinfo.go diff --git a/vfs/filesystem.go b/internal/vfs/filesystem.go similarity index 99% rename from vfs/filesystem.go rename to internal/vfs/filesystem.go index 610eec4b..4dc87cec 100644 --- a/vfs/filesystem.go +++ b/internal/vfs/filesystem.go @@ -17,7 +17,7 @@ package vfs import ( "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/kms" + "github.com/drakkan/sftpgo/v2/internal/kms" ) // Filesystem defines filesystem details diff --git a/vfs/folder.go b/internal/vfs/folder.go similarity index 99% rename from vfs/folder.go rename to internal/vfs/folder.go index 30812deb..db6eb5cb 100644 --- a/vfs/folder.go +++ b/internal/vfs/folder.go @@ -21,7 +21,7 @@ import ( "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/util" ) // BaseVirtualFolder defines the path for the virtual folder and the used quota limits. diff --git a/vfs/gcsfs.go b/internal/vfs/gcsfs.go similarity index 98% rename from vfs/gcsfs.go rename to internal/vfs/gcsfs.go index 17881802..6f6c7374 100644 --- a/vfs/gcsfs.go +++ b/internal/vfs/gcsfs.go @@ -36,11 +36,11 @@ import ( "google.golang.org/api/iterator" "google.golang.org/api/option" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" ) const ( diff --git a/vfs/gcsfs_disabled.go b/internal/vfs/gcsfs_disabled.go similarity index 95% rename from vfs/gcsfs_disabled.go rename to internal/vfs/gcsfs_disabled.go index d452765a..705d9c06 100644 --- a/vfs/gcsfs_disabled.go +++ b/internal/vfs/gcsfs_disabled.go @@ -20,7 +20,7 @@ package vfs import ( "errors" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/version" ) func init() { diff --git a/vfs/httpfs.go b/internal/vfs/httpfs.go similarity index 99% rename from vfs/httpfs.go rename to internal/vfs/httpfs.go index a1603abe..f64474c4 100644 --- a/vfs/httpfs.go +++ b/internal/vfs/httpfs.go @@ -36,10 +36,10 @@ import ( "github.com/pkg/sftp" "github.com/sftpgo/sdk" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/util" ) const ( diff --git a/vfs/osfs.go b/internal/vfs/osfs.go similarity index 99% rename from vfs/osfs.go rename to internal/vfs/osfs.go index 12100c12..224b1425 100644 --- a/vfs/osfs.go +++ b/internal/vfs/osfs.go @@ -31,7 +31,7 @@ import ( "github.com/pkg/sftp" "github.com/rs/xid" - "github.com/drakkan/sftpgo/v2/logger" + "github.com/drakkan/sftpgo/v2/internal/logger" ) const ( diff --git a/vfs/s3fs.go b/internal/vfs/s3fs.go similarity index 99% rename from vfs/s3fs.go rename to internal/vfs/s3fs.go index fc24ff10..f879d890 100644 --- a/vfs/s3fs.go +++ b/internal/vfs/s3fs.go @@ -46,11 +46,11 @@ import ( "github.com/eikenb/pipeat" "github.com/pkg/sftp" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" ) const ( diff --git a/vfs/s3fs_disabled.go b/internal/vfs/s3fs_disabled.go similarity index 94% rename from vfs/s3fs_disabled.go rename to internal/vfs/s3fs_disabled.go index 24fcc1c3..d3fe7691 100644 --- a/vfs/s3fs_disabled.go +++ b/internal/vfs/s3fs_disabled.go @@ -20,7 +20,7 @@ package vfs import ( "errors" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/version" ) func init() { diff --git a/vfs/sftpfs.go b/internal/vfs/sftpfs.go similarity index 99% rename from vfs/sftpfs.go rename to internal/vfs/sftpfs.go index 03d66786..cf650acc 100644 --- a/vfs/sftpfs.go +++ b/internal/vfs/sftpfs.go @@ -35,10 +35,10 @@ import ( "github.com/sftpgo/sdk" "golang.org/x/crypto/ssh" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/version" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/version" ) const ( diff --git a/vfs/statvfs_fallback.go b/internal/vfs/statvfs_fallback.go similarity index 100% rename from vfs/statvfs_fallback.go rename to internal/vfs/statvfs_fallback.go diff --git a/vfs/statvfs_linux.go b/internal/vfs/statvfs_linux.go similarity index 100% rename from vfs/statvfs_linux.go rename to internal/vfs/statvfs_linux.go diff --git a/vfs/statvfs_unix.go b/internal/vfs/statvfs_unix.go similarity index 100% rename from vfs/statvfs_unix.go rename to internal/vfs/statvfs_unix.go diff --git a/vfs/sys_unix.go b/internal/vfs/sys_unix.go similarity index 100% rename from vfs/sys_unix.go rename to internal/vfs/sys_unix.go diff --git a/vfs/sys_windows.go b/internal/vfs/sys_windows.go similarity index 100% rename from vfs/sys_windows.go rename to internal/vfs/sys_windows.go diff --git a/vfs/vfs.go b/internal/vfs/vfs.go similarity index 99% rename from vfs/vfs.go rename to internal/vfs/vfs.go index 176929a0..a3b9faf6 100644 --- a/vfs/vfs.go +++ b/internal/vfs/vfs.go @@ -32,10 +32,10 @@ import ( "github.com/sftpgo/sdk" "github.com/sftpgo/sdk/plugin/metadata" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/plugin" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/plugin" + "github.com/drakkan/sftpgo/v2/internal/util" ) const dirMimeType = "inode/directory" diff --git a/webdavd/file.go b/internal/webdavd/file.go similarity index 98% rename from webdavd/file.go rename to internal/webdavd/file.go index 635cd4fb..2ce183cd 100644 --- a/webdavd/file.go +++ b/internal/webdavd/file.go @@ -27,10 +27,10 @@ import ( "github.com/eikenb/pipeat" "golang.org/x/net/webdav" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) var errTransferAborted = errors.New("transfer aborted") diff --git a/webdavd/handler.go b/internal/webdavd/handler.go similarity index 98% rename from webdavd/handler.go rename to internal/webdavd/handler.go index 1143c298..3865cd88 100644 --- a/webdavd/handler.go +++ b/internal/webdavd/handler.go @@ -24,11 +24,11 @@ import ( "github.com/eikenb/pipeat" "golang.org/x/net/webdav" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) // Connection details for a WebDav connection. diff --git a/webdavd/internal_test.go b/internal/webdavd/internal_test.go similarity index 99% rename from webdavd/internal_test.go rename to internal/webdavd/internal_test.go index 4058069a..77139b89 100644 --- a/webdavd/internal_test.go +++ b/internal/webdavd/internal_test.go @@ -35,11 +35,11 @@ import ( "github.com/stretchr/testify/assert" "golang.org/x/net/webdav" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/util" - "github.com/drakkan/sftpgo/v2/vfs" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/util" + "github.com/drakkan/sftpgo/v2/internal/vfs" ) const ( diff --git a/webdavd/mimecache.go b/internal/webdavd/mimecache.go similarity index 100% rename from webdavd/mimecache.go rename to internal/webdavd/mimecache.go diff --git a/webdavd/server.go b/internal/webdavd/server.go similarity index 98% rename from webdavd/server.go rename to internal/webdavd/server.go index e314913b..2eca057f 100644 --- a/webdavd/server.go +++ b/internal/webdavd/server.go @@ -33,11 +33,11 @@ import ( "github.com/rs/xid" "golang.org/x/net/webdav" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/metric" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/metric" + "github.com/drakkan/sftpgo/v2/internal/util" ) type webDavServer struct { diff --git a/webdavd/webdavd.go b/internal/webdavd/webdavd.go similarity index 98% rename from webdavd/webdavd.go rename to internal/webdavd/webdavd.go index e55b5937..c4a4d809 100644 --- a/webdavd/webdavd.go +++ b/internal/webdavd/webdavd.go @@ -22,10 +22,10 @@ import ( "github.com/go-chi/chi/v5/middleware" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/util" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/util" ) type ctxReqParams int diff --git a/webdavd/webdavd_test.go b/internal/webdavd/webdavd_test.go similarity index 99% rename from webdavd/webdavd_test.go rename to internal/webdavd/webdavd_test.go index ef1dcfa2..7000e4b7 100644 --- a/webdavd/webdavd_test.go +++ b/internal/webdavd/webdavd_test.go @@ -44,16 +44,16 @@ import ( "github.com/stretchr/testify/assert" "github.com/studio-b12/gowebdav" - "github.com/drakkan/sftpgo/v2/common" - "github.com/drakkan/sftpgo/v2/config" - "github.com/drakkan/sftpgo/v2/dataprovider" - "github.com/drakkan/sftpgo/v2/httpclient" - "github.com/drakkan/sftpgo/v2/httpdtest" - "github.com/drakkan/sftpgo/v2/kms" - "github.com/drakkan/sftpgo/v2/logger" - "github.com/drakkan/sftpgo/v2/sftpd" - "github.com/drakkan/sftpgo/v2/vfs" - "github.com/drakkan/sftpgo/v2/webdavd" + "github.com/drakkan/sftpgo/v2/internal/common" + "github.com/drakkan/sftpgo/v2/internal/config" + "github.com/drakkan/sftpgo/v2/internal/dataprovider" + "github.com/drakkan/sftpgo/v2/internal/httpclient" + "github.com/drakkan/sftpgo/v2/internal/httpdtest" + "github.com/drakkan/sftpgo/v2/internal/kms" + "github.com/drakkan/sftpgo/v2/internal/logger" + "github.com/drakkan/sftpgo/v2/internal/sftpd" + "github.com/drakkan/sftpgo/v2/internal/vfs" + "github.com/drakkan/sftpgo/v2/internal/webdavd" ) const ( @@ -65,7 +65,6 @@ const ( sftpServerAddr = "127.0.0.1:9022" defaultUsername = "test_user_dav" defaultPassword = "test_password" - configDir = ".." osWindows = "windows" webDavCert = `-----BEGIN CERTIFICATE----- MIICHTCCAaKgAwIBAgIUHnqw7QnB1Bj9oUsNpdb+ZkFPOxMwCgYIKoZIzj0EAwIw @@ -248,6 +247,7 @@ XMf5HU3ThYqYn3bYypZZ8nQ7BXVh4LqGNqG29wR4v6l+dLO6odXnLzfApGD9e+d4 ) var ( + configDir = filepath.Join(".", "..", "..") allPerms = []string{dataprovider.PermAny} homeBasePath string hookCmdPath string diff --git a/main.go b/main.go index db686e2b..363a2851 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,7 @@ import ( "go.uber.org/automaxprocs/maxprocs" - "github.com/drakkan/sftpgo/v2/cmd" + "github.com/drakkan/sftpgo/v2/internal/cmd" ) func main() {