Backend half

This commit is contained in:
2025-07-11 19:56:28 +02:00
parent fa868e7c1d
commit 8600fa7c1d
19426 changed files with 3750448 additions and 8108 deletions
@@ -0,0 +1,8 @@
var getEndpoint = function() {
return {
IPv4: 'http://169.254.169.254',
IPv6: 'http://[fd00:ec2::254]',
};
};
module.exports = getEndpoint;
@@ -0,0 +1,12 @@
var ENV_ENDPOINT_NAME = 'AWS_EC2_METADATA_SERVICE_ENDPOINT';
var CONFIG_ENDPOINT_NAME = 'ec2_metadata_service_endpoint';
var getEndpointConfigOptions = function() {
return {
environmentVariableSelector: function(env) { return env[ENV_ENDPOINT_NAME]; },
configFileSelector: function(profile) { return profile[CONFIG_ENDPOINT_NAME]; },
default: undefined,
};
};
module.exports = getEndpointConfigOptions;
@@ -0,0 +1,8 @@
var getEndpointMode = function() {
return {
IPv4: 'IPv4',
IPv6: 'IPv6',
};
};
module.exports = getEndpointMode;
@@ -0,0 +1,14 @@
var EndpointMode = require('./get_endpoint_mode')();
var ENV_ENDPOINT_MODE_NAME = 'AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE';
var CONFIG_ENDPOINT_MODE_NAME = 'ec2_metadata_service_endpoint_mode';
var getEndpointModeConfigOptions = function() {
return {
environmentVariableSelector: function(env) { return env[ENV_ENDPOINT_MODE_NAME]; },
configFileSelector: function(profile) { return profile[CONFIG_ENDPOINT_MODE_NAME]; },
default: EndpointMode.IPv4,
};
};
module.exports = getEndpointModeConfigOptions;
@@ -0,0 +1,24 @@
var AWS = require('../core');
var Endpoint = require('./get_endpoint')();
var EndpointMode = require('./get_endpoint_mode')();
var ENDPOINT_CONFIG_OPTIONS = require('./get_endpoint_config_options')();
var ENDPOINT_MODE_CONFIG_OPTIONS = require('./get_endpoint_mode_config_options')();
var getMetadataServiceEndpoint = function() {
var endpoint = AWS.util.loadConfig(ENDPOINT_CONFIG_OPTIONS);
if (endpoint !== undefined) return endpoint;
var endpointMode = AWS.util.loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS);
switch (endpointMode) {
case EndpointMode.IPv4:
return Endpoint.IPv4;
case EndpointMode.IPv6:
return Endpoint.IPv6;
default:
throw new Error('Unsupported endpoint mode: ' + endpointMode);
}
};
module.exports = getMetadataServiceEndpoint;