Populate the conf.L2Socket and conf.L3Socket
    according to the various use_* parameters
339305
def _set_conf_sockets():
    
    if conf.use_bpf and not BSD:
        Interceptor.set_from_hook(conf, "use_bpf", False)
        raise ScapyInvalidPlatformException("BSD-like (OSX, *BSD...) only !")
    if conf.use_winpcapy and not WINDOWS:
        Interceptor.set_from_hook(conf, "use_winpcapy", False)
        raise ScapyInvalidPlatformException("Windows only !")
    # we are already in an Interceptor hook, use Interceptor.set_from_hook
    if conf.use_pcap or conf.use_dnet or conf.use_winpcapy:
        try:
            from scapy.arch.pcapdnet import L2pcapListenSocket, L2pcapSocket, \
                L3pcapSocket
        except ImportError:
            warning("No pcap provider available ! pcap won't be used")
            Interceptor.set_from_hook(conf, "use_winpcapy", False)
            Interceptor.set_from_hook(conf, "use_pcap", False)
        else:
            conf.L3socket = L3pcapSocket
            conf.L3socket6 = functools.partial(L3pcapSocket, filter="ip6")
            conf.L2socket = L2pcapSocket
            conf.L2listen = L2pcapListenSocket
            return
    if conf.use_bpf:
        from scapy.arch.bpf.supersocket import L2bpfListenSocket, \
            L2bpfSocket, L3bpfSocket
        conf.L3socket = L3bpfSocket
        conf.L3socket6 = functools.partial(L3bpfSocket, filter="ip6")
        conf.L2socket = L2bpfSocket
        conf.L2listen = L2bpfListenSocket
        return
    if LINUX:
        from scapy.arch.linux import L3PacketSocket, L2Socket, L2ListenSocket
        conf.L3socket = L3PacketSocket
        conf.L3socket6 = functools.partial(L3PacketSocket, filter="ip6")
        conf.L2socket = L2Socket
        conf.L2listen = L2ListenSocket
        return
    if WINDOWS:
        from scapy.arch.windows import _NotAvailableSocket
        from scapy.arch.windows.native import L3WinSocket, L3WinSocket6
        conf.L3socket = L3WinSocket
        conf.L3socket6 = L3WinSocket6
        conf.L2socket = _NotAvailableSocket
        conf.L2listen = _NotAvailableSocket
        return
    from scapy.supersocket import L3RawSocket
    from scapy.layers.inet6 import L3RawSocket6
    conf.L3socket = L3RawSocket
    conf.L3socket6 = L3RawSocket6
107704
def setup(self):
        ''''''
        TelnetHandlerBase.setup(self)
        # Spawn a greenlet to handle socket input
        self.greenlet_ic = eventlet.spawn(self.inputcooker)
        # Note that inputcooker exits on EOF

        # Sleep for 0.5 second to allow options negotiation
        eventlet.sleep(0.5)
314003
def _init_listen_socket(self):
        
        self.debug("()")
        self._listen_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self._listen_socket.setsockopt(
            socket.SOL_SOCKET,
            socket.SO_REUSEADDR,
            1
        )
        self._listen_socket.bind((self._listen_ip, self._listen_port))
        self._listening.append(self._listen_socket)
