feature: sosreport in the browser outputs text/plain
This commit is contained in:
parent
83beab4c92
commit
77ec2fea63
|
|
@ -3,6 +3,7 @@ syntax = "proto3";
|
||||||
option go_package = "gen/grpc";
|
option go_package = "gen/grpc";
|
||||||
|
|
||||||
import "google/api/annotations.proto";
|
import "google/api/annotations.proto";
|
||||||
|
import "google/api/httpbody.proto";
|
||||||
|
|
||||||
message Action {
|
message Action {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
|
|
@ -237,7 +238,7 @@ service OliveTinApiService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
rpc SosReport(SosReportRequest) returns (SosReportResponse) {
|
rpc SosReport(SosReportRequest) returns (google.api.HttpBody) {
|
||||||
option (google.api.http) = {
|
option (google.api.http) = {
|
||||||
get: "/api/sosreport"
|
get: "/api/sosreport"
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
pb "github.com/OliveTin/OliveTin/gen/grpc"
|
pb "github.com/OliveTin/OliveTin/gen/grpc"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"google.golang.org/genproto/googleapis/api/httpbody"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -251,19 +252,20 @@ func (api *oliveTinAPI) WhoAmI(ctx ctx.Context, req *pb.WhoAmIRequest) (*pb.WhoA
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *oliveTinAPI) SosReport(ctx ctx.Context, req *pb.SosReportRequest) (*pb.SosReportResponse, error) {
|
func (api *oliveTinAPI) SosReport(ctx ctx.Context, req *pb.SosReportRequest) (*httpbody.HttpBody, error) {
|
||||||
sos := installationinfo.GetSosReport()
|
sos := installationinfo.GetSosReport()
|
||||||
|
|
||||||
res := &pb.SosReportResponse{}
|
if !cfg.InsecureAllowDumpSos {
|
||||||
|
|
||||||
if cfg.InsecureAllowDumpSos {
|
|
||||||
res.Alert = sos
|
|
||||||
} else {
|
|
||||||
res.Alert = "Your SOS Report has been logged to OliveTin logs."
|
|
||||||
log.Info(sos)
|
log.Info(sos)
|
||||||
|
sos = "Your SOS Report has been logged to OliveTin logs.\n\nIf you are in a safe network, you can temporarily set `insecureAllowDumpSos: true` in your config.yaml, restart OliveTin, and refresh this page - it will put the output directly in the browser."
|
||||||
}
|
}
|
||||||
|
|
||||||
return res, nil
|
ret := &httpbody.HttpBody{
|
||||||
|
ContentType: "text/plain",
|
||||||
|
Data: []byte(sos),
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *oliveTinAPI) DumpVars(ctx ctx.Context, req *pb.DumpVarsRequest) (*pb.DumpVarsResponse, error) {
|
func (api *oliveTinAPI) DumpVars(ctx ctx.Context, req *pb.DumpVarsRequest) (*pb.DumpVarsResponse, error) {
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,32 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
config "github.com/OliveTin/OliveTin/internal/config"
|
config "github.com/OliveTin/OliveTin/internal/config"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Config *config.Config
|
var Config *config.Config
|
||||||
|
|
||||||
type sosReportConfig struct {
|
type sosReportConfig struct {
|
||||||
CountOfActions int
|
CountOfActions int
|
||||||
LogLevel string
|
CountOfDashboards int
|
||||||
|
LogLevel string
|
||||||
|
ListenAddressSingleHTTPFrontend string
|
||||||
|
ListenAddressWebUI string
|
||||||
|
ListenAddressRestActions string
|
||||||
|
ListenAddressGrpcActions string
|
||||||
|
Timezone string
|
||||||
}
|
}
|
||||||
|
|
||||||
func configToSosreport(cfg *config.Config) *sosReportConfig {
|
func configToSosreport(cfg *config.Config) *sosReportConfig {
|
||||||
return &sosReportConfig{
|
return &sosReportConfig{
|
||||||
CountOfActions: len(cfg.Actions),
|
CountOfActions: len(cfg.Actions),
|
||||||
LogLevel: cfg.LogLevel,
|
CountOfDashboards: len(cfg.Dashboards),
|
||||||
|
LogLevel: cfg.LogLevel,
|
||||||
|
ListenAddressSingleHTTPFrontend: cfg.ListenAddressSingleHTTPFrontend,
|
||||||
|
ListenAddressWebUI: cfg.ListenAddressWebUI,
|
||||||
|
ListenAddressRestActions: cfg.ListenAddressRestActions,
|
||||||
|
ListenAddressGrpcActions: cfg.ListenAddressGrpcActions,
|
||||||
|
Timezone: time.Now().Location().String(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue