Пример #1
0
def main():
    """Parse the command-line arguments and run the bot."""
    parser = argparse.ArgumentParser(description='XMPP echo bot',
                                     parents=[XMPPSettings.get_arg_parser()])
    parser.add_argument('jid', metavar='JID', help='The bot JID')

    parser.add_argument('tunnel_conf', metavar='TUNNEL_CONF')

    parser.add_argument('--debug',
                        action='store_const',
                        dest='log_level',
                        const=logging.DEBUG,
                        default=logging.INFO,
                        help='Print debug messages')
    parser.add_argument('--quiet',
                        const=logging.ERROR,
                        action='store_const',
                        dest='log_level',
                        help='Print only error messages')
    parser.add_argument('--trace',
                        action='store_true',
                        help='Print XML data sent and received')

    args = parser.parse_args()
    settings = XMPPSettings({"software_name": "TCP Tunneler Bot"})
    settings.load_arguments(args)

    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"utf-8")
        settings["password"] = password

    if sys.version_info.major < 3:
        args.jid = args.jid.decode("utf-8")

    logging.basicConfig(level=args.log_level)
    if args.trace:
        print "enabling trace"
        handler = logging.StreamHandler()
        handler.setLevel(logging.DEBUG)
        for logger in ("pyxmpp2.IN", "pyxmpp2.OUT"):
            logger = logging.getLogger(logger)
            logger.setLevel(logging.DEBUG)
            logger.addHandler(handler)
            logger.propagate = False

    im_tcp_tunneler.setup_tunnels(args.tunnel_conf)

    global bot
    bot = Bot(JID(args.jid), settings)
    try:
        bot.run()
    except KeyboardInterrupt:
        bot.disconnect()
Пример #2
0
def main():
    """Parse the command-line arguments and run the bot."""
    parser = argparse.ArgumentParser(description = 'XMPP echo bot',
                                    parents = [XMPPSettings.get_arg_parser()])
    parser.add_argument('jid', metavar = 'JID', 
                        help = 'The bot JID')
    
    parser.add_argument('tunnel_conf', metavar = 'TUNNEL_CONF')
    
    parser.add_argument('--debug',
                        action = 'store_const', dest = 'log_level',
                        const = logging.DEBUG, default = logging.INFO,
                        help = 'Print debug messages')
    parser.add_argument('--quiet', const = logging.ERROR,
                        action = 'store_const', dest = 'log_level',
                        help = 'Print only error messages')
    parser.add_argument('--trace', action = 'store_true',
                        help = 'Print XML data sent and received')
   
    args = parser.parse_args()
    settings = XMPPSettings({
                            "software_name": "TCP Tunneler Bot"
                            })
    settings.load_arguments(args)

    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"utf-8")
        settings["password"] = password

    if sys.version_info.major < 3:
        args.jid = args.jid.decode("utf-8")

    logging.basicConfig(level = args.log_level)
    if args.trace:
        print "enabling trace"
        handler = logging.StreamHandler()
        handler.setLevel(logging.DEBUG)
        for logger in ("pyxmpp2.IN", "pyxmpp2.OUT"):
            logger = logging.getLogger(logger)
            logger.setLevel(logging.DEBUG)
            logger.addHandler(handler)
            logger.propagate = False

    im_tcp_tunneler.setup_tunnels(args.tunnel_conf)

    global bot
    bot = Bot(JID(args.jid), settings)
    try:
        bot.run()
    except KeyboardInterrupt:
        bot.disconnect()
Пример #3
0
    # PyXMPP uses `logging` module for its debug output
    # applications should set it up as needed
    logger = logging.getLogger()
    logger.addHandler(logging.StreamHandler())
    logger.setLevel(logging.INFO) # change to DEBUG for higher verbosity

   # if len(sys.argv) < 3:
     #   print u"Usage:"
     #   print "\t%s JID password 'tls_noverify'|cacert_file tunnelconf_file" % (sys.argv[0],)
      #  print "example:"
      #  print "\t%s test@localhost verysecret tls_noverify tunnels.pyconf" % (sys.argv[0],)
      #  sys.exit(1)

   # im_tcp_tunneler.setup_tunnels(sys.argv[-1])
    im_tcp_tunneler.setup_tunnels('tunnels.conf')

    print u"creating client..."

    #client = Client(JID(sys.argv[1]), sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None)
    #client = Client(JID('e@localhost'), '123456', 'tls_noverify1')
    client = Client(JID('e@localhost/tunneler'), '123456',None)
  #  print sys.argv[0]
   # print sys.argv[1]
   # print sys.argv[2]
   # print sys.argv[3]
   # print sys.argv[4]

    print u"connecting..."
    client.connect()

    # PyXMPP uses `logging` module for its debug output
    # applications should set it up as needed
    logger = logging.getLogger()
    logger.addHandler(logging.StreamHandler())
    logger.setLevel(logging.INFO) # change to DEBUG for higher verbosity

    if len(sys.argv) < 3:
        print u"Usage:"
        print "\t%s JID password 'tls_noverify'|cacert_file tunnelconf_file" % (sys.argv[0],)
        print "example:"
        print "\t%s test@localhost verysecret tls_noverify tunnels.pyconf" % (sys.argv[0],)
        sys.exit(1)

    im_tcp_tunneler.setup_tunnels(sys.argv[-1])
        
    print u"creating client..."

    client = Client(JID(sys.argv[1]), sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None)

    print u"connecting..."
    client.connect()

    print u"looping..."
    try:
        # Component class provides basic "main loop" for the applitation
        # Though, most applications would need to have their own loop and call
        # component.stream.loop_iter() from it whenever an event on
        # component.stream.fileno() occurs.
        client.loop(1)
Пример #5
0
                global keep_running
                keep_running = False
    except:
        traceback.print_exc()


im_tcp_tunneler.send_xmpp_message = send_xmpp_message


def get_client_jid():
    return skype.CurrentUser.Handle


im_tcp_tunneler.get_client_jid = get_client_jid

config_ns = im_tcp_tunneler.setup_tunnels(sys.argv[-1])

if 0: im_tcp_tunneler.data_coding_mode = 'raw'

import Skype4Py

proto = os.environ.get('SKYPE_PREFFERED_PROTO', None)
if proto: skype = Skype4Py.Skype(Transport=proto)
else: skype = Skype4Py.Skype()

skype.Attach()


def onApplicationReceiving(app_, streams):
    if app_.Name != app.Name: return False
    while 1:
Пример #6
0
            else:
                break
        else:
            #¶ÁÈ¡ÅäÖÃÎĵµ
            if config_ns.get('skype_strict_errors', False):
                global keep_running; keep_running = False
    except:
        traceback.print_exc()
im_tcp_tunneler.send_xmpp_message = send_xmpp_message

def get_client_jid():
    return skype.CurrentUser.Handle
im_tcp_tunneler.get_client_jid = get_client_jid

#config_ns = im_tcp_tunneler.setup_tunnels(sys.argv[-1])'tunnels.conf'
config_ns = im_tcp_tunneler.setup_tunnels('tunnels.conf')

if 0: im_tcp_tunneler.data_coding_mode = 'raw'

import Skype4Py

proto = os.environ.get('SKYPE_PREFFERED_PROTO', None)
if proto: skype = Skype4Py.Skype(Transport=proto)
else:     skype = Skype4Py.Skype()

skype.Attach()

def onApplicationReceiving(app_, streams):
    if app_.Name != app.Name: return False
    while 1:
        ret = False
Пример #7
0
            except Skype4Py.SkypeAPIError, e:
                print e, '- trying again'
            else:
                break
        else:
            if config_ns.get('skype_strict_errors', False):
                global keep_running; keep_running = False
    except:
        traceback.print_exc()
im_tcp_tunneler.send_xmpp_message = send_xmpp_message

def get_client_jid():
    return skype.CurrentUser.Handle
im_tcp_tunneler.get_client_jid = get_client_jid

config_ns = im_tcp_tunneler.setup_tunnels(sys.argv[-1])

if 0: im_tcp_tunneler.data_coding_mode = 'raw'

import Skype4Py

proto = os.environ.get('SKYPE_PREFFERED_PROTO', None)
if proto: skype = Skype4Py.Skype(Transport=proto)
else:     skype = Skype4Py.Skype()

skype.Attach()

def onApplicationReceiving(app_, streams):
    if app_.Name != app.Name: return False
    while 1:
        ret = False
Пример #8
0
    # PyXMPP uses `logging` module for its debug output
    # applications should set it up as needed
    logger = logging.getLogger()
    logger.addHandler(logging.StreamHandler())
    logger.setLevel(logging.INFO)  # change to DEBUG for higher verbosity

    if len(sys.argv) < 3:
        print u"Usage:"
        print "\t%s JID password 'tls_noverify'|cacert_file tunnelconf_file" % (
            sys.argv[0], )
        print "example:"
        print "\t%s test@localhost verysecret tls_noverify tunnels.pyconf" % (
            sys.argv[0], )
        sys.exit(1)

    im_tcp_tunneler.setup_tunnels(sys.argv[-1])

    print u"creating client..."

    client = Client(JID(sys.argv[1]), sys.argv[2],
                    sys.argv[3] if len(sys.argv) > 3 else None)

    print u"connecting..."
    client.connect()

    print u"looping..."
    try:
        # Component class provides basic "main loop" for the applitation
        # Though, most applications would need to have their own loop and call
        # component.stream.loop_iter() from it whenever an event on
        # component.stream.fileno() occurs.