def postProxySettings():
    config = {}
    netConfig = {}
    err = ""
    #try:
    config['Operation'] = 'Proxy'
    config['Interface'] = request.form.get('intInt')
    config['Roletype'] = request.form.get('networkRole')
    config['Encryption'] = request.form.get('encryption')
    config['Capture'] = request.form.get('captureMode')
    config['Bind'] = request.form.get('targetIp')
    config['Port'] = request.form.get('targetPort')
    confLib.writeConfig(config, 'proxy')

    netConfig = config
    netConfig['ExternalInterface'] = request.form.get('extInt')
    netConfig['InternalInterface'] = config['Interface']
    confLib.writeInterfacesFile(netConfig, 'proxy')
    #confLib.writeProxyConfig(config)
    confLib.updateConfig(config, 'armore')
    #except:
    #    err = "Unable to set Proxy config"
    #    print("Error writing config:", sys.exc_info()[0])

    dComLib.addToFlash(err)
    
    return redirect(url_for("settings.settings"))
def postArmoreSettings():
    config = {}
    err = ""
    restartFlask = False
    #try:
    config['Operation'] = request.form.get('operationMode')
    config['Management_Interface'] = request.form.get('mgtInt')
    config['Management_IP'] = request.form.get('mgtIp')
    config['Management_Mask'] = request.form.get('mgtMsk')
    config['Internal_Interface'] = request.form.get('intInt')
    config['Internal_IP'] = request.form.get('intIp')
    config['Internal_Mask'] = request.form.get('intMsk')
    config['External_Interface'] = request.form.get('extInt')
    config['External_IP'] = request.form.get('extIp')
    config['External_Mask'] = request.form.get('extMsk')
    restartFlask = confLib.writeConfig(config, 'armore')
    mode = ""
    if config['Operation'] == 'Proxy':
        config['Interface'] = request.form.get('monIntProxy')
        config['Roletype'] = request.form.get('networkRole')
        config['Encryption'] = request.form.get('encryption')
        config['Capture'] = request.form.get('captureMode')
        config['Bind'] = request.form.get('targetIp')
        config['Port'] = request.form.get('targetPort')
        mode = 'proxy'
    if config['Operation'] == 'Passive':
        newKeys = comLib.getKeysByValue(config, request.form.get('monIntPsv'))
        newKey = newKeys[0].split('_')[0]
        config['Monitored_Interface'] = request.form.get('monIntPsv')
        config['Monitored_IP'] = config[newKey + "_IP"]
        config['Monitored_Mask'] = config[newKey + "_Mask"]
        mode = 'passive'
    if config['Operation'] == 'Transparent':
        config['Interface_1'] = request.form.get('brdgInt1')
        config['Interface_2'] = request.form.get('brdgInt2')
        config['Bridge_IP'] = request.form.get('bridgeIp')
        config['Broadcast_IP'] = request.form.get('broadcastIp')
        config['Bridge_Mask'] = request.form.get('netmask')
        config['Bridge_Gateway'] = request.form.get('gateway')
        config['Bridge_CIDR'] = request.form.get('route')
        mode = 'transparent'
    confLib.writeInterfacesFile(config, mode)
    #confLib.updateIpAddrs(config)
    #except:
    #    err = "Unable to get current config"
    #    print("Error writing config:", sys.exc_info()[0])

    dComLib.addToFlash(err)
    
    if restartFlask:
        return redirect(url_for("settings.redirectTo", ip=config["Management_IP"]))
    else:
        return redirect(url_for("settings.settings"))