hi rudiger (sorry, i don't have umlauts on my keyboard :),

i'm really busy and have very little time for my open source projects.
it seems you have concrete solutions to bugs... would you like me to add you
as a maintainer of the project?
just send me your github username, and i'll create branch 3.1.0, where you
can contribute all of your code.


thanks,
-tomer

An NCO and a Gentleman


On Tue, Feb 15, 2011 at 23:57, RĂ¼diger <[email protected]>wrote:

> Hi,
>
> I have some little suggestions for server.py.
>
> The first is rather trivial. It would be nice to see in the logs who
> has used the server. Of course one can create an additional log entry
> when the service starts, but I think it is nicer if it is included in
> Server._serve_client().
>
>    def _serve_client(self, sock, credentials):
>        h, p = sock.getpeername()
>        #{{ my modification
>        if (type(credentials)!=type('')) or (credentials==''):
>            self.logger.info("welcome %s:%s", h, p)
>        else:
>            self.logger.info("welcome %s [%s:%s]", credentials, h, p)
>        #}}
>        try:
>            config = dict(self.protocol_config, credentials =
> credentials)
>            conn = Connection(self.service,
> Channel(SocketStream(sock)),
>                config = config, _lazy = True)
>            conn._init_service()
>            conn.serve_all()
>        finally:
>            self.logger.info("goodbye %s:%s", h, p)
>
> My second suggestion involves Server._authenticate_and_serve_client().
> If I run the server under Linux,
> I observed that tlslite raises an exception if the client does not
> properly closes the connection. This does not happen if I run the
> server under windows. Therefore I suggest to add some error handling
> around the call of _serve_client() and log the exception and the
> traceback properly.
>
>    def _authenticate_and_serve_client(self, sock):
>        try:
>            if self.authenticator:
>                h, p = sock.getpeername()
>                try:
>                    sock, credentials = self.authenticator(sock)
>                except AuthenticationError:
>                    self.logger.info("%s:%s failed to authenticate,
> rejecting connection", h, p)
>                    return
>                else:
>                    self.logger.info("%s:%s authenticated
> successfully", h, p)
>            else:
>                credentials = None
>        #{{ my modification
>            try:
>                self._serve_client(sock, credentials)
>            except Exception,e:
>                etype = sys.exc_type
>                excinfo = sys.exc_info()
>                try:
>                    ename = etype.__name__
>                except AttributeError:
>                    ename = etype
>                self.logger.warn("Exception: %s",ename)
>                self.logger.traceback(excinfo)
>        #}}
>        finally:
>            try:
>                sock.shutdown(socket.SHUT_RDWR)
>            except Exception:
>                pass
>            sock.close()
>            self.clients.discard(sock)
>
> Greetings
> Ruediger
>

Reply via email to