with '#' will be ignored, and an empty message aborts the commit. Author: Ethan Alicea <64653625+Tech-Gamer@users.noreply.github.com> On branch develop Your branch is up to date with 'origin/develop'. Changes to be committed: modified: .github/workflows/push.yaml modified: .github/workflows/release.yaml modified: CHANGELOG.md modified: Dockerfile modified: Makefile modified: README.md modified: cmd/configure.go modified: cmd/diagnostics.go modified: cmd/root.go modified: config/config.go modified: environment/allocations.go modified: environment/docker.go modified: environment/docker/api.go modified: environment/docker/container.go modified: environment/docker/environment.go modified: environment/docker/power.go modified: environment/docker/stats.go modified: environment/environment.go modified: environment/settings.go modified: events/events.go modified: go.mod modified: internal/cron/activity_cron.go modified: internal/cron/cron.go modified: internal/cron/sftp_cron.go modified: internal/database/database.go modified: internal/progress/progress.go modified: internal/progress/progress_test.go modified: loggers/cli/cli.go new file: oryxBuildBinary modified: parser/parser.go modified: remote/http.go modified: remote/servers.go modified: remote/types.go modified: router/downloader/downloader.go modified: router/middleware.go modified: router/middleware/middleware.go modified: router/middleware/request_error.go modified: router/router.go modified: router/router_download.go modified: router/router_server.go modified: router/router_server_backup.go modified: router/router_server_files.go modified: router/router_server_transfer.go modified: router/router_server_ws.go modified: router/router_system.go modified: router/router_transfer.go modified: router/tokens/parser.go modified: router/websocket/listeners.go modified: router/websocket/websocket.go modified: server/activity.go modified: server/backup.go modified: server/backup/backup.go modified: server/backup/backup_local.go modified: server/backup/backup_s3.go modified: server/configuration.go modified: server/console.go modified: server/crash.go modified: server/events.go modified: server/filesystem/archive.go modified: server/filesystem/filesystem.go modified: server/filesystem/filesystem_test.go modified: server/install.go modified: server/installer/installer.go modified: server/listeners.go modified: server/manager.go modified: server/mounts.go modified: server/power.go modified: server/power_test.go modified: server/resources.go modified: server/server.go modified: server/transfer/archive.go modified: server/transfer/source.go modified: server/transfer/transfer.go modified: server/update.go modified: sftp/event.go modified: sftp/handler.go modified: sftp/server.go modified: wings.go
77 lines
2.1 KiB
Go
77 lines
2.1 KiB
Go
package server
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/apex/log"
|
|
|
|
"github.com/Tech-Gamer/nwy-wings/config"
|
|
"github.com/Tech-Gamer/nwy-wings/environment"
|
|
)
|
|
|
|
// To avoid confusion when working with mounts, assume that a server.Mount has not been properly
|
|
// cleaned up and had the paths set. An environment.Mount should only be returned with valid paths
|
|
// that have been checked.
|
|
type Mount environment.Mount
|
|
|
|
// Returns the default container mounts for the server instance. This includes the data directory
|
|
// for the server. Previously this would also mount in host timezone files, however we've moved from
|
|
// that approach to just setting `TZ=Timezone` environment values in containers which should work
|
|
// in most scenarios.
|
|
func (s *Server) Mounts() []environment.Mount {
|
|
m := []environment.Mount{
|
|
{
|
|
Default: true,
|
|
Target: "/home/container",
|
|
Source: s.Filesystem().Path(),
|
|
ReadOnly: false,
|
|
},
|
|
}
|
|
|
|
// Also include any of this server's custom mounts when returning them.
|
|
return append(m, s.customMounts()...)
|
|
}
|
|
|
|
// Returns the custom mounts for a given server after verifying that they are within a list of
|
|
// allowed mount points for the node.
|
|
func (s *Server) customMounts() []environment.Mount {
|
|
var mounts []environment.Mount
|
|
|
|
// TODO: probably need to handle things trying to mount directories that do not exist.
|
|
for _, m := range s.Config().Mounts {
|
|
source := filepath.Clean(m.Source)
|
|
target := filepath.Clean(m.Target)
|
|
|
|
logger := s.Log().WithFields(log.Fields{
|
|
"source_path": source,
|
|
"target_path": target,
|
|
"read_only": m.ReadOnly,
|
|
})
|
|
|
|
mounted := false
|
|
for _, allowed := range config.Get().AllowedMounts {
|
|
// Check if the source path is included in the allowed mounts list.
|
|
// filepath.Clean will strip all trailing slashes (unless the path is a root directory).
|
|
if !strings.HasPrefix(source, filepath.Clean(allowed)) {
|
|
continue
|
|
}
|
|
|
|
mounted = true
|
|
mounts = append(mounts, environment.Mount{
|
|
Source: source,
|
|
Target: target,
|
|
ReadOnly: m.ReadOnly,
|
|
})
|
|
|
|
break
|
|
}
|
|
|
|
if !mounted {
|
|
logger.Warn("skipping custom server mount, not in list of allowed mount points")
|
|
}
|
|
}
|
|
|
|
return mounts
|
|
}
|