Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-addrutil
Commits
a7511437
Commit
a7511437
authored
Feb 08, 2021
by
Jorropo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `IsFDCostlyTransport`
parent
60fd7d35
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
73 deletions
+0
-73
filter.go
filter.go
+0
-15
filter_test.go
filter_test.go
+0
-58
No files found.
filter.go
View file @
a7511437
...
@@ -16,21 +16,6 @@ func SubtractFilter(addrs ...ma.Multiaddr) func(ma.Multiaddr) bool {
...
@@ -16,21 +16,6 @@ func SubtractFilter(addrs ...ma.Multiaddr) func(ma.Multiaddr) bool {
}
}
}
}
// IsFDCostlyTransport returns true for transports that require a new file
// descriptor per connection created
func
IsFDCostlyTransport
(
a
ma
.
Multiaddr
)
bool
{
res
:=
false
ma
.
ForEach
(
a
,
func
(
c
ma
.
Component
)
bool
{
if
c
.
Protocol
()
.
Code
==
ma
.
P_TCP
{
res
=
true
return
false
}
return
true
})
return
res
}
// FilterNeg returns a negated version of the passed in filter
// FilterNeg returns a negated version of the passed in filter
func
FilterNeg
(
f
func
(
ma
.
Multiaddr
)
bool
)
func
(
ma
.
Multiaddr
)
bool
{
func
FilterNeg
(
f
func
(
ma
.
Multiaddr
)
bool
)
func
(
ma
.
Multiaddr
)
bool
{
return
func
(
a
ma
.
Multiaddr
)
bool
{
return
func
(
a
ma
.
Multiaddr
)
bool
{
...
...
filter_test.go
View file @
a7511437
...
@@ -25,61 +25,3 @@ func TestSubtractAndNegFilter(t *testing.T) {
...
@@ -25,61 +25,3 @@ func TestSubtractAndNegFilter(t *testing.T) {
t
.
Errorf
(
"Expected only one remaining address: %s"
,
localhost
.
String
())
t
.
Errorf
(
"Expected only one remaining address: %s"
,
localhost
.
String
())
}
}
}
}
func
TestIsFDCostlyTransport
(
t
*
testing
.
T
)
{
tcpMa
:=
newMultiaddr
(
t
,
"/ip4/127.0.0.1/tcp/1234"
)
if
ok
:=
IsFDCostlyTransport
(
tcpMa
);
!
ok
{
t
.
Errorf
(
"Expected address %s to need a new file descriptor per new connection"
,
tcpMa
.
String
())
}
udpMa
:=
newMultiaddr
(
t
,
"/ip4/127.0.0.1/udp/1234"
)
if
ok
:=
IsFDCostlyTransport
(
udpMa
);
ok
{
t
.
Errorf
(
"Expected address %s to not need a new file descriptor per new connection"
,
udpMa
.
String
())
}
}
func
TestIsFDCostly
(
t
*
testing
.
T
)
{
good
:=
[]
ma
.
Multiaddr
{
newMultiaddr
(
t
,
"/ip4/127.0.0.1/tcp/1234"
),
newMultiaddr
(
t
,
"/ip4/0.0.0.0/tcp/1234"
),
newMultiaddr
(
t
,
"/ip6/::1/tcp/1234"
),
newMultiaddr
(
t
,
"/ip6/::/tcp/1234"
),
newMultiaddr
(
t
,
"/ip6/fe80::1/tcp/1234"
),
newMultiaddr
(
t
,
"/ip6/fe80::/tcp/1234"
),
newMultiaddr
(
t
,
"/ip6/fe80::/tcp/1234/http"
),
newMultiaddr
(
t
,
"/ip4/127.0.0.1/tcp/1234/http"
),
}
bad
:=
[]
ma
.
Multiaddr
{
newMultiaddr
(
t
,
"/ip4/127.0.0.1/udp/1234"
),
newMultiaddr
(
t
,
"/ip4/0.0.0.0/udp/1234/utp"
),
newMultiaddr
(
t
,
"/ip6/::1/udp/1234"
),
newMultiaddr
(
t
,
"/ip6/::/udp/1234"
),
}
for
_
,
a
:=
range
bad
{
if
IsFDCostlyTransport
(
a
)
{
t
.
Errorf
(
"addr %s should not be fd costly"
,
a
)
}
}
for
_
,
a
:=
range
good
{
if
!
IsFDCostlyTransport
(
a
)
{
t
.
Errorf
(
"addr %s should be fd costly"
,
a
)
}
}
}
func
TestIsFdCostlyMalformed
(
t
*
testing
.
T
)
{
bad
:=
[]
ma
.
Multiaddr
{
newMultiaddr
(
t
,
"/ip4/127.0.0.1/"
),
newMultiaddr
(
t
,
"/ip4/0.0.0.0/"
),
newMultiaddr
(
t
,
"/ip6/::1/"
),
newMultiaddr
(
t
,
"/ip6/::/"
),
}
for
_
,
a
:=
range
bad
{
if
IsFDCostlyTransport
(
a
)
{
t
.
Errorf
(
"addr %s should not be fd costly"
,
a
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment