apis

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INTERFACE      = "org.fedoraproject.FirewallD1"
	PATH           = "/org/fedoraproject/FirewallD1"
	DIRECT         = INTERFACE + ".direct"
	IPSET          = INTERFACE + ".ipset"
	POLICIES       = INTERFACE + ".policies"
	ZONE           = INTERFACE + ".zone"
	INTROSPECTABLE = "org.freedesktop.DBus.Introspectable"
	PROPERTIES     = "org.freedesktop.DBus.Properties"

	CONFIG_PATH               = PATH + "/config"
	CONFIG_INTERFACE          = INTERFACE + ".config"
	CONFIG_DIRECT_INTERFACE   = INTERFACE + ".config.direct"
	CONFIG_POLICIES_INTERFACE = INTERFACE + ".config.policies"

	ZONE_PATH      = CONFIG_PATH + "/zone"
	ZONE_INTERFACE = INTERFACE + ".config.zone"

	SERVICE_PATH      = PATH + "/config/service/i"
	SERVICE_INTERFACE = INTERFACE + ".config.service"

	IPSET_PATH      = PATH + "/config/ipset/i"
	IPSET_INTERFACE = INTERFACE + ".config.ipset"

	ICMP_PATH      = PATH + "/config/icmptype/i"
	ICMP_INTERFACE = INTERFACE + ".config.icmptype"

	// org.fedoraproject.FirewallD1
	INTERFACE_GETDEFAULTZONE     = INTERFACE + ".getDefaultZone"
	INTERFACE_SETDEFAULTZONE     = INTERFACE + ".setDefaultZone"
	INTERFACE_GETZONESETTINGS    = INTERFACE + ".getZoneSettings"
	INTERFACE_RELOAD             = INTERFACE + ".completeReload"
	INTERFACE_LISTSERVICES       = INTERFACE + ".listServices"
	INTERFACE_RUNTIMETOPERMANENT = INTERFACE + ".runtimeToPermanent"

	//config
	CONFIG_ADDSERVICE = CONFIG_INTERFACE + ".addService"

	// org.fedoraproject.FirewallD1.zone
	ZONE_ADDMASQUERADE     = ZONE + ".addMasquerade"
	ZONE_REMOVEMASQUERADE  = ZONE + ".removeMasquerade"
	ZONE_QUERYMASQUERADE   = ZONE + ".queryMasquerade"
	ZONE_ADDPORT           = ZONE + ".addPort"
	ZONE_REMOVEPORT        = ZONE + ".removePort"
	ZONE_ADDPROTOCOL       = ZONE + ".addProtocol"
	ZONE_ADDRICHRULE       = ZONE + ".addRichRule"
	ZONE_ADDSERVICE        = ZONE + ".addService"
	ZONE_GETSERVICES       = ZONE + ".getServices"
	ZONE_ADDSOURCE         = ZONE + ".addSource"
	ZONE_ADDINTERFACE      = ZONE + ".addInterface"
	ZONE_QUERYINTERFACE    = ZONE + ".queryInterface"
	ZONE_REMOVEINTERFACE   = ZONE + ".removeInterface"
	ZONE_REOMVERICHRULE    = ZONE + ".removeRichRule"
	ZONE_GETPORTS          = ZONE + ".getPorts"
	ZONE_ADDFORWARDPORT    = ZONE + ".addForwardPort"
	ZONE_GETFORWARDPORT    = ZONE + ".getForwardPorts"
	ZONE_REMOVEFORWARDPORT = ZONE + ".removeForwardPort"
	ZONE_QUERYFORWARDPORT  = ZONE + ".queryForwardPort"

	// get
	ZONE_GETZONES           = ZONE + ".getZones"
	ZONE_GETZONEOFINTERFACE = ZONE + ".getZoneOfInterface"
	ZONE_GETRICHRULES       = ZONE + ".getRichRules"
	ZONE_QUERYRICHRULE      = ZONE + ".queryRichRule"
	ZONE_QUERYSERVICE       = ZONE + ".queryService"
	ZONE_REMOVESERVICE      = ZONE + ".removeService"

	// org.fedoraproject.FirewallD1.config
	CONFIG_ADDZONE = CONFIG_INTERFACE + ".addZone"

	// org.fedoraproject.FirewallD1.config.zone
	CONFIG_ZONE                   = CONFIG_INTERFACE + ".zone"
	CONFIG_UPDATE                 = CONFIG_ZONE + ".update"
	CONFIG_ZONE_ADDRICHRULE       = CONFIG_ZONE + ".addRichRule"
	CONFIG_ZONE_REOMVERICHRULE    = CONFIG_ZONE + ".removeRichRule"
	CONFIG_ZONE_QUERYRICHRULE     = CONFIG_ZONE + ".queryRichRule"
	CONFIG_ZONE_ADDSERVICE        = CONFIG_ZONE + ".addService"
	CONFIG_ZONE_QUERYSERVICE      = CONFIG_ZONE + ".queryService"
	CONFIG_ZONE_REMOVESERVICE     = CONFIG_ZONE + ".removeService"
	CONFIG_ZONE_GETSERVICES       = CONFIG_ZONE + ".getServices"
	CONFIG_ZONE_ADDPORT           = CONFIG_ZONE + ".addPort"
	CONFIG_ZONE_GETPORTS          = CONFIG_ZONE + ".getPorts"
	CONFIG_ZONE_REMOVEPORT        = CONFIG_ZONE + ".removePort"
	CONFIG_ZONE_ADDMASQUERADE     = CONFIG_ZONE + ".addMasquerade"
	CONFIG_ZONE_REMOVEMASQUERADE  = CONFIG_ZONE + ".removeMasquerade"
	CONFIG_ZONE_QUERYMASQUERADE   = CONFIG_ZONE + ".queryMasquerade"
	CONFIG_ZONE_ADDINTERFACE      = CONFIG_ZONE + ".addInterface"
	CONFIG_ZONE_REMOVEINTERFACE   = CONFIG_ZONE + ".removeInterface"
	CONFIG_ZONE_ADDFORWARDPORT    = CONFIG_ZONE + ".addForwardPort"
	CONFIG_ZONE_REMOVEFORWARDPORT = CONFIG_ZONE + ".removeForwardPort"
	CONFIG_ZONE_QUERYFORWARDPORT  = CONFIG_ZONE + ".queryForwardPort"
	CONFIG_GETFORWARDPORT         = CONFIG_ZONE + ".getForwardPorts"
	CONFIG_REMOVEZONE             = CONFIG_ZONE + ".remove"
)

