diff --git a/config.py b/config.py index fc8b59c..c918f9f 100644 --- a/config.py +++ b/config.py @@ -1,3 +1,5 @@ +import socket + from configparser import ConfigParser class GlobalOptions(): @@ -26,8 +28,14 @@ def __init__(self, name, parser, globals): ''' from domain import Domain + self.contact = parser.get(name, 'Contact', fallback=None) + self.hardware_model = parser.get(name, 'Hardware-Model', fallback=None) + self.hostname = parser.get(name, 'Hostname', fallback=socket.gethostname()) self.name = name self.interfaces = list(map(str.strip, parser.get(name, 'Interfaces', fallback='').split(','))) + self.is_gateway = parser.getboolean(name, 'VPN', fallback='True') + self.longitude = parser.getfloat(name, 'Longitude', fallback=None) + self.latitude = parser.getfloat(name, 'Latitude', fallback=None) self.mcast_link = parser.get(name, 'MulticastLinkAddress', fallback='ff02::2:1001') self.mcast_site = parser.get(name, 'MulticastSiteAddress', fallback='ff05::2:1001') self.ipv4_gateway = parser.get(name, 'IPv4Gateway', fallback=None) diff --git a/domain.py b/domain.py index bc9158c..6c06cee 100644 --- a/domain.py +++ b/domain.py @@ -6,18 +6,36 @@ class Domain(): def __init__(self, config): self.config = config + def get_contact(self): + return self.config.contact + def get_name(self): return self.config.name def get_ipv4_gateway(self): return self.config.ipv4_gateway + def get_hardware_model(self): + return self.config.hardware_model + + def get_hostname(self): + return self.config.hostname + def get_multicast_address_link(self): return self.config.mcast_link def get_multicast_address_site(self): return self.config.mcast_site + def get_latitude(self): + return self.config.latitude + + def get_longitude(self): + return self.config.longitude + + def is_gateway(self): + return self.config.is_gateway + def get_interfaces(self): ''' Returns list off all interfaces respondd queries are expected to arrive on @@ -29,7 +47,13 @@ def get_provider_args(self): expected to arrive on ''' return { + 'contact': self.get_contact(), 'domain_code': self.get_name(), + 'hardware_model': self.get_hardware_model(), + 'hostname': self.get_hostname(), + 'is_gateway': self.is_gateway(), + 'latitude': self.get_latitude(), + 'longitude': self.get_longitude(), 'mesh_ipv4': self.get_ipv4_gateway() } diff --git a/providers/nodeinfo/hardware/model.py b/providers/nodeinfo/hardware/model.py new file mode 100644 index 0000000..56ba9a1 --- /dev/null +++ b/providers/nodeinfo/hardware/model.py @@ -0,0 +1,7 @@ +import providers + +class Source(providers.DataSource): + def required_args(self): + return ['hardware_model'] + def call(self, hardware_model): + return hardware_model diff --git a/providers/nodeinfo/hostname.py b/providers/nodeinfo/hostname.py index fbcf7f4..16172a1 100644 --- a/providers/nodeinfo/hostname.py +++ b/providers/nodeinfo/hostname.py @@ -1,6 +1,7 @@ import providers -import socket class Source(providers.DataSource): - def call(self): - return socket.gethostname() + def required_args(self): + return ['hostname'] + def call(self, hostname): + return hostname diff --git a/providers/nodeinfo/location/latitude.py b/providers/nodeinfo/location/latitude.py new file mode 100644 index 0000000..d854bee --- /dev/null +++ b/providers/nodeinfo/location/latitude.py @@ -0,0 +1,7 @@ +import providers + +class Source(providers.DataSource): + def required_args(self): + return ['latitude'] + def call(self, latitude): + return latitude diff --git a/providers/nodeinfo/location/longitude.py b/providers/nodeinfo/location/longitude.py new file mode 100644 index 0000000..031ac63 --- /dev/null +++ b/providers/nodeinfo/location/longitude.py @@ -0,0 +1,7 @@ +import providers + +class Source(providers.DataSource): + def required_args(self): + return ['longitude'] + def call(self, longitude): + return longitude diff --git a/providers/nodeinfo/owner/contact.py b/providers/nodeinfo/owner/contact.py new file mode 100644 index 0000000..3196da2 --- /dev/null +++ b/providers/nodeinfo/owner/contact.py @@ -0,0 +1,7 @@ +import providers + +class Source(providers.DataSource): + def required_args(self): + return ['contact'] + def call(self, contact): + return contact diff --git a/providers/nodeinfo/vpn.py b/providers/nodeinfo/vpn.py index dc20dc5..ee88cc5 100644 --- a/providers/nodeinfo/vpn.py +++ b/providers/nodeinfo/vpn.py @@ -1,5 +1,7 @@ import providers class Source(providers.DataSource): - def call(self): - return True + def required_args(self): + return ['is_gateway'] + def call(self, is_gateway): + return is_gateway diff --git a/respondd.conf.example b/respondd.conf.example index b30f146..a847765 100644 --- a/respondd.conf.example +++ b/respondd.conf.example @@ -20,6 +20,24 @@ DomainType: batadv # Default ddhcpd IPv4 gateway address # optional IPv4Gateway: 10.116.128.8 +# Hostname to advertise +# optional, default is the system hostname +Hostname: gw01 +# Hardware used by the system +# optional, default is None +Hardware-Model: KVM VirtualMachine +# Contact information of owner +# optional, default is None +Contact: info@example.org +# Latitude of the system +# optional, default is None +Latitude: 50.478083306 +# Longitude of the system +# optional, default is None +Longitude: 12.335736752 +# Is the system considered an gateway +# optional, default is True +VPN: True # A domain # User your own domain name here @@ -43,5 +61,23 @@ Interfaces: mvpn-ffki # IPv4 gateway option for ddhcpd # optional, default: @IPv4Gateway IPv4Gateway: 10.116.128.8 +# Hostname to advertise +# optional, default: @Hostname +Hostname: ffki.gw01 +# Hardware used by the system +# optional, default: @Hardware-Model +Hardware-Model: KVM VirtualMachine +# Contact information of owner +# optional, default: @Contact +Contact: ffki@example.org +# Latitude of the system +# optional, default: @Latitude +Latitude: 50.478083306 +# Longitude of the system +# optional, default: @Longitude +Longitude: 12.335736752 +# Is the system considered a gateway +# optional, default: @VPN +VPN: True # An arbitrary number of further domains may follow here