Class: MythicBeasts::Proxy
- Inherits:
-
Object
- Object
- MythicBeasts::Proxy
- Defined in:
- lib/mythic_beasts/proxy.rb
Overview
IPv4 to IPv6 Proxy API
Manages IPv4-to-IPv6 proxy endpoints for making IPv6-only servers accessible via IPv4. Useful for cost-effective IPv6-only VPS deployments.
Instance Method Summary collapse
-
#add(domain, hostname, endpoints) ⇒ Hash
Add proxy endpoints for a hostname without replacing existing ones.
-
#create_simple(domain, hostname, ipv6_address, proxy_protocol: false) ⇒ Hash
Convenience method: Create a simple proxy endpoint for a server.
-
#delete(domain, hostname) ⇒ Hash
Delete all proxy endpoints for a hostname.
-
#delete_endpoint(domain, hostname, address, site = nil) ⇒ Hash
Delete a specific proxy endpoint.
-
#initialize(client) ⇒ Proxy
constructor
A new instance of Proxy.
-
#list ⇒ Array<Hash>
List all proxy endpoints accessible to the authenticated user.
-
#list_for_domain(domain) ⇒ Array<Hash>
List proxy endpoints for a specific domain.
-
#list_for_hostname(domain, hostname) ⇒ Array<Hash>
List proxy endpoints for a specific hostname.
-
#replace(domain, hostname, endpoints) ⇒ Hash
Create or replace proxy endpoints for a hostname.
-
#sites ⇒ Array<String>
List available proxy server locations.
Constructor Details
#initialize(client) ⇒ Proxy
Returns a new instance of Proxy.
12 13 14 |
# File 'lib/mythic_beasts/proxy.rb', line 12 def initialize(client) @client = client end |
Instance Method Details
#add(domain, hostname, endpoints) ⇒ Hash
Add proxy endpoints for a hostname without replacing existing ones
86 87 88 |
# File 'lib/mythic_beasts/proxy.rb', line 86 def add(domain, hostname, endpoints) @client.post("/proxy/endpoints/#{domain}/#{hostname}", body: {endpoints: endpoints}) end |
#create_simple(domain, hostname, ipv6_address, proxy_protocol: false) ⇒ Hash
Convenience method: Create a simple proxy endpoint for a server
141 142 143 144 145 146 147 148 149 |
# File 'lib/mythic_beasts/proxy.rb', line 141 def create_simple(domain, hostname, ipv6_address, proxy_protocol: false) endpoint = { address: ipv6_address, site: "all" } endpoint[:proxy_protocol] = true if proxy_protocol add(domain, hostname, [endpoint]) end |
#delete(domain, hostname) ⇒ Hash
Delete all proxy endpoints for a hostname
97 98 99 |
# File 'lib/mythic_beasts/proxy.rb', line 97 def delete(domain, hostname) @client.delete("/proxy/endpoints/#{domain}/#{hostname}") end |
#delete_endpoint(domain, hostname, address, site = nil) ⇒ Hash
Delete a specific proxy endpoint
110 111 112 113 114 |
# File 'lib/mythic_beasts/proxy.rb', line 110 def delete_endpoint(domain, hostname, address, site = nil) path = "/proxy/endpoints/#{domain}/#{hostname}/#{address}" path += "/#{site}" if site @client.delete(path) end |
#list ⇒ Array<Hash>
List all proxy endpoints accessible to the authenticated user
22 23 24 25 |
# File 'lib/mythic_beasts/proxy.rb', line 22 def list response = @client.get("/proxy/endpoints") response["endpoints"] || response[:endpoints] || [] end |
#list_for_domain(domain) ⇒ Array<Hash>
List proxy endpoints for a specific domain
33 34 35 36 |
# File 'lib/mythic_beasts/proxy.rb', line 33 def list_for_domain(domain) response = @client.get("/proxy/endpoints/#{domain}") response["endpoints"] || response[:endpoints] || [] end |
#list_for_hostname(domain, hostname) ⇒ Array<Hash>
List proxy endpoints for a specific hostname
45 46 47 48 |
# File 'lib/mythic_beasts/proxy.rb', line 45 def list_for_hostname(domain, hostname) response = @client.get("/proxy/endpoints/#{domain}/#{hostname}") response["endpoints"] || response[:endpoints] || [] end |
#replace(domain, hostname, endpoints) ⇒ Hash
Create or replace proxy endpoints for a hostname
This replaces ALL existing endpoints for the hostname.
67 68 69 |
# File 'lib/mythic_beasts/proxy.rb', line 67 def replace(domain, hostname, endpoints) @client.put("/proxy/endpoints/#{domain}/#{hostname}", body: {endpoints: endpoints}) end |
#sites ⇒ Array<String>
List available proxy server locations
122 123 124 125 |
# File 'lib/mythic_beasts/proxy.rb', line 122 def sites response = @client.get("/proxy/sites") response["sites"] || response[:sites] || [] end |