Documentation ¶
Index ¶
Constants ¶
const ( UnifiedEndpointHostname = "100.127.69.42" UnifiedEndpointPort = 80 )
const ( SoracomNameServer1 = "100.127.0.53" SoracomNameServer2 = "100.127.1.53" )
Variables ¶
var Revision = "dev"
Functions ¶
This section is empty.
Types ¶
type ArcSession ¶
type ArcSession struct { // ArcServerPeerPublicKey is WireGuard public key of the SORACOM Arc server. ArcServerPeerPublicKey Key `json:"arcServerPeerPublicKey"` // ArcServerEndpoint is a UDP endpoint of the SORACOM Arc server. ArcServerEndpoint *UDPAddr `json:"arcServerEndpoint"` // ArcAllowedIPs holds IP addresses allowed for routing from the SORACOM Arc server. ArcAllowedIPs []*IPNet `json:"arcAllowedIPs"` // ArcClientPeerPrivateKey holds private key from SORACOM Arc server. ArcClientPeerPrivateKey Key `json:"arcClientPeerPrivateKey,omitempty"` // ArcClientPeerIpAddress is an IP address for this client. ArcClientPeerIpAddress netip.Addr `json:"arcClientPeerIpAddress,omitempty"` }
ArcSession holds SORACOM Arc configurations received from the server.
type Config ¶
type Config struct { // PrivateKey is WireGuard private key. PrivateKey Key `json:"privateKey"` // ArcSession holds connection information provided from SORACOM Arc server. ArcSession *ArcSession `json:"arcSessionStatus,omitempty"` // LogLevel specifies logging level, verbose (2), error (1), or silent (0). LogLevel int `json:"logLevel"` }
Config holds SORACOM Arc client configurations.
type IPNet ¶
IPNet is an alias for net.IPNet.
func (*IPNet) UnmarshalText ¶
UnmarshalText converts a byte array into IPNet. UnmarshalText returns error if invalid CIDR is provided.
type Key ¶
Key is an alias for wgtypes.Key.
func (*Key) AsHexString ¶
AsHexString returns hexadecimal encoding of Key.
func (*Key) UnmarshalText ¶
UnmarshalText decodes a byte array of private key to the Key. If text is invalid WireGuard key, UnmarshalText returns an error.
type Params ¶
type Params struct { // Method is an HTTP method of the request. Only GET or POST is supported. Method string // Path is a path of the request. Path string // Body is a body of the request. Body string }
Params is a set of parameters for HTTP request.
type UDPAddr ¶
UDPAddr represents the UDP address with keeping original endpoint.
func (UDPAddr) String ¶
String returns string representation of UDPAddr for WireGuard configuration.
func (*UDPAddr) UnmarshalText ¶
UnmarshalText converts a byte array into UDPAddr. UnmarshalText returns error if the format is invalid (not "ip" or "ip:port"), IP address specified is invalid, or the port is not a 16-bit unsigned integer.
type UnifiedEndpointHTTPClient ¶
type UnifiedEndpointHTTPClient struct {
// contains filtered or unexported fields
}
UnifiedEndpointHTTPClient is an HTTP client that can be used to communicate with SORACOM Unified Endpoint.
func NewUnifiedEndpointHTTPClient ¶
func NewUnifiedEndpointHTTPClient(config Config) (*UnifiedEndpointHTTPClient, error)
NewUnifiedEndpointHTTPClient creates a new HTTP client specific for the SORACOM Unified Endpoint.
Args: - `config`: A Config object containing the configuration for the SORACOM Arc connection.
Returns: - `*UnifiedEndpointHTTPClient`: A pointer to the created UnifiedEndpointHTTPClient and an error object. If there's any error occurred during setting up the tunnel connection or parsing the endpoint URL, the error will be returned.
The created client uses the http.Transport with a custom DialContext for making HTTP requests. The User-Agent header for all requests made by this client is set to "libsoratun/0.0.1".
func (*UnifiedEndpointHTTPClient) DoRequest ¶
DoRequest sends an HTTP request and returns the response.
Args: - `req`: A pointer to the http.Request object to be sent.
Returns: - `*http.Response`: A pointer to the http.Response, and an error object.
func (*UnifiedEndpointHTTPClient) MakeRequest ¶
func (c *UnifiedEndpointHTTPClient) MakeRequest(params *Params) (*http.Request, error)
MakeRequest creates a new HTTP request based on provided parameters.
Args: - `params`: A Params struct containing the parameters for the request.
- `params.Method`: The HTTP method of the request. Only GET or POST is supported. Any extra spaces are trimmed.
- `params.Path`: The path of the request. It cannot be empty, and any leading slashes are removed.
- `params.Body`: The body of the request. It cannot be empty.
Returns: - `*http.Request`: A pointer to the created http.Request, and an error object.