Created
January 13, 2015 04:02
-
-
Save stevommmm/866320f6f91e6375efa3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def run(self): | |
| self.conn.send('220 Welcome!\r\n') | |
| while True: | |
| if not isinstance(self.conn, ssl.SSLSocket): # Can't PEEK at ssl sockets | |
| if self.conn.recv( 1, socket.MSG_PEEK ) == "\x16": | |
| self.conn = ssl.wrap_socket(self.conn, certfile="cert.pem", server_side=True) | |
| cmd=self.conn.recv(256) | |
| if not cmd: break | |
| else: | |
| try: | |
| func=getattr(self,cmd[:4].strip().upper()) | |
| func(cmd) | |
| except Exception,e: | |
| print 'ERROR:',e | |
| traceback.print_exc() | |
| self.conn.send('500 Sorry.\r\n') | |
| # ... snip ... | |
| def AUTH(self, cmd): | |
| print repr(cmd) | |
| if cmd.strip == "AUTH TLS": | |
| self.conn.send('234 OK.\r\n') | |
| else: | |
| self.conn.send('504 Sorry.\r\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment