Exemple #1
0
def main():
  global logger
  # Needed so that the event handler for the HTTP server can see the selexor server
  global selexor_server
  logger = selexorhelper.setup_logging("selexorweb")

  # Generate the index file
  _generate_request_form()

  http_server = SelexorHTTPServer((settings.http_ip_addr, settings.http_port), SelexorHandler)
  http_thread = threading.Thread(target=http_server.serve_forever)
  nodestate_transition_key = rsa_repy.rsa_file_to_publickey(settings.path_to_nodestate_transition_key)

  selexor_server = selexorserver.SelexorServer()


  http_thread.start()
  print "Listening for connections on", settings.http_ip_addr + ':' + str(settings.http_port)

  # Run indefinitely until CTRL+C is pressed.
  try:
    while True:
      time.sleep(1.0)
  except KeyboardInterrupt, e:
    pass
def _init():
  global logger
  logger = selexorhelper.setup_logging(__name__)

  register_callback('location_specific', 'vessel', _specific_location_parser, _specific_location_preprocessor)
  register_callback('location_separation_radius', 'group', _separation_radius_parser, _separation_radius_preprocessor)
  register_callback('location_different', 'group', _different_location_type_parser, _different_location_preprocessor)
  register_callback('num_ip_change', 'vessel', _ip_change_count_parser, _ip_change_count_preprocessor)
  register_callback('node_type', 'vessel', _node_type_parser, _node_type_preprocessor)
  register_callback('port', 'vessel', _port_parser, _port_preprocessor)
Exemple #3
0
import copy
import selexorruleparser
import selexorhelper
import random
import fastnmclient
import threading
import traceback
import selexorexceptions
import MySQLdb
import settings

import repyhelper
repyhelper.translate_and_import('rsa.repy')


logger = selexorhelper.setup_logging(__name__)


# Contains information about all requests.
# (username, ip): {
#   'status': (string) The current status of this request.
#   'groups': ([node]) Dicts of all groups in request, with group ID as the key
#   'tree': ([node]) Group tree for this request,
#   'expiretime': (float) The time to consider this entry as void.
#   }
request_datum = {}


# This indicates the maximum number of times we should attempt to resolve each
# group.
MAX_PASSES_PER_NODE = 5
Exemple #4
0
  query = 'INSERT INTO location (ip_addr, city, country_code, longitude, latitude) VALUES '
  # Specifies the location tuple
  query += "('%s', '%s', '%s', %s, %s) " % (ip_addr, city, country_code, longitude, latitude)
  query += "ON DUPLICATE KEY UPDATE "
  # Specifies the location tuple for the update clause
  query += "city='%s', country_code='%s', longitude=%s, latitude=%s" % (city, country_code, longitude, latitude)

  selexorhelper.autoretry_mysql_command(cursor, query)




if __name__=='__main__':
  global logger
  global nodestate_transition_key
  logger = selexorhelper.setup_logging('selexordatabase')

  nodestate_transition_key = rsa_file_to_publickey(settings.path_to_nodestate_transition_key)

  geoip_init_client()

  # Perform any first-time initialization if specified by the administrator.
  if len(sys.argv) > 1 and sys.argv[1] == 'initialize':
    # Create the databases if they haven't been created
    create_database()
    exit()

  print "Probing service has started!"
  print "Press CTRL+C to stop the server."

  # Run until Ctrl+C is issued