1072067
function appender(configuration)
{
	var socket = dgram.createSocket('udp4');

	return function(loggingEvent)
	{
		var loggingObject =
		{
			name: loggingEvent.categoryName,
			message: layout(loggingEvent),
			severity: loggingEvent.level.level,
			severityText: loggingEvent.level.levelStr,
		};

		if (configuration.application)
		{
			loggingObject.application = configuration.application;
		}

		if (configuration.environment)
		{
			loggingObject.environment = configuration.environment;
		}

		if (MDC && MDC.active)
		{
			Object.keys(MDC.active).forEach(function(key)
			{
				loggingObject[key] = MDC.active[key];
			});
		}

		send(socket, configuration.host, configuration.port, loggingObject);
	};
}
13312
def _use_ssh_config(self, dict_arg):
        
        connect_dict = dict_arg.copy()

        # Use SSHConfig to generate source content.
        full_path = path.abspath(path.expanduser(self.ssh_config_file))
        if path.exists(full_path):
            ssh_config_instance = paramiko.SSHConfig()
            with io.open(full_path, "rt", encoding="utf-8") as f:
                ssh_config_instance.parse(f)
                source = ssh_config_instance.lookup(self.host)
        else:
            source = {}

        if "proxycommand" in source:
            proxy = paramiko.ProxyCommand(source["proxycommand"])
        elif "ProxyCommand" in source:
            proxy = paramiko.ProxyCommand(source["ProxyCommand"])
        else:
            proxy = None

        # Only update 'hostname', 'sock', 'port', and 'username'
        # For 'port' and 'username' only update if using object defaults
        if connect_dict["port"] == 22:
            connect_dict["port"] = int(source.get("port", self.port))
        if connect_dict["username"] == "":
            connect_dict["username"] = source.get("user", self.username)
        if proxy:
            connect_dict["sock"] = proxy
        connect_dict["hostname"] = source.get("hostname", self.host)

        return connect_dict
