If you've already managed to get the information to your bootstrap object,
then the right thing to do from there is to have the bootstrap object add
wrappers to other objects which add knowledge of the IP to them.

For example:

    interface Bootstrap {
      getRoom @0 (name :Text) -> (room :Room);
    }

The getRoom() method might do something like:

    getRoom(this, name):
      room = rooms.find(name)
      return RoomWrapper(room, this.client_ip)

RoomWrapper is a class that implements the `Room` RPC interface for a
specific client, with knowledge of that client's IP. Whenever it receives
an RPC, it can call into the wrapped room object and pass along the IP
address as well.

This is a common design pattern in Cap'n Proto. Since capnp is
capability-based, we like to avoid "ambient authority" (information about
the call context that is not expressed in the parameters).

As for how the bootstrap interface itself gets the info: In C++ there's a
concept of a BootstrapFactory which receives a callback each time a client
connects, and receives the identity of the client. I imagine this isn't
exposed yet in Python, but this would be the way to do it.

-Kenton

On Mon, Mar 19, 2018 at 2:59 PM, The Cheaterman <the.cheater...@gmail.com>
wrote:

> Hi everyone, I hope you're doing great!
>
> As you may already know, I'm doing a small chat system to familiarize
> myself with Capnp before I do more ambitious things. I would like to have
> some sort of way to implement a banlist on the chat server. I do realize
> the whole point of capabilities is to have the same behavior no matter
> where the capability is called from. However, I feel like users
> (administrators) of server software are used to filter users by IP (when it
> comes to that). Alternatively, I'd like to find something unique (but
> persistent for a given computer - OS install? hardware? not sure) I could
> send during the handshake, to filter undesired users. Basically, I feel
> like I need some sort of persistent authentication system that's relatively
> hard to refresh, if I can't get access to the IP:port of the user even in
> the bootstrap object. I currently managed to hack pycapnp to get a method
> called on the bootstrap object when a client connects with IP and port as
> arguments, but even if I store them I have no way of knowing which client
> calls a given callback (which is a design choice I imagine).
>
> I'd like to know your thoughts on the subject :-) thanks a lot in advance!
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to capnproto+unsubscr...@googlegroups.com.
> Visit this group at https://groups.google.com/group/capnproto.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capnproto+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to