Module: Y2Firewall::Firewalld::Api::Services

Included in:
Y2Firewall::Firewalld::Api
Defined in:
library/network/src/lib/y2firewall/firewalld/api/services.rb

Overview

This module contains specific api methods for handling services definition and configuration.

Instance Method Summary collapse

Instance Method Details

#add_service_port(service, port, permanent: permanent?) ) ⇒ Boolean

command to be executed

Parameters:

  • service (String)

    The firewall firewall

  • port (String)

    The firewall port

  • permanent (Boolean)

    if true it adds the –permanent option the

Returns:

  • (Boolean)

    True if port was removed from service



112
113
114
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 112

def add_service_port(service, port, permanent: permanent?)
  string_command("--service=#{service}", "--add-port=#{port}", permanent: permanent)
end

#info_service(service, permanent: permanent?) ) ⇒ Array<String>

command to be executed

Parameters:

  • service (String)

    The firewall service

  • permanent (Boolean)

    if true it adds the –permanent option the

Returns:

  • (Array<String>)

    list of all information for the given service



47
48
49
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 47

def info_service(service, permanent: permanent?)
  string_command("--info-service", service.to_s, permanent: permanent).split("\n")
end

#new_service(service, permanent: permanent?) ) ⇒ Object

command to be executed

Parameters:

  • service (String)

    The firewall service

  • permanent (Boolean)

    if true it adds the –permanent option the



34
35
36
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 34

def new_service(service, permanent: permanent?)
  query_command("--new-service=#{service}", permanent: permanent)
end

#remove_service_port(service, port, permanent: permanent?) ) ⇒ Boolean

command to be executed

Parameters:

  • service (String)

    The firewall service

  • port (String)

    The firewall port

  • permanent (Boolean)

    if true it adds the –permanent option the

Returns:

  • (Boolean)

    True if port was removed from service



103
104
105
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 103

def remove_service_port(service, port, permanent: permanent?)
  string_command("--service=#{service}", "--remove-port=#{port}", permanent: permanent)
end

#service_description(service, permanent: permanent?) ) ⇒ String

command to be executed

Parameters:

  • service (String)

    the firewall service

  • permanent (Boolean)

    if true it adds the –permanent option the

Returns:

  • (String)

    Description for service



64
65
66
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 64

def service_description(service, permanent: permanent?)
  string_command("--service=#{service}", "--get-description", permanent: permanent)
end

#service_modules(service, permanent: permanent?) ) ⇒ Array<String>

command to be executed

Parameters:

  • service (String)

    The firewall service

  • permanent (Boolean)

    if true it adds the –permanent option the

Returns:

  • (Array<String>)

    The firewall service modules



94
95
96
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 94

def service_modules(service, permanent: permanent?)
  string_command("--service=#{service}", "--get-modules", permanent: permanent).split(" ")
end

#service_ports(service, permanent: permanent?) ) ⇒ Array<String>

command to be executed

Parameters:

  • service (String)

    The firewall service

  • permanent (Boolean)

    if true it adds the –permanent option the

Returns:

  • (Array<String>)

    The firewall service ports



78
79
80
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 78

def service_ports(service, permanent: permanent?)
  string_command("--service=#{service}", "--get-ports", permanent: permanent).split(" ")
end

#service_protocols(service, permanent: permanent?) ) ⇒ Array<String>

command to be executed

Parameters:

  • service (String)

    The firewall service

  • permanent (Boolean)

    if true it adds the –permanent option the

Returns:

  • (Array<String>)

    The firewall service protocols



86
87
88
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 86

def service_protocols(service, permanent: permanent?)
  string_command("--service=#{service}", "--get-protocols", permanent: permanent).split(" ")
end

#service_short(service, permanent: permanent?) ) ⇒ String

command to be executed

Parameters:

  • service (String)

    The firewall service

  • permanent (Boolean)

    if true it adds the –permanent option the

Returns:

  • (String)

    Short description for service



55
56
57
58
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 55

def service_short(service, permanent: permanent?)
  # these may not exist on early firewalld releases
  string_command("--service=#{service}", "--get-short", permanent: permanent)
end

#service_supported?(service) ⇒ Boolean

Returns True if service definition exists

Parameters:

  • service (String)

    The firewall service

Returns:

  • (Boolean)

    True if service definition exists



70
71
72
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 70

def service_supported?(service)
  services.include?(service)
end

#servicesArray<String>

Returns List of firewall services

Returns:

  • (Array<String>)

    List of firewall services



39
40
41
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 39

def services
  string_command("--get-services").split(" ")
end