Ejemplo n.º 1
0
 def check_clipboard(self):
     content = util.get_from_clipboard()
     if content == self.server.just_in:
         self.previous = content
     if content != self.previous and content != None:
         self.logger.debug('Changed clipboard contents found, sending...')
         #new content, send it around
         enc = util.encrypt(self.conf['keyfile'], 'CSCONTENT:' + content + ':TNETNOCSC')
         self.server.clientlistlock.acquire()
         for (ip, (port, _)) in self.server.clientlist.items():
             util.send_content(ip, port, enc)
         self.server.clientlistlock.release()
         self.previous = content
Ejemplo n.º 2
0
    def announce(self, port):
        #get the local ip and set it for later use
        ip = util.get_ip(self.conf)
        if len(ip) == 0:
            self.logger.error('No local ip-address could be found and none was specified, using default!')
            ip = constants.IP

        if ip != self.ip:
            self.logger.info('Found local ip %s!' % (ip))
            self.ip = ip

        self.logger.debug('Announcing %s:%d!' % (self.ip, port))
        msg = util.encrypt(self.conf['keyfile'],"CSHELO:%s:%d:OLEHSC" % (self.ip, port))
        util.broadcast(msg, constants.PORT) #use fixed port for sending
Ejemplo n.º 3
0
import sys

sys.path.append("../")
import util.clipshare_util as util
from socket import *
import time

s = socket(AF_INET, SOCK_DGRAM)
s.bind(("", 0))
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)

data = "CSHELO:192.168.1.124:50244:OLEHSC"
enc = util.encrypt(open("/home/peter/.clipshare/clipshare.key"), data)
s.sendto(enc, ("<broadcast>", 50244))
time.sleep(2)

data = "CSCONTENT:bla:" + "CSCONTENT"[::-1]
enc = util.encrypt(open("/home/peter/.clipshare/clipshare.key"), data)
s = socket(AF_INET, SOCK_DGRAM)
s.sendto(enc, ("127.0.0.1", 50244))