35 lines
611 B
Go
35 lines
611 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.xeserv.us/xena/route/database"
|
|
"git.xeserv.us/xena/route/lib/tun2"
|
|
)
|
|
|
|
type storageWrapper struct {
|
|
database.Storage
|
|
}
|
|
|
|
var (
|
|
_ tun2.Storage = &storageWrapper{}
|
|
)
|
|
|
|
func (s *storageWrapper) HasToken(token string) (string, []string, error) {
|
|
t, err := s.Storage.GetToken(context.Background(), token)
|
|
if err != nil {
|
|
return "", nil, err
|
|
}
|
|
|
|
return t.Owner, t.Scopes, nil
|
|
}
|
|
|
|
func (s *storageWrapper) HasRoute(domain string) (string, error) {
|
|
r, err := s.Storage.GetRoute(context.Background(), domain)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return r.Creator, nil
|
|
}
|