database: add GetRouteForHost function
This commit is contained in:
parent
ede0affbdc
commit
87be7e8a30
|
@ -66,6 +66,22 @@ func (db *DB) SaveRoute(resp *routerpc.AddHostResponse) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *DB) GetRouteForHost(name string) (*Route, error) {
|
||||||
|
rows, err := r.Table("routes").Filter(r.Row.Field("hostname", name).Or(r.Row.Field("onionhostname", name))).Run(db.s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := &Route{}
|
||||||
|
|
||||||
|
err = rows.One(result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetAllRoutes fetches all of the route entries from the database
|
// GetAllRoutes fetches all of the route entries from the database
|
||||||
// and returns them. This is intended for the startup process or
|
// and returns them. This is intended for the startup process or
|
||||||
// admin tooling.
|
// admin tooling.
|
||||||
|
|
Loading…
Reference in New Issue