simplify unix socket permission format (#3014)
### Pull Request Checklist <!-- Please read https://matrix-org.github.io/dendrite/development/contributing before submitting your pull request --> * [x] I have added Go unit tests or [Complement integration tests](https://github.com/matrix-org/complement) for this PR _or_ I have justified why this PR doesn't need tests * [x] Pull request includes a [sign off below using a legally identifiable name](https://matrix-org.github.io/dendrite/development/contributing#sign-off) _or_ I have already signed off privately Signed-off-by: `Boris Rybalkin <ribalkin@gmail.com>`
This commit is contained in:
parent
2c58bab6a8
commit
d88f71ab71
4 changed files with 34 additions and 8 deletions
|
|
@ -3,6 +3,7 @@ package config
|
|||
import (
|
||||
"io/fs"
|
||||
"net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -32,8 +33,12 @@ func (s ServerAddress) Network() string {
|
|||
}
|
||||
}
|
||||
|
||||
func UnixSocketAddress(path string, perm fs.FileMode) ServerAddress {
|
||||
return ServerAddress{Address: path, Scheme: NetworkUnix, UnixSocketPermission: perm}
|
||||
func UnixSocketAddress(path string, perm string) (ServerAddress, error) {
|
||||
permission, err := strconv.ParseInt(perm, 8, 32)
|
||||
if err != nil {
|
||||
return ServerAddress{}, err
|
||||
}
|
||||
return ServerAddress{Address: path, Scheme: NetworkUnix, UnixSocketPermission: fs.FileMode(permission)}, nil
|
||||
}
|
||||
|
||||
func HTTPAddress(urlAddress string) (ServerAddress, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue