Skip to content

Commit

Permalink
MFW-4232: Added support for any type in captive portal conditions (#345)
Browse files Browse the repository at this point in the history
version: bug
  • Loading branch information
Utkarsh51 authored Jan 10, 2024
1 parent f1936f7 commit 927cd70
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 621 deletions.
39 changes: 0 additions & 39 deletions protobuffersrc/Captiveportal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,6 @@ syntax = "proto3";
package captiveportal;
option go_package = "github.com/untangle/golang-shared/structs/protocolbuffers/CaptivePortal";

// Captive portal condition
message CpRuleCondition {
string Op = 1 [json_name = "op"];
string Type = 2 [json_name = "type"];
string Value = 3 [json_name = "value"];
}

// Captive portal action
message CpRulesAction {
string Type = 1 [json_name = "type"];
}

// Captive portal rule
message CpRules {
string RuleId = 1 [json_name = "rule_id"];
bool Enabled = 2 [json_name = "enabled"];
string Description = 3 [json_name = "description"];
repeated CpRuleCondition Conditions = 4 [json_name = "conditions"];
CpRulesAction Action = 5 [json_name = "action"];
}

message ImageDetails {
string imageName = 2 [json_name = "imageName"];
}

message CpSettingType {
bool Enabled = 1 [json_name = "enabled"];
int32 TimeoutValue = 2 [json_name = "timeoutValue"];
string TimeoutPeriod = 3 [json_name = "timeoutPeriod"];
string AcceptText = 4 [json_name = "acceptText"];
string AcceptButtonText = 5 [json_name = "acceptButtonText"];
string MessageHeading = 6 [json_name = "messageHeading"];
string MessageText = 7 [json_name = "messageText"];
string WelcomeText = 8 [json_name = "welcomeText"];
string PageTitle = 9 [json_name = "pageTitle"];
ImageDetails logo = 10 [json_name = "logo"];
repeated CpRules Rules = 11 [json_name = "rules"];
}

service CaptivePortalGrpcService {
rpc getCaptivePortalUser (UserGetRequest) returns (UserGetResponse) {}
rpc setCaptivePortalUser (UserSetRequest) returns (UserSetResponse) {}
Expand Down
126 changes: 126 additions & 0 deletions services/captiveportal/captiveportal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package captiveportal

// Captive portal condition
type CpRuleCondition struct {
Op string `json:"Op,omitempty"`
Type string `json:"Type,omitempty"`
Value any `json:"Value,omitempty"`
}

// Captive portal action

type CpRulesAction struct {
Type string `json:"Type,omitempty"`
}

//Captive portal rules

type CpRules struct {
RuleId string `json:"RuleId,omitempty"`
Enabled bool `json:"Enabled,omitempty"`
Description string `json:"Description,omitempty"`
Conditions []*CpRuleCondition `json:"Conditions,omitempty"`
Action *CpRulesAction `json:"Action,omitempty"`
}

type ImageDetails struct {
ImageName string `json:"imageName,omitempty"`
}

func (x *ImageDetails) GetImageName() string {
if x != nil {
return x.ImageName
}
return ""
}

type CpSettingType struct {
Enabled bool `json:"Enabled,omitempty"`
TimeoutValue int32 `json:"TimeoutValue,omitempty"`
TimeoutPeriod string `json:"TimeoutPeriod,omitempty"`
AcceptText string `json:"AcceptText,omitempty"`
AcceptButtonText string `json:"AcceptButtonText,omitempty"`
MessageHeading string `json:"MessageHeading,omitempty"`
MessageText string `json:"MessageText,omitempty"`
WelcomeText string `json:"WelcomeText,omitempty"`
PageTitle string `json:"PageTitle,omitempty"`
Logo *ImageDetails `json:"logo,omitempty"`
Rules []*CpRules `json:"Rules,omitempty"`
}

func (x *CpSettingType) GetEnabled() bool {
if x != nil {
return x.Enabled
}
return false
}

func (x *CpSettingType) GetTimeoutValue() int32 {
if x != nil {
return x.TimeoutValue
}
return 0
}

func (x *CpSettingType) GetTimeoutPeriod() string {
if x != nil {
return x.TimeoutPeriod
}
return ""
}

func (x *CpSettingType) GetAcceptText() string {
if x != nil {
return x.AcceptText
}
return ""
}

func (x *CpSettingType) GetAcceptButtonText() string {
if x != nil {
return x.AcceptButtonText
}
return ""
}

func (x *CpSettingType) GetMessageHeading() string {
if x != nil {
return x.MessageHeading
}
return ""
}

func (x *CpSettingType) GetMessageText() string {
if x != nil {
return x.MessageText
}
return ""
}

func (x *CpSettingType) GetWelcomeText() string {
if x != nil {
return x.WelcomeText
}
return ""
}

func (x *CpSettingType) GetPageTitle() string {
if x != nil {
return x.PageTitle
}
return ""
}

func (x *CpSettingType) GetLogo() *ImageDetails {
if x != nil {
return x.Logo
}
return nil
}

func (x *CpSettingType) GetRules() []*CpRules {
if x != nil {
return x.Rules
}
return nil
}
26 changes: 18 additions & 8 deletions structs/protocolbuffers/ActiveSessions/ActiveSessions.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion structs/protocolbuffers/Alerts/Alerts.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 927cd70

Please sign in to comment.