Variables

This section is empty.

Functions

func APIResponse

func APIResponse(ctx *gin.Context, err error, data interface{})

APIResponse ....

func BacthMissionFailedResponse

func BacthMissionFailedResponse(ctx *gin.Context, err ...error)

ConnectDbusService ....

func BacthMissionSuccessResponse

func BacthMissionSuccessResponse(ctx *gin.Context, err error)

ConnectDbusService ....

func ConnectDbusService

func ConnectDbusService(ctx *gin.Context, err error)

ConnectDbusService ....

func NotFount

func NotFount(ctx *gin.Context, err error, data interface{})

NotFountResponse ....

func SuccessResponse

func SuccessResponse(ctx *gin.Context, err error, data interface{})

SuccessResponse ....

Types

type Accept

type Accept struct {
	Flag  bool
	Limit Limit `form:"limit" json:"limit,omitempty"`
}

func (*Accept) IsEmpty

func (this *Accept) IsEmpty() bool

func (*Accept) ToString

func (this *Accept) ToString() string

type Audit

type Audit struct {
	Limit Limit `form:"limit" json:"limit,omitempty"`
}

func (*Audit) IsEmpty

func (this *Audit) IsEmpty() bool

func (*Audit) ToString

func (this *Audit) ToString() string

type BatchPortQuery

type BatchPortQuery struct {
	Delay uint32      `form:"delay,default=0" json:"delay,omitempty"`
	Ports []PortQuery `form:"ports" json:"ports"`
}

type BatchServiceQuery

type BatchServiceQuery struct {
	Delay    uint32         `form:"delay,default=0" json:"delay,omitempty"`
	Services []ServiceQuery `form:"services" json:"services,omitempty"`
}

type BatchSettingQuery

type BatchSettingQuery struct {
	Delay uint32   `form:"delay,default=0" json:"delay,omitempty"`
	Hosts []string `form:"hosts" json:"hosts,omitempty" binding:"required"`
}

type BatchZoneQuery

type BatchZoneQuery struct {
	Delay        uint32    `form:"delay,default=0" json:"delay,omitempty"`
	ActionObject []ZoneDst `form:"action_object" json:"action_object,omitempty" binding:"required"`
}

type Destination

type Destination struct {
	Address string `form:"address" json:"address,omitempty"`
	Invert  string `form:"invert" json:"invert,omitempty"`
}

func (*Destination) IsEmpty

func (this *Destination) IsEmpty() bool

func (*Destination) ToString

func (this *Destination) ToString() string

type Drop

type Drop struct {
	Flag  bool
	Limit Limit `form:"limit" json:"limit,omitempty"`
}

