Changeset c7304b2
- Timestamp:
- 2008-01-12T20:07:10Z (17 years ago)
- Branches:
- master
- Children:
- 55664fc
- Parents:
- e65ceaa
- Location:
- skype
- Files:
-
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
skype/Makefile
re65ceaa rc7304b2 12 12 $(INSTALL) skype.so $(DESTDIR)$(plugindir) 13 13 $(INSTALL) skyped.py $(DESTDIR)$(bindir)/skyped 14 sed -i 's|/ etc|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped14 sed -i 's|/usr/local/etc/skyped|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped 15 15 $(INSTALL) -m644 skyped.conf.dist $(DESTDIR)$(sysconfdir)/skyped.conf 16 16 -
skype/config.mak.in
re65ceaa rc7304b2 3 3 INSTALL = @INSTALL@ 4 4 prefix = @prefix@ 5 sysconfdir = @sysconfdir@ 5 sysconfdir = @sysconfdir@/skyped 6 6 exec_prefix = @exec_prefix@ 7 7 bindir = @bindir@ -
skype/configure.ac
re65ceaa rc7304b2 17 17 LDFLAGS="$LDFLAGS $BITLBEE_LIBS" 18 18 AC_OUTPUT(config.mak) 19 AC_OUTPUT(skyped.conf.dist) -
skype/skype.c
re65ceaa rc7304b2 28 28 #include <poll.h> 29 29 #include <bitlbee.h> 30 #include <bitlbee/ssl_client.h> 30 31 #include <glib.h> 31 32 … … 63 64 * we're connected and when we aren't. */ 64 65 int bfd; 66 /* ssl_getfd() uses this to get the file desciptor. */ 67 void *ssl; 65 68 /* When we receive a new message id, we query the properties, finally 66 69 * the chatname. Store the properties here so that we can use … … 146 149 if(pfd[0].revents & POLLHUP) 147 150 { 148 imcb_error( ic, "Could not connect to server" );149 151 imc_logout( ic, TRUE ); 150 152 return FALSE; 151 153 } 152 write( sd->fd, buf, len );154 ssl_write( sd->ssl, buf, len ); 153 155 154 156 return TRUE; … … 210 212 return FALSE; 211 213 /* Read the whole data. */ 212 st = read( sd->fd, buf, sizeof( buf ) );214 st = ssl_read( sd->ssl, buf, sizeof( buf ) ); 213 215 if( st > 0 ) 214 216 { … … 720 722 } 721 723 } 724 else if(!strncmp(line, "PASSWORD ", 9)) 725 { 726 if(!strncmp(line+9, "OK", 2)) 727 imcb_connected(ic); 728 else 729 { 730 imcb_error(ic, "Authentication Failed"); 731 imc_logout( ic, TRUE ); 732 } 733 } 722 734 lineptr++; 723 735 } … … 766 778 } 767 779 768 gboolean skype_connected( gpointer data, gintsource, b_input_condition cond )780 gboolean skype_connected( gpointer data, void *source, b_input_condition cond ) 769 781 { 770 782 struct im_connection *ic = data; 771 imcb_connected(ic); 783 struct skype_data *sd = ic->proto_data; 784 if(!source) 785 { 786 sd->ssl = NULL; 787 imcb_error( ic, "Could not connect to server" ); 788 imc_logout( ic, TRUE ); 789 return FALSE; 790 } 791 imcb_log( ic, "Connected to server, logging in" ); 772 792 return skype_start_stream(ic); 773 793 } … … 781 801 782 802 imcb_log( ic, "Connecting" ); 783 sd->fd = proxy_connect(set_getstr( &acc->set, "server" ), set_getint( &acc->set, "port" ), skype_connected, ic ); 803 sd->ssl = ssl_connect(set_getstr( &acc->set, "server" ), set_getint( &acc->set, "port" ), skype_connected, ic ); 804 sd->fd = sd->ssl ? ssl_getfd( sd->ssl ) : -1; 784 805 sd->username = g_strdup( acc->user ); 785 806 -
skype/skyped.conf.dist.in
re65ceaa rc7304b2 3 3 # use `echo -n foo|sha1sum` to generate this hash for your password 4 4 password = 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33 5 cert = @sysconfdir@/skyped/skyped.cert.pem 6 key = @sysconfdir@/skyped/skyped.key.pem -
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.