Documentation ¶
Index ¶
- Constants
- Variables
- func FormatFingerprint(fpr []byte) string
- func GenerateKeys(password string, params EncryptionParameters) ([]byte, []byte)
- func IsWindows() bool
- func ParseYes(input string) bool
- func SerializedKeys(keys []otr3.PrivateKey) [][]byte
- func SystemConfigDir() string
- func WithHome(file string) string
- func XdgCacheDir() string
- func XdgConfigHome() string
- func XdgDataDir() string
- type Account
- func (a *Account) AddTrustedFingerprint(fpr []byte, uid string)
- func (a *Account) AllPrivateKeys() [][]byte
- func (a *Account) AuthorizeFingerprint(uid string, fingerprint []byte) error
- func (a *Account) EnsurePeer(uid string) *Peer
- func (a *Account) EnsurePrivateKey() (hasUpdate bool, e error)
- func (a *Account) GetPeer(uid string) (*Peer, bool)
- func (a *Account) HasFingerprint(uid string) bool
- func (a *Account) HasTorAuto() bool
- func (a *Account) ID() string
- func (a *Account) Is(jid string) bool
- func (a *Account) RemoveFingerprint(uid string, fpr []byte) bool
- func (a *Account) RemovePeer(uid string)
- func (a *Account) SaveCert(subject, issuer string, sha3Digest []byte)
- func (a *Account) SavePeerDetails(jid, nickname string, groups []string)
- func (a *Account) SetOTRPoliciesFor(jid string, c *otr3.Conversation)
- func (a *Account) ShouldEncryptTo(jid string) bool
- func (a *Account) ToggleAlwaysEncrypt()
- func (a *Account) ToggleConnectAutomatically()
- func (a *Account) UpdateEncryptionRequired(jid string, requireEnc bool)
- func (a *Account) UserIDForVerifiedFingerprint(fpr []byte) string
- type ApplicationConfig
- func (a *ApplicationConfig) Add(ac *Account)
- func (a *ApplicationConfig) AddNewAccount() (ac *Account, err error)
- func (a *ApplicationConfig) GetAccount(jid string) (*Account, bool)
- func (a *ApplicationConfig) GetUniqueID() string
- func (a *ApplicationConfig) HasEncryptedStorage() bool
- func (a *ApplicationConfig) Remove(toRemove *Account)
- func (a *ApplicationConfig) Save(ks KeySupplier) error
- func (a *ApplicationConfig) SetShouldSaveFileEncrypted(val bool) bool
- func (a *ApplicationConfig) UpdateToLatestVersion() bool
- func (a *ApplicationConfig) WhenLoaded(f func(*ApplicationConfig))
- type ByAccountNameAlphabetic
- type ByNaturalOrder
- type CertificatePin
- type CertificatePinForSerialization
- type CertificatePinsByNaturalOrder
- type ConnectionPolicy
- type DisplayConfig
- type EncryptionParameters
- type EncryptionSettings
- type Fingerprint
- type FingerprintForSerialization
- type KeySupplier
- type KnownFingerprint
- type LegacyByNaturalOrder
- type Peer
Constants ¶
const ( // Default encrypts conversations with this peer depending on the account // configuration (config.Account#AlwaysEncrypt) Default EncryptionSettings = "default" // AlwaysEncrypt always encrypts conversations with this peer AlwaysEncrypt = "always" // NeverEncrypt never encrypts conversations with this peer NeverEncrypt = "never" )
Variables ¶
var ( ConfigFile = flag.String("config-file", "", "Location of the config file") ConfigFileEncrypted = flag.Bool("config-file-encrypted", false, "Force config file to be encrypted even if the file name doesn't match the expected pattern") CreateAccount = flag.Bool("create", false, "If true, attempt to create account") DebugFlag = flag.Bool("debug", false, "Enable debug logging") AccountFlag = flag.String("account", "", "The account the CLI should connect to, if more than one is configured") MultiFlag = flag.Bool("multi", false, "If true, will not try to unify the windows, but create separate instances") VersionFlag = flag.Bool("version", false, "Print CoyIM version and exit") )
These flags represent all the available command line flags
var ( // ErrTorNotRunning is the error returned when Tor is required by the policy // but it was not found to be running (on port 9050 or 9051). ErrTorNotRunning = errors.New("Tor is not running") )
Functions ¶
func FormatFingerprint ¶
FormatFingerprint returns a formatted string of the fingerprint
func GenerateKeys ¶
func GenerateKeys(password string, params EncryptionParameters) ([]byte, []byte)
GenerateKeys takes a password and encryption parameters and generates an AES key and a MAC key using SCrypt
func SerializedKeys ¶
func SerializedKeys(keys []otr3.PrivateKey) [][]byte
SerializedKeys will generate a new slice of a byte slice containing serializations of all keys given
func SystemConfigDir ¶
func SystemConfigDir() string
SystemConfigDir returns the application data directory, valid on both windows and posix systems
func XdgCacheDir ¶
func XdgCacheDir() string
XdgCacheDir returns the standardized XDG Cache directory
func XdgConfigHome ¶
func XdgConfigHome() string
XdgConfigHome returns the standardized XDG Configuration directory
Types ¶
type Account ¶
type Account struct { //TODO: this should be JID Account string Nickname string `json:",omitempty"` Server string `json:",omitempty"` Proxies []string `json:",omitempty"` Password string `json:",omitempty"` Port int `json:",omitempty"` PrivateKeys [][]byte `json:",omitempty"` Peers []*Peer HideStatusUpdates bool OTRAutoTearDown bool OTRAutoAppendTag bool OTRAutoStartSession bool AlwaysEncrypt bool `json:",omitempty"` InstanceTag uint32 `json:",omitempty"` ConnectAutomatically bool Certificates []*CertificatePin `json:",omitempty"` PinningPolicy string `json:",omitempty"` LegacyKnownFingerprints []KnownFingerprint `json:"KnownFingerprints,omitempty"` DeprecatedPrivateKey []byte `json:"PrivateKey,omitempty"` LegacyServerCertificateSHA256 string `json:"ServerCertificateSHA256,omitempty"` // AlwaysEncryptWith and DontEncryptWith should be promoted to legacy and replaced with the peer settings AlwaysEncryptWith []string `json:",omitempty"` DontEncryptWith []string `json:",omitempty"` // contains filtered or unexported fields }
Account contains the configuration for one account
func (*Account) AddTrustedFingerprint ¶
AddTrustedFingerprint adds a new fingerprint for the given user
func (*Account) AllPrivateKeys ¶
AllPrivateKeys returns all private keys for this account
func (*Account) AuthorizeFingerprint ¶
AuthorizeFingerprint will authorize and add the fingerprint for the given user or return an error if the fingerprint is already associated with another user
func (*Account) EnsurePeer ¶
EnsurePeer returns the first peer with the given uid, or creates and adds a new one if none exist
func (*Account) EnsurePrivateKey ¶
EnsurePrivateKey generates a private key for the account in case it's missing
func (*Account) GetPeer ¶
GetPeer returns the first peer with the given uid, or false if none is found
func (*Account) HasFingerprint ¶
HasFingerprint returns true if we have the fingerprint for the given user
func (*Account) HasTorAuto ¶
HasTorAuto check if account has proxy with prefix "tor-auto://"
func (*Account) RemoveFingerprint ¶
RemoveFingerprint removes the fingerprint for the given uid
func (*Account) RemovePeer ¶
RemovePeer removes the given peer
func (*Account) SaveCert ¶
SaveCert will put the given certificate as a pinned certificate. It expects a SHA3-256 hash of the certificate.
func (*Account) SavePeerDetails ¶
SavePeerDetails store peer identifiable information only locally
func (*Account) SetOTRPoliciesFor ¶
func (a *Account) SetOTRPoliciesFor(jid string, c *otr3.Conversation)
SetOTRPoliciesFor will set the OTR policies on the given conversation based on the users settings
func (*Account) ShouldEncryptTo ¶
ShouldEncryptTo returns true if the connection with this peer should be encrypted
func (*Account) ToggleAlwaysEncrypt ¶
func (a *Account) ToggleAlwaysEncrypt()
ToggleAlwaysEncrypt toggles the state of AlwaysEncrypt config
func (*Account) ToggleConnectAutomatically ¶
func (a *Account) ToggleConnectAutomatically()
ToggleConnectAutomatically toggles the state of ConnectAutomatically config
func (*Account) UpdateEncryptionRequired ¶
UpdateEncryptionRequired will set a specific encryption setting for this peer
func (*Account) UserIDForVerifiedFingerprint ¶
UserIDForVerifiedFingerprint returns the user ID for the given verified fingerprint
type ApplicationConfig ¶
type ApplicationConfig struct { Accounts []*Account RawLogFile string `json:",omitempty"` NotifyCommand []string `json:",omitempty"` IdleSecondsBeforeNotification int `json:",omitempty"` Bell bool ConnectAutomatically bool Display DisplayConfig `json:",omitempty"` AdvancedOptions bool UniqueConfigurationID string // contains filtered or unexported fields }
ApplicationConfig contains the configuration for the application, including account information.
func LoadOrCreate ¶
func LoadOrCreate(configFile string, ks KeySupplier) (a *ApplicationConfig, ok bool, e error)
LoadOrCreate will try to load the configuration from the given configuration file or from the standard configuration file. If no file exists or it is malformed, or it could not be decrypted, an error will be returned. However, the returned Accounts instance will always be usable
func (*ApplicationConfig) Add ¶
func (a *ApplicationConfig) Add(ac *Account)
Add will add the account to the application configuration
func (*ApplicationConfig) AddNewAccount ¶
func (a *ApplicationConfig) AddNewAccount() (ac *Account, err error)
AddNewAccount creates a new account and adds it to the list of accounts
func (*ApplicationConfig) GetAccount ¶
func (a *ApplicationConfig) GetAccount(jid string) (*Account, bool)
GetAccount will return the account with the given JID or not OK if it doesn't exist
func (*ApplicationConfig) GetUniqueID ¶ added in v0.3.3
func (a *ApplicationConfig) GetUniqueID() string
GetUniqueID returns a unique id for this application config
func (*ApplicationConfig) HasEncryptedStorage ¶
func (a *ApplicationConfig) HasEncryptedStorage() bool
HasEncryptedStorage returns true if this configuration file is stored encrypt
func (*ApplicationConfig) Remove ¶
func (a *ApplicationConfig) Remove(toRemove *Account)
Remove will update the accounts to exclude the account to remove, if it does exist
func (*ApplicationConfig) Save ¶
func (a *ApplicationConfig) Save(ks KeySupplier) error
Save will save the application configuration
func (*ApplicationConfig) SetShouldSaveFileEncrypted ¶
func (a *ApplicationConfig) SetShouldSaveFileEncrypted(val bool) bool
SetShouldSaveFileEncrypted will change whether the file is saved in encrypted form or not It will immediately ask for a password if turning on encryption, and it will remove the old configuration file
func (*ApplicationConfig) UpdateToLatestVersion ¶
func (a *ApplicationConfig) UpdateToLatestVersion() bool
UpdateToLatestVersion will run through all accounts and update their configuration to latest version for cases where we have changed the configuration format. It returns true if any changes were made
func (*ApplicationConfig) WhenLoaded ¶
func (a *ApplicationConfig) WhenLoaded(f func(*ApplicationConfig))
WhenLoaded will ensure that the function f is not called until the configuration has been loaded
type ByAccountNameAlphabetic ¶
type ByAccountNameAlphabetic []*Account
ByAccountNameAlphabetic sorts the accounts based on their account names
func (ByAccountNameAlphabetic) Len ¶
func (s ByAccountNameAlphabetic) Len() int
func (ByAccountNameAlphabetic) Less ¶
func (s ByAccountNameAlphabetic) Less(i, j int) bool
func (ByAccountNameAlphabetic) Swap ¶
func (s ByAccountNameAlphabetic) Swap(i, j int)
type ByNaturalOrder ¶
type ByNaturalOrder []*Fingerprint
ByNaturalOrder sorts fingerprints according to the fingerprint
func (ByNaturalOrder) Len ¶
func (s ByNaturalOrder) Len() int
func (ByNaturalOrder) Less ¶
func (s ByNaturalOrder) Less(i, j int) bool
func (ByNaturalOrder) Swap ¶
func (s ByNaturalOrder) Swap(i, j int)
type CertificatePin ¶
type CertificatePin struct { Subject string Issuer string Fingerprint []byte FingerprintType string }
CertificatePin represents a known certificate hash to accept as a given
func (*CertificatePin) MarshalJSON ¶
func (v *CertificatePin) MarshalJSON() ([]byte, error)
MarshalJSON is used to create a JSON representation of this certificate pin
func (*CertificatePin) Matches ¶
func (v *CertificatePin) Matches(cert *x509.Certificate) bool
Matches returns true if this pin matches the given certificate
func (*CertificatePin) UnmarshalJSON ¶
func (v *CertificatePin) UnmarshalJSON(data []byte) error
UnmarshalJSON is used to parse the JSON representation of a certificate pin
type CertificatePinForSerialization ¶
type CertificatePinForSerialization struct { Subject string `json:",omitempty"` Issuer string `json:",omitempty"` FingerprintHex string FingerprintType string }
CertificatePinForSerialization represents a certificate pin in its serialized form
type CertificatePinsByNaturalOrder ¶
type CertificatePinsByNaturalOrder []*CertificatePin
CertificatePinsByNaturalOrder sorts certificate pins by the fingerprints
func (CertificatePinsByNaturalOrder) Len ¶
func (s CertificatePinsByNaturalOrder) Len() int
func (CertificatePinsByNaturalOrder) Less ¶
func (s CertificatePinsByNaturalOrder) Less(i, j int) bool
func (CertificatePinsByNaturalOrder) Swap ¶
func (s CertificatePinsByNaturalOrder) Swap(i, j int)
type ConnectionPolicy ¶
type ConnectionPolicy struct { // Logger logs connection information. Logger io.Writer // XMPPLogger logs XMPP messages XMPPLogger io.Writer DialerFactory interfaces.DialerFactory // contains filtered or unexported fields }
ConnectionPolicy represents a policy to connect to XMPP servers
func (*ConnectionPolicy) Connect ¶
func (p *ConnectionPolicy) Connect(password string, conf *Account, verifier ourtls.Verifier) (interfaces.Conn, error)
Connect to the server and authenticates with the password
func (*ConnectionPolicy) RegisterAccount ¶
func (p *ConnectionPolicy) RegisterAccount(createCallback data.FormCallback, conf *Account, verifier ourtls.Verifier) (interfaces.Conn, error)
RegisterAccount register the account on the XMPP server.
type DisplayConfig ¶
DisplayConfig contains display parameters
type EncryptionParameters ¶
type EncryptionParameters struct { Nonce string Salt string N int R int P int // contains filtered or unexported fields }
EncryptionParameters contains the parameters used for scrypting the password and encrypting the configuration file
type EncryptionSettings ¶
type EncryptionSettings string
EncryptionSettings configures the encryption setting for this peer
type Fingerprint ¶
Fingerprint represents a known fingerprint for a specific peer
func (*Fingerprint) MarshalJSON ¶
func (k *Fingerprint) MarshalJSON() ([]byte, error)
MarshalJSON is used to create a JSON representation of this fingerprint
func (*Fingerprint) UnmarshalJSON ¶
func (k *Fingerprint) UnmarshalJSON(data []byte) error
UnmarshalJSON is used to parse the JSON representation of a fingerprint
type FingerprintForSerialization ¶
FingerprintForSerialization represents a fingerprint in its serialized form
type KeySupplier ¶
type KeySupplier interface { GenerateKey(params EncryptionParameters) ([]byte, []byte, bool) Invalidate() LastAttemptFailed() }
KeySupplier is a function that can be used to get key data from a user
func CachingKeySupplier ¶
func CachingKeySupplier(getKeys func(params EncryptionParameters, lastAttemptFailed bool) ([]byte, []byte, bool)) KeySupplier
CachingKeySupplier is a key supplier that only asks the user for a password if it doesn't already have the key material
func FunctionKeySupplier ¶
func FunctionKeySupplier(getKeys func(params EncryptionParameters, lastAttemptFailed bool) ([]byte, []byte, bool)) KeySupplier
FunctionKeySupplier is a key supplier that wraps a function to ask for the password
type KnownFingerprint ¶
KnownFingerprint represents one fingerprint
func (KnownFingerprint) MarshalJSON ¶
func (k KnownFingerprint) MarshalJSON() ([]byte, error)
MarshalJSON is used to create a JSON representation of this known fingerprint
func (*KnownFingerprint) UnmarshalJSON ¶
func (k *KnownFingerprint) UnmarshalJSON(data []byte) error
UnmarshalJSON is used to parse the JSON representation of a known fingerprint
type LegacyByNaturalOrder ¶
type LegacyByNaturalOrder []*KnownFingerprint
LegacyByNaturalOrder sorts fingerprints according to first the user ID and then the fingerprint
func (LegacyByNaturalOrder) Len ¶
func (s LegacyByNaturalOrder) Len() int
func (LegacyByNaturalOrder) Less ¶
func (s LegacyByNaturalOrder) Less(i, j int) bool
func (LegacyByNaturalOrder) Swap ¶
func (s LegacyByNaturalOrder) Swap(i, j int)
type Peer ¶
type Peer struct { UserID string Nickname string EncryptionSettings EncryptionSettings `json:",omitempty"` Groups []string `json:",omitempty"` Fingerprints []*Fingerprint }
Peer represents one peer
func (*Peer) EnsureHasFingerprint ¶
func (p *Peer) EnsureHasFingerprint(fpr []byte) *Fingerprint
EnsureHasFingerprint ensures that the peer has the given fingerprint and returns the Fingerprint instance
func (*Peer) HasTrustedFingerprint ¶
HasTrustedFingerprint returns true if the peer has the given fingerprint and it is trusted