525399
public synchronized void buildThriftSocketPool(ClientSocketPoolParameters parameters) {
		if (!ServerUtil.checkHostAndPort(parameters.getHost(), parameters.getPort()))
			throw new IllegalArgumentException("Server host or port is null !");
		SimpleSocketPoolImpl self = selfMap.get(parameters.getKey());
		if (self == null)
			self = init(parameters);
		try {
			for (byte i = 0; i < size; i++) {
				self.socketPool.put(new Byte(i), parameters.buildClientThriftSocket());
				self.socketStatusArray[i] = Boolean.FALSE;
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
863980
def _configured_socket(address, options):
    
    sock = _create_connection(address, options)
    ssl_context = options.ssl_context

    if ssl_context is not None:
        host = address[0]
        try:
            # According to RFC6066, section 3, IPv4 and IPv6 literals are
            # not permitted for SNI hostname.
            # Previous to Python 3.7 wrap_socket would blindly pass
            # IP addresses as SNI hostname.
            # https://bugs.python.org/issue32185
            # We have to pass hostname / ip address to wrap_socket
            # to use SSLContext.check_hostname.
            if _HAVE_SNI and (not is_ip_address(host) or _PY37PLUS):
                sock = ssl_context.wrap_socket(sock, server_hostname=host)
            else:
                sock = ssl_context.wrap_socket(sock)
        except _SSLCertificateError:
            sock.close()
            # Raise CertificateError directly like we do after match_hostname
            # below.
            raise
        except IOError as exc:
            sock.close()
            # We raise AutoReconnect for transient and permanent SSL handshake
            # failures alike. Permanent handshake failures, like protocol
            # mismatch, will be turned into ServerSelectionTimeoutErrors later.
            _raise_connection_failure(address, exc, "SSL handshake failed: ")
        if (ssl_context.verify_mode and not
                getattr(ssl_context, "check_hostname", False) and
                options.ssl_match_hostname):
            try:
                match_hostname(sock.getpeercert(), hostname=host)
            except CertificateError:
                sock.close()
                raise

    sock.settimeout(options.socket_timeout)
    return sock
250462
function ModulesCtrl($scope, $location, $rootScope, $window, $timeout, $sce, 
                     _bind, _modules, _req, _socket) {

  /****************************************************************************/
  /* INITIALIZATION                                                           */
  /****************************************************************************/
  /* Handhsaking [modules] */
  _socket.on('modules', function(state) {
    //console.log('========================================');
    //console.log(JSON.stringify(state, null, 2));
    //console.log('----------------------------------------');
    $scope.modules = state;
  });

  /* Handhsaking [about] */
  _socket.on('about', function(state) {
    //console.log('========================================');
    //console.log(JSON.stringify(state, null, 2));
    //console.log('----------------------------------------');
    $scope.about = state;
  });

  _socket.emit('handshake', 'modules');
  _socket.emit('handshake', 'about');

  $window.document.title = 'Breach::Modules';

  /****************************************************************************/
  /* COMMANDS                                                                  */
  /****************************************************************************/
  $scope.modules_install = function() {
    var path = $scope.install_path;
    $scope.install_path = '';
    async.waterfall([
      function(cb_) {
        _modules.add(path).then(function(data) {
          return cb_(null, data.module);
        });
      },
      function(module, cb_) {
        _modules.install(module.path).then(function(data) {
          return cb_(null, data.module);
        });
      },
      function(module, cb_) {
        _modules.run(module.path).then(function(data) {
          return cb_(null, data.module);
        });
      }
    ], function(err) {
    });
  };

  $scope.modules_remove = function(path) {
    _modules.remove(path).then(function(data) {
    });
  };

  $scope.modules_update = function(path) {
    _modules.update(path).then(function(data) {
    });
  };

  $scope.modules_kill = function(path) {
    _modules.kill(path).then(function(data) {
    });
  };
  $scope.modules_run = function(path) {
    _modules.run(path).then(function(data) {
    });
  };

  $scope.modules_restart = function(path) {
    async.series([
      function(cb_) {
        _modules.kill(path).then(function(data) {
          return cb_();
        });
      },
      function(cb_) {
        _modules.run(path).then(function(data) {
          return cb_();
        });
      },
    ], function(err) {
    });
  };

  $scope.about_install = function() {
    _req.post('/about/install', {}).then(function(data) {
    });
  };
}
1128594
def _init_nodes(self, config):
        
        if not isinstance(config, dict):
            raise TypeError('"config" must be a dictionary')

        for (name, conf) in six.iteritems(config):
            args = [] if 'args' not in conf else conf['args']
            kwargs = {} if 'kwargs' not in conf else conf['kwargs']

            dependencies = set()
            arg_deps = self._get_dependencies_from_args(args)
            kwarg_deps = self._get_dependencies_from_kwargs(kwargs)

            dependencies.update(arg_deps)
            dependencies.update(kwarg_deps)

            self._nodes[name] = dependencies
1259042
def srpflood(x, promisc=None, filter=None, iface=None, iface_hint=None, nofilter=None, *args, **kargs):  # noqa: E501
    """"""
    if iface is None and iface_hint is not None:
        iface = conf.route.route(iface_hint)[0]
    s = conf.L2socket(promisc=promisc, filter=filter, iface=iface, nofilter=nofilter)  # noqa: E501
    r = sndrcvflood(s, x, *args, **kargs)
    s.close()
    return r
502239
def __init(self):
        
        params = {
            "f" : "json",
        }
        json_dict = self._get(self._url, params,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port)
        self._json_dict = json_dict
        self._json = json.dumps(self._json_dict)
        attributes = [attr for attr in dir(self)
                      if not attr.startswith('__') and \
                      not attr.startswith('_')]

        for k,v in json_dict.items():
            if k in attributes:
                if k == "routeLayers" and json_dict[k]:
                    self._routeLayers = []
                    for rl in v:
                        self._routeLayers.append(
                            RouteNetworkLayer(url=self._url + "/%s" % rl,
                                              securityHandler=self._securityHandler,
                                              proxy_url=self._proxy_url,
                                              proxy_port=self._proxy_port,
                                              initialize=False))

                elif k == "serviceAreaLayers" and json_dict[k]:
                    self._serviceAreaLayers = []
                    for sal in v:
                        self._serviceAreaLayers.append(
                            ServiceAreaNetworkLayer(url=self._url + "/%s" % sal,
                                                    securityHandler=self._securityHandler,
                                                    proxy_url=self._proxy_url,
                                                    proxy_port=self._proxy_port,
                                                    initialize=False))

                elif k == "closestFacilityLayers" and json_dict[k]:
                    self._closestFacilityLayers = []
                    for cf in v:
                        self._closestFacilityLayers.append(
                            ClosestFacilityNetworkLayer(url=self._url + "/%s" % cf,
                                                    securityHandler=self._securityHandler,
                                                    proxy_url=self._proxy_url,
                                                    proxy_port=self._proxy_port,
                                                    initialize=False))
                else:
                    setattr(self, "_"+ k, v)
            else:
                print ("attribute %s is not implemented." % k)
320714
def init(self, conf):
        

        # For searching class and elements for on-demand
        # we need link to types
        self.my_conf = conf
        self.lists_on_demand = []
        self.hosts = self.my_conf.hosts
        # For special void host_name handling...
        self.host_class = self.hosts.inner_class
        self.lists_on_demand.append(self.hosts)
        self.services = self.my_conf.services
        self.contacts = self.my_conf.contacts
        self.lists_on_demand.append(self.contacts)
        self.hostgroups = self.my_conf.hostgroups
        self.lists_on_demand.append(self.hostgroups)
        self.commands = self.my_conf.commands
        self.servicegroups = self.my_conf.servicegroups
        self.lists_on_demand.append(self.servicegroups)
        self.contactgroups = self.my_conf.contactgroups
        self.lists_on_demand.append(self.contactgroups)
        self.illegal_macro_output_chars = self.my_conf.illegal_macro_output_chars
        self.env_prefix = self.my_conf.env_variables_prefix
74774
def configure(conf)
      if conf['output_type'] && !conf['format']
        conf['format'] = conf['output_type']
      end
      compat_parameters_convert(conf, :inject, :formatter)

      super
      @host = conf['host']
      @port = conf['port']
      @token = conf['token']
      @hostname = conf['hostname'] || Socket.gethostname.split('.').first

      # Determine mapping of record keys to syslog keys
      @mappings = {}
      SYSLOG_HEADERS.each do |key_name|
        conf_key = "#{key_name}_key"
        @mappings[key_name] = conf[conf_key] if conf.key?(conf_key)
      end

      @formatter = formatter_create(conf: conf.elements('format').first, default_type: DEFAULT_FORMAT_TYPE)
    end
568625
function() {
      var t = this, hostName = t.get('hostName'), hostPort = t.get('hostPort'),
      url = t.get('url');

      // Build the URL if not specified
      if (!url) {
        url = t.attributes.url = 'http://' + hostName + ':' + hostPort;
        t.set('url', url);
      }

      // Connect with this url
      var opts = {
        // 'transports': ['websocket', 'xhr-polling', 'jsonp-polling'],
        'force new connection': true,      // Don't re-use existing connections
        'reconnect': false                 // Don't let socket.io reconnect.
                                           // Reconnects are performed by the Router.
      };
      var socket = SocketIO.connect(url, opts);
      t.set({socket:socket}).bindConnectionEvents();
    }
516342
def _bind_socket(self, bindaddr):
        """"""
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock.setblocking(0)
        try:
            sock.bind(bindaddr)
        except Exception:
            self._logger.exception("Unable to bind to %s" % str(bindaddr))
            raise
        sock.listen(self.BACKLOG)
        return sock
844857
function WebsocketRouter(options) {
  options = options || {};
  this.clientsPath = [];
  this.host = options.host ? options.host : 'localhost';
  this.port = options.port ? options.port : 8000;
}
118871
def _setup_fun_config(self, fun_conf):
        '''
        
        '''
        conf = copy.deepcopy(self.config)
        conf['file_client'] = 'local'
        conf['fun'] = ''
        conf['arg'] = []
        conf['kwarg'] = {}
        conf['cache_jobs'] = False
        conf['print_metadata'] = False
        conf.update(fun_conf)
        conf['fun'] = conf['fun'].split(':')[-1]  # Discard typing prefix

        return conf