2017-12-15 18:18:13 +00:00
|
|
|
package main
|
2017-04-28 23:27:34 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2017-09-30 13:41:35 +00:00
|
|
|
"git.xeserv.us/xena/route/internal/database"
|
2017-10-01 15:23:08 +00:00
|
|
|
"git.xeserv.us/xena/route/internal/tun2"
|
2017-04-28 23:27:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type storageWrapper struct {
|
|
|
|
database.Storage
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
_ tun2.Storage = &storageWrapper{}
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *storageWrapper) HasToken(token string) (string, []string, error) {
|
2018-01-21 19:12:40 +00:00
|
|
|
t, err := s.Storage.Tokens().GetBody(context.Background(), token)
|
2017-04-28 23:27:34 +00:00
|
|
|
if err != nil {
|
|
|
|
return "", nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return t.Owner, t.Scopes, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *storageWrapper) HasRoute(domain string) (string, error) {
|
2018-01-21 19:08:43 +00:00
|
|
|
r, err := s.Storage.Routes().GetHost(context.Background(), domain)
|
2017-04-28 23:27:34 +00:00
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
return r.Creator, nil
|
|
|
|
}
|