move config file to SAMPLE

This commit is contained in:
Cort Buffington 2016-07-21 12:41:36 -05:00
parent 871b07dc0d
commit 3018379311
2 changed files with 31 additions and 4 deletions

View File

@ -16,7 +16,7 @@ PASSPHRASE: s3cr37w0rd
[MASTER-2] [MASTER-2]
MODE: MASTER MODE: MASTER
ENABLED: True ENABLED: False
IP: IP:
PORT: 55000 PORT: 55000
PASSPHRASE: 13370p3r470r PASSPHRASE: 13370p3r470r
@ -46,7 +46,7 @@ PACKAGE_ID: HBlink v1.0
[REPEATER-2] [REPEATER-2]
MODE: CLIENT MODE: CLIENT
ENABLED: True ENABLED: False
IP: IP:
PORT: 54002 PORT: 54002
MASTER_IP: 172.16.1.1 MASTER_IP: 172.16.1.1

View File

@ -16,11 +16,15 @@ import os
# Specifig functions from modules we need # Specifig functions from modules we need
from binascii import b2a_hex as h from binascii import b2a_hex as h
from socket import gethostbyname from socket import gethostbyname
from random import randint
# Debugging functions
from pprint import pprint from pprint import pprint
# Twisted is pretty important, so I keep it separate # Twisted is pretty important, so I keep it separate
from twisted.internet.protocol import DatagramProtocol from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor from twisted.internet import reactor
from twisted.internet import task
# Other files we pull from -- this is mostly for readability and segmentation # Other files we pull from -- this is mostly for readability and segmentation
import hb_log import hb_log
@ -72,11 +76,34 @@ logger.debug('Logging system started, anything from here on gets logged')
class HBMASTER(DatagramProtocol): class HBMASTER(DatagramProtocol):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
pass pass
def startProtocol(self):
pass
class HBCLIENT(DatagramProtocol): class HBCLIENT(DatagramProtocol):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
pass if len(args) == 1:
self._client = args[0]
self._config = CONFIG['CLIENTS'][self._client]
else:
# If we didn't get called correctly, log it!
logger.error('(%s) HBCLIENT was not called with an argument. Terminating', self._client)
sys.exit()
def startProtocol(self):
# Set up periodic loop for sending pings to the master. Run every minute
self._peer_maintenance = task.LoopingCall(self.peer_maintenance_loop)
self._peer_maintenance_loop = self._peer_maintenance.start(60)
def peer_maintenance_loop(self):
###### Need to add check to see if the peer is connected, and only do this if it is.
logger.debug('(%s) Sending ping to Master', self._client)
def datagramReceived(self, data, (host, port)):
print(data)
#************************************************ #************************************************