#!/usr/bin/env python3
'''
This is the clam foot server module for the clam-chatter peer to peer network
framework. The only dependency the clam foot server requires is openssl version
1.0.0+. This dependency is supported on ARM chipsets making it possible to run
a clam foot server on devices such as phones or Raspberry Pis.

_______________________________________________________________________________
clam-chatter is a total encryption peer to peer network framework. Consistency
is provided by a blind clam foot server.
_______________________________________________________________________________


NOTE:
To make a self signed username_cert.pem and username_key.pem use a command
similar to this: "openssl req -x509 -newkey rsa:4096 -keyout username_key.pem
-out username_cert.pem -days 365"


Untested on Mac and Windows systems.

Tested with Python 3.5.2.
Tested on Linux (Ubuntu Mate 16.04.2) systems.


Written by: Micah Parks.
'''

# Start standard library injections.
from hashlib import md5
from os import getcwd, remove
from os.path import exists
from selectors import DefaultSelector, EVENT_READ
from socket import AF_INET, SOCK_STREAM, socket
from ssl import PROTOCOL_TLSv1_2, SSLContext
from threading import Thread
from time import sleep, time
# End standard library injections.

CTX = SSLContext(PROTOCOL_TLSv1_2)
EOF_BYTES = bytes('EOF', 'utf-8')
FILE_BUFF = 1048576
SELF_HOST = str()
SELF_PORT = 26650


def addr_or_username_to_addr(addrorusername, activeconndict, knownbool=True):