net/portmapper: add upnp port mapping
Add in UPnP portmapping, using goupnp library in order to get the UPnP client and run the portmapping functions. This rips out anywhere where UPnP used to be in portmapping, and has a flow separate from PMP and PCP. RELNOTE=portmapper now supports UPnP mappings Fixes #682 Updates #2109 Signed-off-by: julianknodt <julianknodt@gmail.com>
This commit is contained in:
committed by
Julian Knodt
parent
236eb4d04d
commit
1bb6abc604
@@ -29,6 +29,13 @@ func (b Bool) Get() (v bool, ok bool) {
|
||||
return v, err == nil
|
||||
}
|
||||
|
||||
func (b Bool) And(v bool) Bool {
|
||||
if v {
|
||||
return b
|
||||
}
|
||||
return "false"
|
||||
}
|
||||
|
||||
// EqualBool reports whether b is equal to v.
|
||||
// If b is empty or not a valid bool, it reports false.
|
||||
func (b Bool) EqualBool(v bool) bool {
|
||||
|
||||
@@ -87,3 +87,26 @@ func TestBoolEqualBool(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestBoolAnd(t *testing.T) {
|
||||
tests := []struct {
|
||||
lhs Bool
|
||||
rhs bool
|
||||
want Bool
|
||||
}{
|
||||
{"true", true, "true"},
|
||||
{"true", false, "false"},
|
||||
|
||||
{"false", true, "false"},
|
||||
{"false", false, "false"},
|
||||
|
||||
{"", true, ""},
|
||||
{"", false, "false"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := tt.lhs.And(tt.rhs); got != tt.want {
|
||||
t.Errorf("(%q).And(%v) = %v; want %v", string(tt.lhs), tt.rhs, got, tt.want)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user