Skip to content

Commit

Permalink
added permission checking for httpapi voicetargetsetting
Browse files Browse the repository at this point in the history
  • Loading branch information
talkkonnect committed Sep 5, 2021
1 parent e63c450 commit e4fdd1a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
18 changes: 13 additions & 5 deletions httpapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,22 @@ func (b *Talkkonnect) httpAPI(w http.ResponseWriter, r *http.Request) {
b.cmdDumpXMLConfig()
fmt.Fprintf(w, "API Print XML Config Processed Successfully\n")
} else {
fmt.Fprintf(w, "API Print XML Congfig Denied\n")
fmt.Fprintf(w, "API Print XML Config Denied\n")
}
case "playrepeatertone":
b.cmdPlayRepeaterTone()
fmt.Fprintf(w, "API Play Repeater Tone Processed Successfully\n")
if APIPlayRepeaterTone {
b.cmdPlayRepeaterTone()
fmt.Fprintf(w, "API Play Repeater Tone Processed Successfully\n")
} else {
fmt.Fprintf(w, "API Play Repeater Tone Denied\n")
}
case "setvoicetarget":
fmt.Fprintf(w, "API Set Voice Target to ID %v Processed Successfully\n", ID)
b.cmdSendVoiceTargets(uint32(ID))
if APISetVoiceTarget {
fmt.Fprintf(w, "API Set Voice Target to ID %v Processed Successfully\n", ID)
b.cmdSendVoiceTargets(uint32(ID))
} else {
fmt.Fprintf(w, "API Set Voice Target Denied\n")
}
default:
fmt.Fprintf(w, "API Command Not Defined\n")
}
Expand Down
10 changes: 9 additions & 1 deletion xmlparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (

//version and release date
const (
talkkonnectVersion string = "1.67.28"
talkkonnectVersion string = "1.67.29"
talkkonnectReleased string = "Sep 5 2021"
)

Expand Down Expand Up @@ -259,6 +259,8 @@ var (
APIPingServersEnabled bool
APIRepeatTxLoopTest bool
APIPrintXmlConfig bool
APIPlayRepeaterTone bool
APISetVoiceTarget bool
)

//print xml config sections for easy debugging, set any section to false to prevent printing to screen
Expand Down Expand Up @@ -725,6 +727,8 @@ type DocumentStruct struct {
PrintXmlConfig bool `xml:"printxmlconfig"`
SendEmail bool `xml:"sendemail"`
PingServers bool `xml:"pingservers"`
PlayRepeaterTone bool `xml:"playrepeatertone"`
SetVoiceTarget bool `xml:"setvoicetarget"`
} `xml:"api"`
PrintVariables struct {
PrintAccount bool `xml:"printaccount"`
Expand Down Expand Up @@ -1478,6 +1482,8 @@ func readxmlconfig(file string) error {
APIPingServersEnabled = Document.Global.Software.API.Enabled
APIRepeatTxLoopTest = Document.Global.Software.API.RepeatTxLoopTest
APIPrintXmlConfig = Document.Global.Software.API.PrintXmlConfig
APIPlayRepeaterTone = Document.Global.Software.API.PlayRepeaterTone
APISetVoiceTarget = Document.Global.Software.API.SetVoiceTarget

PrintAccount = Document.Global.Software.PrintVariables.PrintAccount
PrintLogging = Document.Global.Software.PrintVariables.PrintLogging
Expand Down Expand Up @@ -1890,6 +1896,8 @@ func printxmlconfig() {
log.Println("info: PingServersEnabled " + fmt.Sprintf("%t", APIPingServersEnabled))
log.Println("info: TxLoopTest " + fmt.Sprintf("%t", APIRepeatTxLoopTest))
log.Println("info: PrintXmlConfig " + fmt.Sprintf("%t", APIPrintXmlConfig))
log.Println("info: PlayRepeaterTone " + fmt.Sprintf("%t", APIPlayRepeaterTone))
log.Println("info: SetVoiceTarget " + fmt.Sprintf("%t", APISetVoiceTarget))
} else {
log.Println("info: ------------ HTTP API ----------------- SKIPPED ")
}
Expand Down

0 comments on commit e4fdd1a

Please sign in to comment.