func (*Drop) IsEmpty

func (this *Drop) IsEmpty() bool

func (*Drop) ToString

func (this *Drop) ToString() string

type ForwardPort

type ForwardPort struct {
	Port     string `form:"port" json:"port,omitempty"`
	Protocol string `form:"protocol" json:"protocol,omitempty"`
	ToPort   string `form:"toport" json:"toport,omitempty"`
	ToAddr   string `form:"toaddr" json:"toaddr,omitempty"`
}

func SliceToStruct

func SliceToStruct(array interface{}) (ForwardPort, error)

func (*ForwardPort) IsEmpty

func (this *ForwardPort) IsEmpty() bool

func (*ForwardPort) ToString

func (this *ForwardPort) ToString() string

type ForwardQuery

type ForwardQuery struct {
	Ip      string       `form:"ip" json:"ip" binding:"required"`
	Zone    string       `form:"zone,default=public" json:"zone"`
	Timeout uint32       `form:"timeout,default=0" json:"timeout"`
	Forward *ForwardPort `form:"forward" json:"forward,omitempty" binding:"required"`
}

type IcmpBlock

type IcmpBlock struct {
	Name string `form:"name" json:"name,omitempty"`
}

func (*IcmpBlock) IsEmpty

func (this *IcmpBlock) IsEmpty() bool

func (*IcmpBlock) ToString

func (this *IcmpBlock) ToString() string

type IcmpType

type IcmpType struct {
	Name string `form:"name" json:"name,omitempty"`
}

func (*IcmpType) IsEmpty

func (this *IcmpType) IsEmpty() bool

func (*IcmpType) ToString

func (this *IcmpType) ToString() string

type Interface

type Interface struct {
	Name string `form:"source" json:"name,omitempty"`
}

type Limit

type Limit struct {
	Value string `form:"value" json:"value,omitempty"`
}

func (*Limit) IsEmpty

func (this *Limit) IsEmpty() bool

type Log

type Log struct {
	Prefix string `form:"prefix" json:"prefix,omitempty"`
	Level  string `form:"level" json:"level,omitempty"`
	Limit  Limit  `form:"limit" json:"limit,omitempty"`
}

func (*Log) IsEmpty

func (this *Log) IsEmpty() bool

func (*Log) ToString

func (this *Log) ToString() string

type Mark

type Mark struct {
	Set   string `form:"set" json:"set,omitempty"`
	Limit Limit  `form:"limit" json:"limit,omitempty"`
}

func (*Mark) IsEmpty

func (this *Mark) IsEmpty() bool

func (*Mark) ToString

func (this *Mark) ToString() string

type Port

type Port struct {
	Port     string `form:"port" query:"port" json:"port,omitempty"`
	Protocol string `form:"protocol" query:"protocol" json:"protocol,omitempty"`
}

func (*Port) IsEmpty

func (this *Port) IsEmpty() bool

func (*Port) ToString

func (this *Port) ToString() string

type PortQuery

type PortQuery struct {
	Ip      string `form:"ip" json:"ip" binding:"required"`
	Zone    string `form:"zone,default=public" json:"zone"`
	Timeout uint32 `form:"timeout,default=0" json:"timeout"`
	Port    Port   `form:"port" json:"port,omitempty" binding:"required"`
}

type Protocol

type Protocol struct {
	Value string `form:"value" json:"value,omitempty"`
}

func (*Protocol) IsEmpty

func (this *Protocol) IsEmpty() bool

func (*Protocol) ToString

func (this *Protocol) ToString() string

type Query

type Query struct {
	Ip      string       `form:"ip" json:"ip" binding:"required"`
	Zone    string       `form:"zone,default=public" json:"zone"`
	Timeout uint32       `form:"timeout,default=0" json:"timeout"`
	Port    *Port        `form:"port" json:"port,omitempty"`
	Forward *ForwardPort `form:"forward" json:"forward,omitempty"`
	Rich    *Rule        `form:"rich" json:"rich,omitempty"`
	Service string       `form:"service" json:"service,omitempty"`
}

type QueryRich

type QueryRich struct {
	Address  string `form:"address" json:"address" binding:"required,omitempty"`
	Port     int    `form:"port" json:"port" binding:"required,omitempty"`
	Protocol string `form:"protocol" json:"protocol" binding:"required,omitempty"`
	Type     string `form:"type" json:"type" binding:"required,omitempty"`
	Expire   int    `form:"expire" json:"expire,omitempty"`
	Zone     string `form:"utils" json:"utils" binding:"required,omitempty"`
}

type QuerySettings

type QuerySettings struct {
	Version            string         `deepcopier:"field:Version" form:"version" json:"version,omitempty"`
	Short              string         `deepcopier:"field:Short" form:"short" json:"short,omitempty" binding:"required"`
	Description        string         `deepcopier:"field:Description" form:"description" json:"description,omitempty" binding:"required"`
	Forward            bool           `deepcopier:"field:Forward" form:"forward" json:"forward,omitempty"`
	Target             string         `deepcopier:"field:Target" form:"target" json:"target,omitempty" binding:"required"`
	Service            []string       `deepcopier:"field:Service" form:"service" json:"service,omitempty"`
	Port               []*Port        `deepcopier:"field:Port" form:"port" json:"port,omitempty"`
	IcmpBlock          []*IcmpBlock   `deepcopier:"field:IcmpBlock" form:"icmpblock" json:"icmpblock,omitempty"`
	Masquerade         bool           `deepcopier:"field:Masquerade" form:"masquerade" json:"masquerade,omitempty"`
	ForwardPort        []*ForwardPort `deepcopier:"field:ForwardPort" form:"forwardport" json:"forwardport,omitempty"`
	Interface          []*Interface   `deepcopier:"field:Interface" form:"interface" json:"interface,omitempty"`
	Source             []*Source      `deepcopier:"field:Source" form:"source" json:"source,omitempty"`
	Rule               []*Rule        `deepcopier:"skip" form:"rule" json:"rule,omitempty"`
	Protocol           []*Protocol    `deepcopier:"field:Protocol" form:"protocol" json:"protocol,omitempty"`
	SourcePort         []*SourcePort  `deepcopier:"field:SourcePort" form:"sourceport" json:"sourceport,omitempty"`
	IcmpBlockInversion bool           `deepcopier:"field:IcmpBlockInversion" form:"icmp-block-inversion" json:"icmp-block-inversion",omitempty"`
}

type Reject

type Reject struct {
	Type  string `form:"type" json:"type,omitempty"`
	Limit Limit  `form:"limit" json:"limit,omitempty"`
}

func (*Reject) IsEmpty

func (this *Reject) IsEmpty() bool

func (*Reject) ToString

func (this *Reject) ToString() string

type RemoveQuery

type RemoveQuery struct {
	Ip   string `form:"ip" json:"ip" binding:"required"`
	Name string `form:"name" json:"name" binding:"required"`
}

type Response

type Response struct {
	Code int         `form:"apis" json:"apis,omitempty"`
	Msg  string      `form:"msg" json:"msg,omitempty"`
	Data interface{} `form:"data" json:"data,omitempty"`
}

type ResponseSlice

type ResponseSlice struct {
	Code int         `form:"apis" json:"apis,omitempty"`
	Msg  []string    `form:"msg" json:"msg,omitempty"`
	Data interface{} `form:"data" json:"data,omitempty"`
}

type Rich

type Rich struct {
	Address  string `form:"address" json:"address" binding:"required,omitempty"`
	Port     int    `form:"port" json:"port" binding:"required,omitempty"`
	Protocol string `form:"protocol" json:"protocol" binding:"required,omitempty"`
	Type     string `form:"type" json:"type" binding:"required,omitempty"`
	Expire   int    `form:"expire" json:"expire,omitempty"`
	Zone     string `form:"utils" json:"utils,omitempty"`
}

type RichQuery

type RichQuery struct {
	Ip      string `form:"ip" json:"ip" binding:"required"`
	Zone    string `form:"zone,default=public" json:"zone"`
	Timeout uint32 `form:"timeout,default=0" json:"timeout"`
	Rich    *Rule  `form:"rich" json:"rich,omitempty" binding:"required"`
}

type Rule

type Rule struct {
	Family      string       `form:"family" json:"family,omitempty,default=ipv4"`
	Source      *Source      `form:"source" json:"source,omitempty"`
	Destination *Destination `form:"destination" json:"destination,omitempty"`
	Service     []string     `form:"service" json:"service,omitempty"`
	Port        *Port        `form:"protocol" json:"protocol,omitempty"`
	Protocol    *Protocol    `form:"protocol" json:"protocol,omitempty"`
	IcmpBlock   *IcmpBlock   `form:"icmpblock" json:"icmpblock,omitempty"`
	IcmpType    *IcmpType    `form:"icmptype" json:"icmptype,omitempty"`
	ForwardPort *ForwardPort `form:"forwardport" json:"forwardport,omitempty"`
	Log         *Log         `form:"log" json:"log,omitempty"`
	Audit       *Audit       `form:"audit" json:"audit,omitempty"`
	Accept      *Accept      `form:"accept" json:"accept,omitempty"`
	Reject      *Reject      `form:"reject" json:"reject,omitempty"`
	Drop        *Drop        `form:"drop" json:"drop,omitempty"`
	Mark        *Mark        `form:"mark" json:"mark,omitempty"`
}

