Documentation ¶
Overview ¶
Package soratun implements userspace SORACOM Arc client.
Index ¶
- Constants
- func ConfigureInterface(iname string, config *Config) error
- func DefaultInterfaceName() string
- func Up(ctx context.Context, config *Config)
- type ArcSession
- type AuthKeyBootstrapper
- type Bootstrapper
- type CellularBootstrapper
- type Config
- type DefaultSoracomClient
- type DefaultSoracomKryptonClient
- type IPNet
- type Key
- type KryptonClientConfig
- type Profile
- type SimBootstrapper
- type SimProfile
- type SoracomClient
- type SoracomKryptonClient
- type UDPAddr
- type VirtualSim
Constants ¶
const ( // LogLevelVerbose is an alias for WireGuard device logger equivalent. LogLevelVerbose = device.LogLevelVerbose // LogLevelError is an alias for WireGuard device logger equivalent. LogLevelError = device.LogLevelError // LogLevelSilent is an alias for WireGuard device logger equivalent. LogLevelSilent = device.LogLevelSilent // DefaultPersistentKeepaliveInterval defines WireGuard persistent keepalive interval to SORACOM Arc. DefaultPersistentKeepaliveInterval = 60 // DefaultMTU is MTU for the configured interface. DefaultMTU = device.DefaultMTU )
Variables ¶
This section is empty.
Functions ¶
func ConfigureInterface ¶
ConfigureInterface create a new network interface with given SORACOM Arc configuration. Then setup routing table for allowedIPs.
func DefaultInterfaceName ¶
func DefaultInterfaceName() string
DefaultInterfaceName returns a default interface name
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 net.IP `json:"arcClientPeerIpAddress,omitempty"` }
ArcSession holds SORACOM Arc configurations received from the server.
func (*ArcSession) MarshalJSON ¶
func (a *ArcSession) MarshalJSON() ([]byte, error)
MarshalJSON converts struct to JSON, omitting ArcClientPeerPrivateKey field which is redundant for configuration file.
type AuthKeyBootstrapper ¶
type AuthKeyBootstrapper struct {
Profile *Profile
}
AuthKeyBootstrapper defines bootstrap method with SORACOM API authentication. Needs Profile information.
type Bootstrapper ¶
Bootstrapper defines how to bootstrap virtual SIM with SORACOM.
type CellularBootstrapper ¶
type CellularBootstrapper struct {
Endpoint string
}
CellularBootstrapper defines bootstrap method with SORACOM Krypton cellular authentication. Needs active cellular connection.
type Config ¶
type Config struct { // PrivateKey is WireGuard private key. PrivateKey Key `json:"privateKey"` // PublicKey is WireGuard public key. PublicKey Key `json:"publicKey"` // SimId is virtual SIM's SimId for the connection. SimId string `json:"simId"` // LogLevel specifies logging level, verbose, error, or silent. LogLevel int `json:"logLevel"` // If EnableMetrics is true, metrics will be logged when log-level is verbose or error. EnableMetrics bool `json:"enableMetrics"` // Interface is name for the tunnel interface. Interface string `json:"interface"` // AdditionalAllowedIPs holds a set of WireGuard allowed IPs in addition to the list which will get while creating Arc session. AdditionalAllowedIPs []*IPNet `json:"additionalAllowedIPs,omitempty"` // Mtu of the interface. Mtu int `json:"mtu,omitempty"` // WireGuard PersistentKeepalive parameter. PersistentKeepalive int `json:"persistentKeepalive,omitempty"` // PostUp is array of commands which will be executed after the interface is up successfully. PostUp [][]string `json:"postUp,omitempty"` // PostDown is array of commands which will be executed after the interface is removed successfully. PostDown [][]string `json:"postDown,omitempty"` // Profile is for SORACOM API access. Profile *Profile `json:"profile,omitempty"` // ArcSession holds connection information provided from SORACOM Arc server. ArcSession *ArcSession `json:"arcSessionStatus,omitempty"` }
Config holds SORACOM Arc client configurations.
type DefaultSoracomClient ¶
type DefaultSoracomClient struct {
// contains filtered or unexported fields
}
DefaultSoracomClient is an implementation of the SoracomClient for the general use case.
func (*DefaultSoracomClient) CreateArcSession ¶
func (c *DefaultSoracomClient) CreateArcSession(simId, publicKey string) (*ArcSession, error)
CreateArcSession creates new Arc session.
func (*DefaultSoracomClient) CreateVirtualSim ¶
func (c *DefaultSoracomClient) CreateVirtualSim() (*VirtualSim, error)
CreateVirtualSim creates new virtual SIM.
func (*DefaultSoracomClient) SetVerbose ¶
func (c *DefaultSoracomClient) SetVerbose(v bool)
SetVerbose sets if verbose output is enabled or not.
func (*DefaultSoracomClient) Verbose ¶
func (c *DefaultSoracomClient) Verbose() bool
Verbose returns if verbose output is enabled or not.
type DefaultSoracomKryptonClient ¶
type DefaultSoracomKryptonClient struct {
// contains filtered or unexported fields
}
DefaultSoracomKryptonClient is an implementation of the SoracomKryptonClient for the general use case.
func (*DefaultSoracomKryptonClient) Bootstrap ¶
func (c *DefaultSoracomKryptonClient) Bootstrap() (*ArcSession, error)
Bootstrap bootstraps Arc virtual SIM.
func (*DefaultSoracomKryptonClient) BootstrapWithKeyID ¶
func (c *DefaultSoracomKryptonClient) BootstrapWithKeyID() (*ArcSession, error)
BootstrapWithKeyID bootstraps Arc virtual SIM with SIM authentication.
func (*DefaultSoracomKryptonClient) SetVerbose ¶
func (c *DefaultSoracomKryptonClient) SetVerbose(v bool)
SetVerbose sets if verbose output is enabled or not.
func (*DefaultSoracomKryptonClient) Verbose ¶
func (c *DefaultSoracomKryptonClient) Verbose() bool
Verbose returns if verbose output is enabled or not.
type IPNet ¶
IPNet is an alias for net.IPNet.
func (*IPNet) MarshalText ¶
MarshalText converts struct to a string.
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) MarshalText ¶
MarshalText encodes Key to an array of bytes.
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 KryptonClientConfig ¶
type KryptonClientConfig struct {
Endpoint string
}
A KryptonClientConfig holds SORACOM Krypton provisioning API client related information.
type Profile ¶
type Profile struct { // AuthKey is SORACOM API auth key secret. AuthKey string `json:"authKey,omitempty"` // AuthKeyID is SORACOM API auth key ID. AuthKeyID string `json:"authKeyId,omitempty"` // Endpoint is SORACOM API endpoint. Endpoint string `json:"endpoint,omitempty"` }
A Profile holds SORACOM API client related information.
type SimBootstrapper ¶
SimBootstrapper defines bootstrap method with SORACOM Krypton SIM authentication. Needs krypton-cli installed.
type SimProfile ¶
type SimProfile struct { // Iccid is ICCID of the subscriber. Iccid string `json:"iccid"` // ArcClientPeerPrivateKey is WireGuard private key of the subscriber. ArcClientPeerPrivateKey string `json:"arcClientPeerPrivateKey"` // ArcClientPeerPublicKey is WireGuard public key of the subscriber. ArcClientPeerPublicKey string `json:"arcClientPeerPublicKey"` // PrimaryImsi is Imsi of this virtual SIM. PrimaryImsi string `json:"primaryImsi"` }
SimProfile is a SIM profile which holds one of profiles in the subscription container.
type SoracomClient ¶
type SoracomClient interface { CreateVirtualSim() (*VirtualSim, error) CreateArcSession(simId, publicKey string) (*ArcSession, error) SetVerbose(v bool) Verbose() bool }
A SoracomClient represents an API client for SORACOM API. See https://developers.soracom.io/en/docs/tools/api-reference/ or https://dev.soracom.io/jp/docs/api_guide/
func NewDefaultSoracomClient ¶
func NewDefaultSoracomClient(p Profile) (SoracomClient, error)
NewDefaultSoracomClient returns new SoracomClient for caller.
type SoracomKryptonClient ¶
type SoracomKryptonClient interface { Bootstrap() (*ArcSession, error) SetVerbose(v bool) Verbose() bool }
A SoracomKryptonClient represents a maybe-over-complicated API client for SORACOM Krypton Provisioning API. See https://developers.soracom.io/en/api/krypton/ https://users.soracom.io/ja-jp/tools/krypton-api/
func NewDefaultSoracomKryptonClient ¶
func NewDefaultSoracomKryptonClient(config *KryptonClientConfig) SoracomKryptonClient
NewDefaultSoracomKryptonClient returns new SoracomClient for caller.
type UDPAddr ¶
UDPAddr represents the UDP address with keeping original endpoint.
func (*UDPAddr) MarshalText ¶
MarshalText converts struct to a string.
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 VirtualSim ¶
type VirtualSim struct { // OperatorId is operator ID of the subscriber. OperatorId string `json:"operatorId"` // Status is virtual SIM status, active or terminated as of 2021 first release. Status string `json:"status"` // SimId is SIM ID of the subscriber. SimId string `json:"simId"` // ArcSession holds Arc connection information. ArcSession ArcSession `json:"arcSessionStatus"` // Profiles holds series of SimProfile, (not SORACOM API Profile). Profiles map[string]SimProfile `json:"profiles"` }
VirtualSim represents virtual subscriber.