Skip to content

Commit

Permalink
move funcs around
Browse files Browse the repository at this point in the history
  • Loading branch information
ingon committed Jan 20, 2025
1 parent fabe7bd commit 9811106
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,22 @@ func ServerClientsAddress(address string) ServerOption {
}
}

func ServerClientTokens(tokens ...string) ServerOption {
func ServerClientRestrictions(allow []string, deny []string) ServerOption {
return func(cfg *serverConfig) error {
clientAuth, err := selfhosted.NewClientAuthenticator(tokens...)
iprestr, err := restr.ParseIP(allow, deny)
if err != nil {
return err
}

cfg.clientsAuth = clientAuth
cfg.clientsRestr = iprestr

return nil
}
}

func ServerClientTokensRestricted(tokens []string, iprestr []restr.IP, namerestr []restr.Name) ServerOption {
func ServerClientTokens(tokens ...string) ServerOption {
return func(cfg *serverConfig) error {
clientAuth, err := selfhosted.NewClientAuthenticatorRestricted(tokens, iprestr, namerestr)
clientAuth, err := selfhosted.NewClientAuthenticator(tokens...)
if err != nil {
return err
}
Expand All @@ -216,14 +216,14 @@ func ServerClientTokensRestricted(tokens []string, iprestr []restr.IP, namerestr
}
}

func ServerClientRestrictions(allow []string, deny []string) ServerOption {
func ServerClientTokensRestricted(tokens []string, iprestr []restr.IP, namerestr []restr.Name) ServerOption {
return func(cfg *serverConfig) error {
iprestr, err := restr.ParseIP(allow, deny)
clientAuth, err := selfhosted.NewClientAuthenticatorRestricted(tokens, iprestr, namerestr)
if err != nil {
return err
}

cfg.clientsRestr = iprestr
cfg.clientsAuth = clientAuth

return nil
}
Expand Down

0 comments on commit 9811106

Please sign in to comment.