Documentation ¶
Index ¶
- Constants
- Variables
- func DecryptRc4(key string, data string) (string, error)
- func GetLoginDigestDigest(type_ string, domain string, username string, password string, nonce string, ...) string
- func GetRandomHexString(n int) string
- func Hex2bin(inputstring string) []int
- type App
- type Authenticate
- type Authorize
- type CallbackHandler
- type CallbackHandlerRegister
- type CallbackHandlerRegisterItem
- type CheckBuildResult
- type Config
- func (myappconfig *Config) DeleteSessionKeys() error
- func (myappconfig *Config) GetSessionKeys() (string, string, error)
- func (config *Config) Printf(format string, a ...interface{})
- func (config *Config) Println(v ...any)
- func (myappconfig *Config) SaveSessionKeys(usr, pwd string) error
- func (config *Config) StartSession(wg *sync.WaitGroup)
- type Login
- type LoginInfo
- type LoginInfoResult
- type LoginResult
- type Message
- type MessageHandler
- type MessageHandlerRegister
- type MyAppUserInfo
- type MyAppsConnection
- type Redirect
- type SessionAdded
- type SubscribeRegister
- type UpdateAppsInfo
- type UpdateOwnPresence
- type UpdateRegister
Constants ¶
View Source
const LoginResultAuthenticationFailed = 2 // {"mt":"LoginResult","error":2,"errorText":"Authentication failed"}
View Source
const LoginResultInvalidParameters = 1 // {"mt":"LoginResult","error":1,"errorText":"Invalid parameters"}
View Source
const LoginResultSessionExpired = 5 // {"mt":"LoginResult","error":5,"errorText":"Session expired"}
Variables ¶
View Source
var ReconnectTimeout = time.Second * 2
Functions ¶
func GetLoginDigestDigest ¶
func GetRandomHexString ¶
Types ¶
type Authenticate ¶
type CallbackHandler ¶
type CallbackHandler interface {
HandleCallbackMessage(*MyAppsConnection, []byte) error // the function that gets called when a messages received that matches the src
}
the interface all src handlers must implement
type CallbackHandlerRegister ¶
type CallbackHandlerRegister struct {
Handler map[string]CallbackHandlerRegisterItem
}
func NewCallbackHandlerRegister ¶
func NewCallbackHandlerRegister() *CallbackHandlerRegister
func (*CallbackHandlerRegister) Add ¶
func (cbr *CallbackHandlerRegister) Add(src string, numcallbacks int, handler CallbackHandler) error
func (*CallbackHandlerRegister) HandleMessage ¶
func (cbr *CallbackHandlerRegister) HandleMessage(myAppsConnection *MyAppsConnection, src string, message []byte) error
func (*CallbackHandlerRegister) Remove ¶
func (cbr *CallbackHandlerRegister) Remove(src string) error
type CallbackHandlerRegisterItem ¶
type CallbackHandlerRegisterItem struct { NumCallbacks int ReceivedCallbacks int Handler CallbackHandler }
type CheckBuildResult ¶
type Config ¶
type Config struct { Host string `yaml:"host"` // IP or Hostname to initialy connect to. could be a DNS name of the pbx like 'pbx.company.com' or a IP address with a Port '192.168.33.11:433' InsecureSkipVerify bool `yaml:"insecureskipverify"` // disabled the check for valid SSL/TLS certificate on the outgoing websocket connection Username string `yaml:"username"` // Username of the pbx Password string `yaml:"password"` // Password to the Username SessionFilePath string `yaml:"sessionfilepath"` // Filename to a local JSON file to store the session. Will be created if it not exists SecretKey []byte `yaml:"-"` // the key to encrypt local files UserAgent string `yaml:"useragent"` // the User Agnent shown in the list of current sessions in the user profile Handler MessageHandlerRegister // list of message handler on the session RedirectHost string // is set, when the user is located not in the master and should open a connection to the secondary pbx Debug bool `yaml:"debug"` // set to true to print log messages of the connection }
the Values for one Account
func (*Config) DeleteSessionKeys ¶
Deletes the JSON file with stored sessions
func (*Config) GetSessionKeys ¶
loads session keys from file
func (*Config) SaveSessionKeys ¶
writes session keys to file
func (*Config) StartSession ¶
type LoginInfoResult ¶
type LoginInfoResult struct { Mt string `json:"mt"` Error int `json:"error"` ErrorText string `json:"errorText"` User struct { Digest bool `json:"digest"` Ntlm bool `json:"ntlm"` OAuth2 bool `json:"oauth2"` OAuth2Name string `json:"oauth2Name"` } `json:"user"` Session struct { Digest bool `json:"digest"` } `json:"session"` }
type LoginResult ¶
type LoginResult struct { Mt string `json:"mt"` Info struct { User MyAppUserInfo `json:"user"` Account map[string]interface{} `json:"account"` Settings map[string]interface{} `json:"settings"` Session struct { Usr string Pwd string } `json:"session"` AltHttp string `json:"altHttp"` Alt string `json:"alt"` } `json:"info"` Digest string `json:"digest"` Error int `json:"error"` ErrorText string `json:"errorText"` }
type MessageHandler ¶
type MessageHandler interface { GetMt() string // the MessageHandlerRegister matches this string against the incoming message MT HandleMessage(*MyAppsConnection, []byte) error }
the interface all message handlers must implement
type MessageHandlerRegister ¶
type MessageHandlerRegister struct {
Handler []MessageHandler
}
func (*MessageHandlerRegister) AddHandler ¶
func (hr *MessageHandlerRegister) AddHandler(handler MessageHandler) error
func (*MessageHandlerRegister) HandleMessage ¶
func (hr *MessageHandlerRegister) HandleMessage(myAppsConnection *MyAppsConnection, mt string, message []byte) error
type MyAppUserInfo ¶
type MyAppUserInfo struct { Domain string `json:"domain"` Sip string `json:"sip"` Guid string `json:"guid"` Dn string `json:"dn"` Num string `json:"num"` Email string `json:"email"` Prefix struct { Intl string `json:"intl"` Ntl string `json:"ntl"` Subs string `json:"subs"` Area string `json:"area"` Country string `json:"country"` } `json:"prefix"` }
type MyAppsConnection ¶
type MyAppsConnection struct { Context context.Context Conn *websocket.Conn Config *Config Nonce string LoggedIn bool // indicates if a user is logged in User *MyAppUserInfo // the info object of the logged in user Apps map[string]*App // keeps a list of apps in the account ["devices", "contacts", ...]. CallbackHandlerRegister *CallbackHandlerRegister // hold a list of callback handler that are registered for a message with src attribute }
func NewMyAppsConnection ¶
func (*MyAppsConnection) OnUserLoggedIn ¶
func (myappsConnection *MyAppsConnection) OnUserLoggedIn(user *MyAppUserInfo)
func (*MyAppsConnection) SendWithResult ¶
func (myappsConnection *MyAppsConnection) SendWithResult(message []byte, src string, num int, handler CallbackHandler) error
type SessionAdded ¶
type SubscribeRegister ¶
type SubscribeRegister struct {
MT string `json:"mt"`
}
type UpdateAppsInfo ¶
type UpdateOwnPresence ¶
Click to show internal directories.
Click to hide internal directories.