Ejemplo n.º 1
0
        /**
         * Constructor.
         * @param brunetConfig configuration file for Brunet P2P library.
         * @param ipopConfig configuration file for IP over P2P app.
         */
        public SocialNode(string brunetConfig, string ipopConfig,
                          string certDir, string port) :
            base(brunetConfig, ipopConfig)
        {
            _friends  = new Dictionary <string, SocialUser>();
            _cert_dir = certDir;
            string cert_path = Path.Combine(certDir, CERTFILENAME);

            _local_cert     = new Certificate(SocialUtils.ReadFileBytes(cert_path));
            _local_user     = new SocialUser(_local_cert);
            _local_cert_b64 = Convert.ToBase64String(_local_cert.X509.RawData);
            _bso.CertificateHandler.AddCACertificate(_local_cert.X509);
            _bso.CertificateHandler.AddSignedCertificate(_local_cert.X509);
            _snp = new SocialNetworkProvider(this.Dht, _local_user);
            _srh = new SocialRpcHandler(_node, _local_user, _friends);
            _scm = new SocialConnectionManager(this, _snp, _snp, port, _friends,
                                               _srh);
        }
Ejemplo n.º 2
0
 /**
  * Constructor.
  * @param brunetConfig configuration file for Brunet P2P library.
  * @param ipopConfig configuration file for IP over P2P app.
  */
 public SocialNode(NodeConfig brunetConfig, IpopConfig ipopConfig, 
               string certDir, string http_port, string jabber_port,
               string global_access)
     : base(brunetConfig, ipopConfig)
 {
     _friends = new Dictionary<string, SocialUser>();
       _aliases = new Dictionary<string, string>();
       _addr_to_key = new Dictionary<string, string>();
       _cert_dir = certDir;
       _http_port = http_port;
       string cert_path = Path.Combine(certDir, CERTFILENAME);
       _local_cert = new Certificate(SocialUtils.ReadFileBytes(cert_path));
       _local_user = new SocialUser(_local_cert);
       _local_cert_b64 = Convert.ToBase64String(_local_cert.X509.RawData);
       _bso.CertificateHandler.AddCACertificate(_local_cert.X509);
       _bso.CertificateHandler.AddSignedCertificate(_local_cert.X509);
       _queue = new BlockingQueue();
       _snp = new SocialNetworkProvider(this.Dht, _local_user,
                                _local_cert.X509.RawData, _queue,
                                jabber_port);
       _sdm = new SocialDnsManager(this, _local_user);
       _srh = new SocialRpcHandler(_node, _local_user, _friends, _queue, _sdm);
       _scm = new SocialConnectionManager(this, _snp, _srh, http_port, _queue,
                                  _sdm);
       _cert_published = false;
       _node.ConnectionTable.ConnectionEvent += ConnectHandler;
       _node.HeartBeatEvent += _scm.HeartBeatHandler;
       Shutdown.OnExit += _scm.Stop;
       _local_user.IP = _marad.LocalIP;
       CreateAlias(_local_user);
       _marad.MapLocalDNS(_local_user.Alias);
       _scm.GlobalAccess = (global_access == "on");
       LoadCertificates();
 }
Ejemplo n.º 3
0
 /**
  * Constructor.
  * @param brunetConfig configuration file for Brunet P2P library.
  * @param ipopConfig configuration file for IP over P2P app.
  */
 public SocialNode(string brunetConfig, string ipopConfig, 
               string certDir, string port)
     : base(brunetConfig, ipopConfig)
 {
     _friends = new Dictionary<string, SocialUser>();
       _cert_dir = certDir;
       string cert_path = Path.Combine(certDir, CERTFILENAME);
       _local_cert = new Certificate(SocialUtils.ReadFileBytes(cert_path));
       _local_user = new SocialUser(_local_cert);
       _local_cert_b64 = Convert.ToBase64String(_local_cert.X509.RawData);
       _bso.CertificateHandler.AddCACertificate(_local_cert.X509);
       _bso.CertificateHandler.AddSignedCertificate(_local_cert.X509);
       _snp = new SocialNetworkProvider(this.Dht, _local_user);
       _srh = new SocialRpcHandler(_node, _local_user, _friends);
       _scm = new SocialConnectionManager(this, _snp, _snp, port, _friends,
                                  _srh);
 }
Ejemplo n.º 4
0
 /**
  * Constructor.
  * @param node the social node.
  * @param provider the identity provider.
  * @param network the social network.
  * @param port the port number for the HTTP interface.
  * @param srh the social rpc handler.
  */
 public SocialConnectionManager(SocialNode node,SocialNetworkProvider snp,
                            SocialRpcHandler srh, string port,
                            BlockingQueue queue, 
                            SocialDnsManager sdm)
 {
     _snode = node;
       _snp = snp;
       _http = new HttpInterface(port);
       _http.ProcessEvent += ProcessHandler;
       _http.Start();
       _srh = srh;
       _queue = queue;
       _sdm = sdm;
       _main_thread = new Thread(Start);
       _main_thread.Start();
       _delims = new char[] {'\n',','};
       _last_update = DateTime.MinValue;
       _last_store = _last_update;
       _last_publish = _last_update;
       _last_ping = _last_update;
       _heartbeat_counter = 0;
 }