Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
8851c85d
Commit
8851c85d
authored
Sep 15, 2017
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add backwards-compatibility wrappers around LLAIP methods that now take NetworkFilters.
parent
ac6b5d30
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
async-io.c++
c++/src/kj/async-io.c++
+14
-0
async-io.h
c++/src/kj/async-io.h
+8
-0
No files found.
c++/src/kj/async-io.c++
View file @
8851c85d
...
...
@@ -213,6 +213,20 @@ Own<DatagramPort> LowLevelAsyncIoProvider::wrapDatagramSocketFd(
KJ_UNIMPLEMENTED
(
"Datagram sockets not implemented."
);
}
namespace
{
class
DummyNetworkFilter
:
public
kj
::
LowLevelAsyncIoProvider
::
NetworkFilter
{
public
:
bool
shouldAllow
(
const
struct
sockaddr
*
addr
,
uint
addrlen
)
override
{
return
true
;
}
};
}
// namespace
LowLevelAsyncIoProvider
::
NetworkFilter
&
LowLevelAsyncIoProvider
::
NetworkFilter
::
getAllAllowed
()
{
static
DummyNetworkFilter
result
;
return
result
;
}
// =======================================================================================
namespace
_
{
// private
...
...
c++/src/kj/async-io.h
View file @
8851c85d
...
...
@@ -536,16 +536,24 @@ public:
virtual
bool
shouldAllow
(
const
struct
sockaddr
*
addr
,
uint
addrlen
)
=
0
;
// Returns true if incoming connections or datagrams from the given peer should be accepted.
// If false, they will be dropped. This is used to implement kj::Network::restrictPeers().
static
NetworkFilter
&
getAllAllowed
();
};
virtual
Own
<
ConnectionReceiver
>
wrapListenSocketFd
(
Fd
fd
,
NetworkFilter
&
filter
,
uint
flags
=
0
)
=
0
;
inline
Own
<
ConnectionReceiver
>
wrapListenSocketFd
(
Fd
fd
,
uint
flags
=
0
)
{
return
wrapListenSocketFd
(
fd
,
NetworkFilter
::
getAllAllowed
(),
flags
);
}
// Create an AsyncIoStream wrapping a listen socket file descriptor. This socket should already
// have had `bind()` and `listen()` called on it, so it's ready for `accept()`.
//
// `flags` is a bitwise-OR of the values of the `Flags` enum.
virtual
Own
<
DatagramPort
>
wrapDatagramSocketFd
(
Fd
fd
,
NetworkFilter
&
filter
,
uint
flags
=
0
);
inline
Own
<
DatagramPort
>
wrapDatagramSocketFd
(
Fd
fd
,
uint
flags
=
0
)
{
return
wrapDatagramSocketFd
(
fd
,
NetworkFilter
::
getAllAllowed
(),
flags
);
}
virtual
Timer
&
getTimer
()
=
0
;
// Returns a `Timer` based on real time. Time does not pass while event handlers are running --
...
...
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