Skip to content

Commit

Permalink
feat!: change default port and scope
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the default port is no longer random, but 6065. The default scope is now the current directory instead of the root directory.
  • Loading branch information
hacdias committed Jul 25, 2024
1 parent 4ed6b34 commit 8558575
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /webdav/main /bin/webdav

EXPOSE 80
EXPOSE 6065

ENTRYPOINT [ "webdav" ]
CMD [ "-p", "80" ]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The configuration can be provided as a YAML, JSON or TOML file. Below is an exam

```yaml
address: 0.0.0.0
port: 0
port: 6065

# TLS-related settings if you want to enable TLS directly.
tls: false
Expand All @@ -74,8 +74,8 @@ auth: true

# The directory that will be able to be accessed by the users when connecting.
# This directory will be used by users unless they have their own 'scope' defined.
# Default is "/".
scope: /
# Default is "." (current directory).
scope: .

# Whether the users can, by default, modify the contents. Default is false.
modify: true
Expand Down
3 changes: 2 additions & 1 deletion lib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
DefaultCert = "cert.pem"
DefaultKey = "key.pem"
DefaultAddress = "0.0.0.0"
DefaultPort = 0
DefaultPort = 6065
DefaultPrefix = "/"
DefaultLogFormat = "console"
)
Expand Down Expand Up @@ -89,6 +89,7 @@ func ParseConfig(filename string, flags *pflag.FlagSet) (*Config, error) {
v.SetDefault("Log_Format", DefaultLogFormat)

// Other defaults
v.SetDefault("Scope", ".")
v.SetDefault("CORS.Allowed_Headers", []string{"*"})
v.SetDefault("CORS.Allowed_Hosts", []string{"*"})
v.SetDefault("CORS.Allowed_Methods", []string{"*"})
Expand Down
5 changes: 4 additions & 1 deletion lib/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ func TestConfigDefaults(t *testing.T) {
require.EqualValues(t, DefaultPort, cfg.Port)
require.EqualValues(t, DefaultPrefix, cfg.Prefix)
require.EqualValues(t, DefaultLogFormat, cfg.LogFormat)
require.NotEmpty(t, cfg.Scope)

dir, err := os.Getwd()
require.NoError(t, err)
require.Equal(t, dir, cfg.Scope)

require.EqualValues(t, []string{"*"}, cfg.CORS.AllowedHeaders)
require.EqualValues(t, []string{"*"}, cfg.CORS.AllowedHosts)
Expand Down

0 comments on commit 8558575

Please sign in to comment.