Added router ID. Deregister remote services when router is stopped.

Added ID function to router interface.

Network registry addresses are deregistered when the router is stopped.

Query has been updated to search for particular GW in lookups.
This commit is contained in:
Milos Gajdos
2019-06-16 23:09:59 +01:00
parent 322eaae529
commit f62fcaad76
4 changed files with 53 additions and 7 deletions

View File

@@ -19,6 +19,8 @@ type QueryOptions struct {
DestAddr string
// NetworkAddress is network address
Network string
// Gateway is gateway address
Gateway Router
// Policy is query lookup policy
Policy LookupPolicy
}
@@ -37,6 +39,13 @@ func QueryNetwork(a string) QueryOption {
}
}
// QueryGateway sets query gateway address
func QueryGateway(r Router) QueryOption {
return func(o *QueryOptions) {
o.Gateway = r
}
}
// QueryPolicy sets query policy
func QueryPolicy(p LookupPolicy) QueryOption {
return func(o *QueryOptions) {
@@ -57,10 +66,14 @@ type query struct {
// NewQuery creates new query and returns it
func NewQuery(opts ...QueryOption) Query {
// default gateway for wildcard router
r := newRouter(ID("*"))
// default options
qopts := QueryOptions{
DestAddr: "*",
Network: "*",
Gateway: r,
Policy: DiscardNoRoute,
}