mirror of https://github.com/statping/statping
added http headers for outgoing requests, removed mobile notifier inputs, added Pushover notifier fields
parent
1044337ec6
commit
7be131d0cf
|
@ -12,7 +12,12 @@
|
|||
<div class="card-body">
|
||||
<p class="small text-muted" v-html="notifier.description"/>
|
||||
|
||||
<div v-for="(form, index) in notifier.form" v-bind:key="index" class="form-group">
|
||||
<div v-if="notifier.method==='mobile'" class="col-6 offset-3">
|
||||
<img :src="qrcode" class="img-thumbnail">
|
||||
<span class="text-muted small center">Scan this QR Code on the Statping Mobile App for quick setup</span>
|
||||
</div>
|
||||
|
||||
<div v-if="notifier.method!=='mobile'" v-for="(form, index) in notifier.form" v-bind:key="index" class="form-group">
|
||||
<label class="text-capitalize">{{form.title}}</label>
|
||||
<input v-if="formVisible(['text', 'number', 'password', 'email'], form)" v-model="notifier[form.field.toLowerCase()]" :type="form.type" class="form-control" :placeholder="form.placeholder" >
|
||||
|
||||
|
@ -171,9 +176,15 @@ export default {
|
|||
beautifySettings: { indent_size: 2, space_in_empty_paren: true },
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
},
|
||||
computed: {
|
||||
core() {
|
||||
return this.$store.getters.core
|
||||
},
|
||||
qrcode() {
|
||||
const u = `statping://setup?domain=${this.core.domain}&api=${this.core.api_secret}`
|
||||
return "https://chart.googleapis.com/chart?chs=500x500&cht=qr&chl=" + encodeURIComponent(u)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formVisible(want, form) {
|
||||
return !!want.includes(form.type);
|
||||
|
|
|
@ -68,12 +68,33 @@ var Pushover = &pushover{¬ifications.Notification{
|
|||
}},
|
||||
}
|
||||
|
||||
func priority(val string) string {
|
||||
switch strings.ToLower(val) {
|
||||
case "lowest":
|
||||
return "-2"
|
||||
case "low":
|
||||
return "-1"
|
||||
case "normal":
|
||||
return "0"
|
||||
case "high":
|
||||
return "1"
|
||||
case "emergency":
|
||||
return "2"
|
||||
default:
|
||||
return "1"
|
||||
}
|
||||
}
|
||||
|
||||
// Send will send a HTTP Post to the Pushover API. It accepts type: string
|
||||
func (t *pushover) sendMessage(message string) (string, error) {
|
||||
v := url.Values{}
|
||||
v.Set("token", t.ApiSecret)
|
||||
v.Set("user", t.ApiKey)
|
||||
v.Set("message", message)
|
||||
v.Set("priority", priority(t.Var1))
|
||||
if t.Var2 != "" {
|
||||
v.Set("sound", t.Var2)
|
||||
}
|
||||
rb := strings.NewReader(v.Encode())
|
||||
|
||||
content, _, err := utils.HttpRequest(pushoverUrl, "POST", "application/x-www-form-urlencoded", nil, rb, time.Duration(10*time.Second), true, nil)
|
||||
|
|
|
@ -31,9 +31,9 @@ var Webhook = &webhooker{¬ifications.Notification{
|
|||
Author: "Hunter Long",
|
||||
AuthorUrl: "https://github.com/hunterlong",
|
||||
Icon: "fas fa-code-branch",
|
||||
Delay: time.Duration(1 * time.Second),
|
||||
SuccessData: `{"id": {{.Service.Id}}, "online": true}`,
|
||||
FailureData: `{"id": {{.Service.Id}}, "online": false}`,
|
||||
Delay: time.Duration(3 * time.Second),
|
||||
SuccessData: `{"id": "{{.Service.Id}}", "online": true}`,
|
||||
FailureData: `{"id": "{{.Service.Id}}", "online": false}`,
|
||||
DataType: "json",
|
||||
Limits: 180,
|
||||
Form: []notifications.NotificationForm{{
|
||||
|
@ -83,8 +83,7 @@ func (w *webhooker) sendHttpWebhook(body string) (*http.Response, error) {
|
|||
utils.Log.Infoln(fmt.Sprintf("sending body: '%v' to %v as a %v request", body, w.Host, w.Var1))
|
||||
client := new(http.Client)
|
||||
client.Timeout = time.Duration(10 * time.Second)
|
||||
var buf *bytes.Buffer
|
||||
buf = bytes.NewBuffer(nil)
|
||||
buf := bytes.NewBuffer(nil)
|
||||
if w.Var2 != "" {
|
||||
buf = bytes.NewBuffer([]byte(body))
|
||||
}
|
||||
|
@ -103,6 +102,7 @@ func (w *webhooker) sendHttpWebhook(body string) (*http.Response, error) {
|
|||
req.Header.Add("Content-Type", w.ApiKey)
|
||||
}
|
||||
req.Header.Set("User-Agent", "Statping")
|
||||
req.Header.Set("Statping-Version", utils.Version)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -24,7 +24,7 @@ func InitEnvs() {
|
|||
Log.Errorln(err)
|
||||
defaultDir = "."
|
||||
}
|
||||
Params.Set("VERSION", version)
|
||||
Params.Set("VERSION", Version)
|
||||
Params.SetDefault("DISABLE_HTTP", false)
|
||||
Params.SetDefault("STATPING_DIR", defaultDir)
|
||||
Params.SetDefault("GO_ENV", "production")
|
||||
|
|
|
@ -21,7 +21,7 @@ var (
|
|||
LastLines []*logRow
|
||||
LockLines sync.Mutex
|
||||
VerboseMode int
|
||||
version string
|
||||
Version string
|
||||
allowReports bool
|
||||
)
|
||||
|
||||
|
@ -36,7 +36,7 @@ func SentryInit(v *string, allow bool) {
|
|||
if *v == "" {
|
||||
*v = "development"
|
||||
}
|
||||
version = *v
|
||||
Version = *v
|
||||
}
|
||||
goEnv := Params.GetString("GO_ENV")
|
||||
allowReports := Params.GetBool("ALLOW_REPORTS")
|
||||
|
@ -44,7 +44,7 @@ func SentryInit(v *string, allow bool) {
|
|||
if err := sentry.Init(sentry.ClientOptions{
|
||||
Dsn: errorReporter,
|
||||
Environment: goEnv,
|
||||
Release: version,
|
||||
Release: Version,
|
||||
AttachStacktrace: true,
|
||||
}); err != nil {
|
||||
Log.Errorln(err)
|
||||
|
@ -63,7 +63,7 @@ func SentryErr(err error) {
|
|||
func SentryLogEntry(entry *Logger.Entry) {
|
||||
e := sentry.NewEvent()
|
||||
e.Message = entry.Message
|
||||
e.Release = version
|
||||
e.Release = Version
|
||||
e.Contexts = entry.Data
|
||||
sentry.CaptureEvent(e)
|
||||
}
|
||||
|
|
|
@ -217,6 +217,10 @@ func HttpRequest(url, method string, content interface{}, headers []string, body
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
req.Header.Set("User-Agent", "Statping")
|
||||
req.Header.Set("Statping-Version", Version)
|
||||
|
||||
var resp *http.Response
|
||||
|
||||
dialer := &net.Dialer{
|
||||
|
|
Loading…
Reference in New Issue