Adds network id. Skips processing routes when router is the origin.

This commit is contained in:
Milos Gajdos
2019-08-27 23:08:35 +01:00
parent 470304ef87
commit 5e7208119e
8 changed files with 142 additions and 76 deletions

View File

@@ -11,29 +11,38 @@ type QueryOptions struct {
Gateway string
// Network is network address
Network string
// Router is router id
Router string
}
// QueryService sets destination address
// QueryService sets service to query
func QueryService(s string) QueryOption {
return func(o *QueryOptions) {
o.Service = s
}
}
// QueryGateway sets route gateway
// QueryGateway sets gateway address to query
func QueryGateway(g string) QueryOption {
return func(o *QueryOptions) {
o.Gateway = g
}
}
// QueryNetwork sets route network address
// QueryNetwork sets network name to query
func QueryNetwork(n string) QueryOption {
return func(o *QueryOptions) {
o.Network = n
}
}
// QueryRouter sets router id to query
func QueryRouter(r string) QueryOption {
return func(o *QueryOptions) {
o.Router = r
}
}
// Query is routing table query
type Query interface {
// Options returns query options
@@ -52,6 +61,7 @@ func NewQuery(opts ...QueryOption) Query {
Service: "*",
Gateway: "*",
Network: "*",
Router: "*",
}
for _, o := range opts {
@@ -67,8 +77,3 @@ func NewQuery(opts ...QueryOption) Query {
func (q *query) Options() QueryOptions {
return q.opts
}
// String prints routing table query in human readable form
func (q query) String() string {
return "query"
}