<reponame>paulgirmes/vpn_ansible<filename>config.py<gh_stars>0
class Config:
    """
    configuration options for vpn.py (to be replaced if needed)
    """

    # the route behind the vpn server to be pushed to clients+
    # wan interface name for the VPN server
    LAN_TO_PUSH = "'route 10.0.1.0 255.255.255.0'"
    WAN_INTERFACE_NAME = "ens33"
    VPN_SERVER_IP = "192.168.0.11"
    CLIENTS_IP = [
        "192.168.0.10",
    ]

    # EasyRsa Tool vars config file
    RSA = [
        'set_var EASYRSA_REQ_COUNTRY "US"',
        'set_var EASYRSA_REQ_PROVINCE "NewYork"',
        'set_var EASYRSA_REQ_CITY "New York City"',
        'set_var EASYRSA_REQ_ORG "DigitalOcean"',
        'set_var EASYRSA_REQ_EMAIL "<EMAIL>"',
        'set_var EASYRSA_REQ_OU "Community"',
    ]
    # VPN server.conf file options
    VPN = [
        "# Generated by vpn.py, model can be found at :",
        "# /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz",
        "port 1194",
        "proto udp",
        "dev tun",
        "ca ca.crt",
        "cert server.crt",
        "key server.key",
        "server 10.8.0.0 255.255.255.0",
        "ifconfig-pool-persist /var/log/openvpn/ipp.txt",
        "keepalive 10 120",
        "tls-auth ta.key 0",
        "auth SHA256",
        "dh dh.pem",
        "push {}".format(LAN_TO_PUSH),
        "cipher AES-256-CBC",
        "user nobody",
        "group nogroup",
        "persist-key",
        "persist-tun",
        "status /var/log/openvpn/openvpn-status.log",
        "verb 4",
        "explicit-exit-notify 1",
    ]

    # /etc/ufw/before.rules
    UFW_BEFORE = [
        "# START OPENVPN RULES",
        "# NAT table rules",
        "*nat",
        ":POSTROUTING ACCEPT [0:0]",
        "# Allow traffic from OpenVPN client to WAN",
        "-A POSTROUTING -s 10.8.0.0/8 {} -j MASQUERADE".format(WAN_INTERFACE_NAME),
        "COMMIT",
        "# END OPENVPN RULES",
    ]
    # client config file
    VPN_CLIENT = [
        "# Generated by vpn.py, model can be found at :",
        "# /usr/share/doc/openvpn/examples/sample-config-files/client.conf",
        "client",
        "dev tun",
        "proto udp",
        "remote {} 1194".format(VPN_SERVER_IP),
        "resolv-retry infinite",
        "nobind",
        "user nobody",
        "group nogroup",
        "persist-key",
        "persist-tun",
        "remote-cert-tls server",
        "cipher AES-256-CBC",
        "auth SHA256",
        "key-direction 1",
        "verb 3",
    ]

class Config:
    """
    configuration options for vpn.py (to be replaced if needed)
    """

    # the route behind the vpn server to be pushed to clients+
    # wan interface name for the VPN server
    LAN_TO_PUSH = "'route 10.0.1.0 255.255.255.0'"
    WAN_INTERFACE_NAME = "ens33"
    VPN_SERVER_IP = "192.168.0.11"
    CLIENTS_IP = [
        "192.168.0.10",
    ]

    # EasyRsa Tool vars config file
    RSA = [
        'set_var EASYRSA_REQ_COUNTRY "US"',
        'set_var EASYRSA_REQ_PROVINCE "NewYork"',
        'set_var EASYRSA_REQ_CITY "New York City"',
        'set_var EASYRSA_REQ_ORG "DigitalOcean"',
        'set_var EASYRSA_REQ_EMAIL "<EMAIL>"',
        'set_var EASYRSA_REQ_OU "Community"',
    ]
    # VPN server.conf file options
    VPN = [
        "# Generated by vpn.py, model can be found at :",
        "# /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz",
        "port 1194",
        "proto udp",
        "dev tun",
        "ca ca.crt",
        "cert server.crt",
        "key server.key",
        "server 10.8.0.0 255.255.255.0",
        "ifconfig-pool-persist /var/log/openvpn/ipp.txt",
        "keepalive 10 120",
        "tls-auth ta.key 0",
        "auth SHA256",
        "dh dh.pem",
        "push {}".format(LAN_TO_PUSH),
        "cipher AES-256-CBC",
        "user nobody",
        "group nogroup",
        "persist-key",
        "persist-tun",
        "status /var/log/openvpn/openvpn-status.log",
        "verb 4",
        "explicit-exit-notify 1",
    ]

    # /etc/ufw/before.rules
    UFW_BEFORE = [
        "# START OPENVPN RULES",
        "# NAT table rules",
        "*nat",
        ":POSTROUTING ACCEPT [0:0]",
        "# Allow traffic from OpenVPN client to WAN",
        "-A POSTROUTING -s 10.8.0.0/8 {} -j MASQUERADE".format(WAN_INTERFACE_NAME),
        "COMMIT",
        "# END OPENVPN RULES",
    ]
    # client config file
    VPN_CLIENT = [
        "# Generated by vpn.py, model can be found at :",
        "# /usr/share/doc/openvpn/examples/sample-config-files/client.conf",
        "client",
        "dev tun",
        "proto udp",
        "remote {} 1194".format(VPN_SERVER_IP),
        "resolv-retry infinite",
        "nobind",
        "user nobody",
        "group nogroup",
        "persist-key",
        "persist-tun",
        "remote-cert-tls server",
        "cipher AES-256-CBC",
        "auth SHA256",
        "key-direction 1",
        "verb 3",
    ]
configuration options for vpn.py (to be replaced if needed) # the route behind the vpn server to be pushed to clients+ # wan interface name for the VPN server # EasyRsa Tool vars config file # VPN server.conf file options # /etc/ufw/before.rules # client config file