golang/go

net/rpc: access to client's IP address

gopherbot opened this issue · 10 comments

by visan.ovidiu:

Right now RemoteAddr() method can be called to get the RPC client's address only on
net.Conn when the client dials to server, but suppose that your server has multiple
clients connected and each of this clients are calling an RPC exported method. Is there
a way to implement a method to get the caller's remote address from inside the RPC
method?

func (t *Type) Method(args *Args, reply *string) error {
    //something like
        *reply = Caller.RemoteAddr().String()
        // who called the method now?
    return nil
}
rsc commented

Comment 2:

I'm skeptical. It would take an API change (not necessarily a backwards incompatible one
but still a bit of a redesign) to supply this.

Labels changed: added priority-later, removed priority-triage, go1.1.

Status changed to Thinking.

Comment 3 by visan.ovidiu:

I see, it would be nice to have though...
rsc commented

Comment 4:

Status changed to Unfortunate.

How come this issue is now considered closed?

As the record shows, Russ closed the issue as "unfortunate" on July 30, 2013. We use the "unfortunate" status for issues that are the result of a possibly mistaken choice in the past.

I'm not sure that it's true that this issue is unfixable though? For example, given that the RPC layer already does reflection on the RPC methods of the implementing class, it would not be too hard to have it detect if a method also takes a request argument, and if so, pass it when the method is called?

rsc commented

"Unfortunate" doesn't mean it's impossible to fix. It means that we've decided it's not worth fixing given the constraints we have, especially that of backwards compatibility.

Does this issue still exists?

@andyxning: what do you mean? Yes, this is still absolutely a useful feature. Not sure why it was just closed :/

@jonhoo I mean that until now we can not implement this functionality about get remote ip address inside the rpc function. right?