Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodeinfo: add more nodeinfo #63

Merged
merged 1 commit into from
Mar 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import socket

from configparser import ConfigParser

class GlobalOptions():
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}

Expand Down
7 changes: 7 additions & 0 deletions providers/nodeinfo/hardware/model.py
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions providers/nodeinfo/hostname.py
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions providers/nodeinfo/location/latitude.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import providers

class Source(providers.DataSource):
def required_args(self):
return ['latitude']
def call(self, latitude):
return latitude
7 changes: 7 additions & 0 deletions providers/nodeinfo/location/longitude.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import providers

class Source(providers.DataSource):
def required_args(self):
return ['longitude']
def call(self, longitude):
return longitude
7 changes: 7 additions & 0 deletions providers/nodeinfo/owner/contact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import providers

class Source(providers.DataSource):
def required_args(self):
return ['contact']
def call(self, contact):
return contact
6 changes: 4 additions & 2 deletions providers/nodeinfo/vpn.py
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions respondd.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]
# 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
Expand All @@ -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: [email protected]
# 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