Changeset c7304b2 for skype/skyped.py
- Timestamp:
- 2008-01-12T20:07:10Z (17 years ago)
- Branches:
- master
- Children:
- 55664fc
- Parents:
- e65ceaa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
skype/skyped.py
re65ceaa rc7304b2 37 37 import sha 38 38 from ConfigParser import ConfigParser 39 from OpenSSL import SSL 39 40 40 41 __version__ = "0.1.1" … … 67 68 68 69 def server(host, port): 69 sock = socket.socket() 70 global options 71 72 ctx = SSL.Context(SSL.TLSv1_METHOD) 73 ctx.use_privatekey_file(options.config.sslkey) 74 ctx.use_certificate_file(options.config.sslcert) 75 sock = SSL.Connection(ctx, socket.socket()) 70 76 sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 71 77 sock.bind((host, port)) … … 76 82 global options 77 83 options.conn, addr = sock.accept() 78 lines = options.conn.recv(512).split('\n')79 84 ret = 0 80 nlines = [] 81 for i in lines: 82 if i.startswith("USERNAME") and i.split(' ')[1].strip() == options.config.username: 83 ret += 1 84 elif i.startswith("PASSWORD") and sha.sha(i.split(' ')[1].strip()).hexdigest() == options.config.password: 85 ret += 1 86 else: 87 nlines.append(i) 88 del lines 85 line = options.conn.recv(1024) 86 if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username: 87 ret += 1 88 line = options.conn.recv(1024) 89 if line.startswith("PASSWORD") and sha.sha(line.split(' ')[1].strip()).hexdigest() == options.config.password: 90 ret += 1 89 91 if ret == 2: 90 92 dprint("Username and password OK.") 91 options.buf = nlines 92 input_handler(None, None) 93 options.conn.send("PASSWORD OK\n") 93 94 gobject.io_add_watch(options.conn, gobject.IO_IN, input_handler) 94 95 return True 95 96 else: 96 97 dprint("Username and/or password WRONG.") 98 options.conn.send("PASSWORD KO\n") 97 99 return False 98 100 … … 153 155 class Options: 154 156 def __init__(self): 155 self.cfgpath = "/ etc/skyped.conf"157 self.cfgpath = "/usr/local/etc/skyped/skyped.conf" 156 158 self.daemon = True 157 159 self.debug = False … … 217 219 options.config.username = options.config.get('skyped', 'username').split('#')[0] 218 220 options.config.password = options.config.get('skyped', 'password').split('#')[0] 221 options.config.sslkey = options.config.get('skyped', 'key').split('#')[0] 222 options.config.sslcert = options.config.get('skyped', 'cert').split('#')[0] 219 223 dprint("Parsing config file '%s' done, username is '%s'." % (options.cfgpath, options.config.username)) 220 224 if options.daemon:
Note: See TracChangeset
for help on using the changeset viewer.