func StringToRule

func StringToRule(str string) (rule *Rule)

func (*Rule) ToString

func (this *Rule) ToString() (ruleString string)

type ServiceQuery

type ServiceQuery struct {
	Ip      string `form:"ip" json:"ip" binding:"required"`
	Zone    string `form:"zone,default=public" json:"zone"`
	Timeout uint32 `form:"timeout,default=0" json:"timeout"`
	Service string `form:"service" json:"service,omitempty" binding:"required"`
}

type ServiceSetting

type ServiceSetting struct {
	Version      string            `form:"version" json:"version,omitempty"`
	Short        string            `form:"short" json:"short,omitempty"`
	Description  string            `form:"description" json:"description,omitempty"`
	Port         *[]Port           `form:"port" json:"port,omitempty"`
	Module       []string          `form:"module" json:"module,omitempty"`
	Destination  map[string]string `form:"destination" json:"destination,omitempty"`
	Protocol     []string          `form:"protocol" json:"protocol,omitempty"`
	Source_ports []string          `form:"source_ports" json:"source_ports,omitempty"`
}

type ServiceSettingQuery

type ServiceSettingQuery struct {
	Host        string          `form:"host" json:"host" binding:"required"`
	ServiceName string          `form:"service_name" json:"service_name" binding:"required"`
	Setting     *ServiceSetting `form:"setting" json:"setting,omitempty" binding:"required"`
}

type Settings

type Settings struct {
	Version            string         `deepcopier:"field:Version" form:"version" json:"version,omitempty"`
	Short              string         `deepcopier:"field:Short" form:"short" json:"short,omitempty" binding:"required"`
	Description        string         `deepcopier:"field:Description" form:"description" json:"description,omitempty" binding:"required"`
	Forward            bool           `deepcopier:"field:Forward" form:"forward" json:"forward,omitempty"`
	Target             string         `deepcopier:"field:Target" form:"target" json:"target,omitempty" binding:"required"`
	Service            []string       `deepcopier:"field:Service" form:"service" json:"service,omitempty"`
	Port               []*Port        `deepcopier:"field:Port" form:"port" json:"port,omitempty"`
	IcmpBlock          []*IcmpBlock   `deepcopier:"field:IcmpBlock" form:"icmpblock" json:"icmpblock,omitempty"`
	Masquerade         bool           `deepcopier:"field:Masquerade" form:"masquerade" json:"masquerade,omitempty"`
	ForwardPort        []*ForwardPort `deepcopier:"field:ForwardPort" form:"forwardport" json:"forwardport,omitempty"`
	Interface          []*Interface   `deepcopier:"field:Interface" form:"interface" json:"interface,omitempty"`
	Source             []*Source      `deepcopier:"field:Source" form:"source" json:"source,omitempty"`
	Rule               []string       `deepcopier:"skip" form:"rule" json:"rule,omitempty"`
	Protocol           []*Protocol    `deepcopier:"field:Protocol" form:"protocol" json:"protocol,omitempty"`
	SourcePort         []*SourcePort  `deepcopier:"field:SourcePort" form:"sourceport" json:"sourceport,omitempty"`
	IcmpBlockInversion bool           `deepcopier:"field:IcmpBlockInversion" form:"icmp-block-inversion" json:"icmp-block-inversion",omitempty"`
}

type Source

type Source struct {
	Address string `form:"address" json:"address,omitempty"`
	Mac     string `form:"mac" json:"mac,omitempty"`
	Ipset   string `form:"ipset" json:"ipset,omitempty"`
	Invert  string `form:"invert" json:"invert,omitempty"`
}

func (*Source) IsEmpty

func (this *Source) IsEmpty() bool

func (*Source) ToString

func (this *Source) ToString() string

type SourcePort

type SourcePort struct {
	Port     string `form:"port" json:"port,omitempty"`
	Protocol string `form:"protocol" json:"protocol,omitempty"`
}

type ZoneDst

type ZoneDst struct {
	Host string `form:"host" json:"host,omitempty" binding:"required"`
	Zone string `form:"zone" json:"zone,omitempty" binding:"required"`
}

type ZoneSettingQuery

type ZoneSettingQuery struct {
	Ip      string         `form:"ip" json:"ip" binding:"required"`
	Setting *QuerySettings `form:"setting" json:"Setting,omitempty" binding:"required"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL