Пример #1
0
        /// <summary>
        /// Creates a new management parser.
        /// </summary>
        /// <param name="oc">reference to the network communicator</param>
        /// <param name="ol">reference to the management logic</param>
        /// <param name="logs">reference to the log interface</param>
        internal OVPNManagementParser(OVPNCommunicator oc, OVPNManagementLogic ol, OVPNLogManager logs)
        {
            // copy data
            m_logs = logs;
            m_ol   = ol;

            // receive new data
            oc.gotLine += new OVPNCommunicator.GotLineEvent(oc_gotLine);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new OVPNCommunicator object.
 /// </summary>
 /// <param name="host">Host to connect to (127.0.0.1)</param>
 /// <param name="port">Port to connect to</param>
 /// <param name="logs">Log manager</param>
 /// <param name="ovpn">Parent object</param>
 public OVPNCommunicator(string host, int port,
                         OVPNLogManager logs, OVPNConnection ovpn)
 {
     m_host = host;
     m_port = port;
     m_logs = logs;
     m_ovpn = ovpn;
     m_tcpC = new TcpClient();
 }
Пример #3
0
        /// <summary>
        /// Creates a new ManagementLogic object.
        /// </summary>
        /// <param name="ovpn">parent</param>
        /// <param name="host">host to connect to (e.g. 127.0.0.1)</param>
        /// <param name="port">port to connect to</param>
        /// <param name="logs">LogManager to write the logs to</param>
        public OVPNManagementLogic(OVPNConnection ovpn,string host,
                                   int port,OVPNLogManager logs)
        {
            m_ovpn        = ovpn;
            m_logs        = logs;
            m_releaselock = true;

            // initialize required components
            m_ovpnComm      = new OVPNCommunicator(host,port,logs,ovpn);
            m_ovpnMParser   = new OVPNManagementParser(m_ovpnComm,this,logs);
            m_pkcs11details = new List <PKCS11Detail>();

            m_ovpnComm.connectionClosed += new System.EventHandler(m_ovpnComm_connectionClosed);
        }
Пример #4
0
        /// <summary>
        /// Initializes a new OVPN Object.
        /// </summary>
        /// <param name="host">Host to connect to which holds the management interface</param>
        /// <param name="port">Port to connect to</param>
        /// <param name="earlyLogEvent">Delegate to a event processor</param>
        /// <param name="earlyLogLevel">Log level</param>
        /// <seealso cref="logs"/>
        public OVPNConnection(string host, int port, OVPNLogManager.LogEventDelegate earlyLogEvent, int earlyLogLevel)
        {
            m_host = host;
            m_port = port;

            m_logs            = new OVPNLogManager(this);
            m_logs.debugLevel = earlyLogLevel;
            if (earlyLogEvent != null)
            {
                m_logs.LogEvent += earlyLogEvent;
            }

            m_ovpnMLogic = new OVPNManagementLogic(this, host, port, m_logs);
            changeState(OVPNState.STOPPED);
        }
Пример #5
0
        /// <summary>
        /// Initialize a new OpenVPN service.
        /// </summary>
        /// <param name="binfile">path to openvpn</param>
        /// <param name="configfile">path to openvpn config</param>
        /// <param name="dir">directory where config lies</param>
        /// <param name="logs">provider to write logs to</param>
        /// <param name="host">The host to connect to (e.g. 127.0.0.1)</param>
        /// <param name="port">The port to connect to</param>
        /// <param name="logfile">file to write OpenVPN log to</param>
        public OVPNService(string binfile, string configfile,
                           string dir, OVPNLogManager logs, string host, int port,
                           string logfile)
        {
            m_objid = ++objcount;
            m_logs  = logs;
            running = false;

            m_psi.FileName         = binfile;
            m_psi.WorkingDirectory = dir;
            m_psi.WindowStyle      = ProcessWindowStyle.Hidden;
            m_psi.UseShellExecute  = true;
            m_psi.Verb             = "runas";
            m_psi.CreateNoWindow   = true;
            m_psi.Arguments        =
                "--log \"" + logfile + "\"" +
                " --config \"" + configfile + "\"" +
                " --management " + host + " " + port.ToString() +
                " --management-query-passwords" +
                " --management-hold" +
                " --management-signal" +
                " --management-forget-disconnect" +
                " --pkcs11-id-management";
        }