Documentation ¶
Index ¶
- func CheckPasswordHash(password, hash string) bool
- func DeviceDownlinkHandler(w http.ResponseWriter, r *http.Request, email string, devTable string)
- func DeviceInfoHandler(w http.ResponseWriter, r *http.Request, email string, devTable string)
- func DeviceLoginHandler(w http.ResponseWriter, r *http.Request)
- func DeviceLogsHandler(w http.ResponseWriter, r *http.Request, email string, devTable string)
- func DeviceManagerHandler(w http.ResponseWriter, r *http.Request, email string, tableName string)
- func DeviceSSHStatusHandler(w http.ResponseWriter, r *http.Request, email string, devTable string)
- func DeviceTunnelRequestHandler(w http.ResponseWriter, r *http.Request, devClaims *DevClaims)
- func DeviceUplinkHandler(w http.ResponseWriter, r *http.Request, devClaims *DevClaims)
- func FrontPageHandler(w http.ResponseWriter, r *http.Request, email string, tableName string)
- func HashPassword(password string) (string, error)
- func HeartBeatHandler(w http.ResponseWriter, r *http.Request, devClaims *DevClaims)
- func LogSession(w http.ResponseWriter, usr *models.User)
- func LoginHandler(w http.ResponseWriter, r *http.Request)
- func LogoutHandler(w http.ResponseWriter, r *http.Request)
- func ProvideApiHandler(fn func(http.ResponseWriter, *http.Request, *DevClaims)) http.HandlerFunc
- func ProvideWebHandler(fn func(http.ResponseWriter, *http.Request, string, string)) http.HandlerFunc
- func RegisterHandler(w http.ResponseWriter, r *http.Request)
- func SSHRequestHandler(w http.ResponseWriter, r *http.Request, email string, devTable string)
- func Start()
- func Testprovidehandler(fn func(http.ResponseWriter, *http.Request, string, string)) http.HandlerFunc
- type DevClaims
- type DevEnv
- type DownlinkReq
- type HeartBeatReq
- type JWToken
- type SSHReq
- type UplinkReq
- type UsrEnv
- type UsrListDevsReq
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
Check BCrypt hash by matching
func DeviceDownlinkHandler ¶
Function users use to send a downlink message to the device
func DeviceInfoHandler ¶
Device preview page showing tunnel status and latest logs (up to 10)
func DeviceLoginHandler ¶
func DeviceLoginHandler(w http.ResponseWriter, r *http.Request)
Provides JWT token when presented with valid device claims. Checks device name, user's email, and devices password to return back a JWT TODO: Make this agnostic to the user TODO: Add token validity period
func DeviceLogsHandler ¶
Device Logs
func DeviceManagerHandler ¶
Function to manage devices. Handles device registration and deletion
func DeviceSSHStatusHandler ¶
Get SSHStatus, i.e, if user has scheduled a tunnel to be made, if device has launched that tunnel, or if it is stopped
func DeviceTunnelRequestHandler ¶
func DeviceTunnelRequestHandler(w http.ResponseWriter, r *http.Request, devClaims *DevClaims)
func DeviceUplinkHandler ¶
func DeviceUplinkHandler(w http.ResponseWriter, r *http.Request, devClaims *DevClaims)
func FrontPageHandler ¶
Render template for front page displaying all the devices registered to a particular user TODO: Add a more qualified user context here instead of tableName
func HashPassword ¶
Simple BCrypt hash to store user and device passwords
func HeartBeatHandler ¶
func HeartBeatHandler(w http.ResponseWriter, r *http.Request, devClaims *DevClaims)
func LogSession ¶
func LogSession(w http.ResponseWriter, usr *models.User)
Log a users web session via cookies
func LoginHandler ¶
func LoginHandler(w http.ResponseWriter, r *http.Request)
func LogoutHandler ¶
func LogoutHandler(w http.ResponseWriter, r *http.Request)
func ProvideApiHandler ¶
func ProvideApiHandler(fn func(http.ResponseWriter, *http.Request, *DevClaims)) http.HandlerFunc
Closure to provide requested API for devices. Checks for JWT token claims and services the requested api if token is valid. In addition, provides the devices claim to the underlying API
func ProvideWebHandler ¶
func ProvideWebHandler(fn func(http.ResponseWriter, *http.Request, string, string)) http.HandlerFunc
Closure to provide web content. Checks for cookies and returns to the requester the requested page if user's session token is present in usrAuthCache. Also provides to the API function the users email and the device table name TODO: No need of device table. It can be constructed from user email
func RegisterHandler ¶
func RegisterHandler(w http.ResponseWriter, r *http.Request)
func SSHRequestHandler ¶
Functions users use to make an SSH request to schedule or stop
func Testprovidehandler ¶
func Testprovidehandler(fn func(http.ResponseWriter, *http.Request, string, string)) http.HandlerFunc
A test closure to wrap web functions for testing. A user "a" with email "a@a.com" password "a" is used
Types ¶
type DevClaims ¶
type DevClaims struct { DevName string `json:"devName"` Email string `json:"email"` Pwd string `json:"pwd"` }
Claims structure for devices claiming a JWT
type DevEnv ¶
type DevEnv struct {
// contains filtered or unexported fields
}
Database environment for "device" related database accesses
type DownlinkReq ¶
type DownlinkReq struct { Port string `json:"port"` DownlinkMsg string `json:"downlinkMsg"` RespType string `json:"reqType"` // schedule, stop or downlink }
Structure users use to give either of the following -
send a downlink message OR ssh schedule/stop request
type HeartBeatReq ¶
type HeartBeatReq struct {
PingTime int `json:"pingTime"`
}
Structure devices use register that they are alive
type SSHReq ¶
type SSHReq struct { TunnelStatus string `json:"tunnelStatus"` // schedule, launch, stop Port string `json:"port"` RemoccPort string `json:"remoccPort"` Uname string `json:"uname"` DevName string `json:"devName"` DevUName string `json:"devUName"` RemoccHost string `json:"remoccHost"` }
Structure users use to get SSH tunnel Status Structure devices use to make an SSH launch request
type UplinkReq ¶
type UplinkReq struct {
UplinkMsg string `json:"uplinkMsg"`
}
Structure devices use to send a message to server
type UsrListDevsReq ¶
Structure to list user's devices