Esempio n. 1
0
        public SocialConnectionManager(SocialNode node, RpcManager rpc,
                                       SocialDnsManager sdm, SocialStatsManager ssm, SocialConfig config)
        {
            _rpc = rpc;
            _rpc.AddHandler(RPCID, this);
            _sdm          = sdm;
            _node         = node;
            _ssm          = ssm;
            _networks     = ImmutableDictionary <string, ISocialNetwork> .Empty;
            _fprs         = ImmutableDictionary <string, string> .Empty;
            _times        = ImmutableDictionary <string, DateTime> .Empty;
            _pending      = ImmutableList <string> .Empty;
            _blocked      = ImmutableList <string> .Empty;
            _beat_counter = 0;
            _auto_allow   = config.AutoFriend;
            _sdm.Sender   = this;
#if !SVPN_NUNIT
            _timer = new Timer(TimerHandler, _beat_counter, PERIOD, PERIOD);
            LoadState();
#endif
        }
    public SocialConnectionManager(SocialNode node, RpcManager rpc,
      SocialDnsManager sdm, SocialStatsManager ssm, SocialConfig config) {
      _rpc = rpc;
      _rpc.AddHandler(RPCID, this);
      _sdm = sdm;
      _node = node;
      _ssm = ssm;
      _networks = ImmutableDictionary<string, ISocialNetwork>.Empty;
      _fprs = ImmutableDictionary<string, string>.Empty;
      _times = ImmutableDictionary<string, System.DateTime>.Empty;
      _pending = ImmutableList<string>.Empty;
      _blocked = ImmutableList<string>.Empty;
      _beat_counter = 0;
      _auto_allow = config.AutoFriend;
      _sdm.Sender = this;
#if !SVPN_NUNIT
      _timer = new Timer(TimerHandler, _beat_counter, PERIOD, PERIOD);
      LoadState();
#endif

    }
Esempio n. 3
0
    public static new SocialNode CreateNode() {

      SocialConfig social_config;
      NodeConfig node_config;
      IpopConfig ipop_config;
      RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

      if(File.Exists(CONFIGPATH)) {
        social_config = Utils.ReadConfig<SocialConfig>(CONFIGPATH);
      }
      else {
        social_config = SocialUtils.CreateConfig();
      }

      node_config = Utils.ReadConfig<NodeConfig>(social_config.BrunetConfig);
      ipop_config = Utils.ReadConfig<IpopConfig>(social_config.IpopConfig);

      if(!File.Exists(node_config.Security.KeyPath) || 
        node_config.NodeAddress == null) {
        node_config.NodeAddress = Utils.GenerateAHAddress().ToString();
        Utils.WriteConfig(social_config.BrunetConfig, node_config);

        SocialUtils.WriteToFile(rsa.ExportCspBlob(true), 
          node_config.Security.KeyPath);
      }
      else if(File.Exists(node_config.Security.KeyPath)) {
        rsa.ImportCspBlob(SocialUtils.ReadFileBytes(
          node_config.Security.KeyPath));
      }

      SocialNode node = new SocialNode(node_config, ipop_config, rsa);
#if !SVPN_NUNIT
      SocialDnsManager sdm = new SocialDnsManager(node);
      SocialStatsManager ssm = new SocialStatsManager(node);

      SocialConnectionManager manager = new SocialConnectionManager(node,
        node.AppNode.Node.Rpc, sdm, ssm, social_config);

      JabberNetwork jabber = new JabberNetwork(social_config.JabberID, 
        social_config.JabberPass, social_config.JabberHost, 
        social_config.JabberPort);

      TestNetwork test = new TestNetwork();

      manager.Register("jabber", jabber);
      manager.Register("test", test);

      if(social_config.AutoLogin) {
        manager.Login("jabber", social_config.JabberID, 
          social_config.JabberPass);
      }

      HttpInterface http = new HttpInterface(social_config.HttpPort);
      http.ProcessEvent += manager.ProcessHandler;

      node._marad.Resolver = sdm;
      node.Shutdown.OnExit += jabber.Logout;
      node.Shutdown.OnExit += http.Stop;
      http.Start();
#endif

      return node;
    }
Esempio n. 4
0
        public static new SocialNode CreateNode()
        {
            SocialConfig             social_config;
            NodeConfig               node_config;
            IpopConfig               ipop_config;
            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

            if (File.Exists(CONFIGPATH))
            {
                social_config = Utils.ReadConfig <SocialConfig>(CONFIGPATH);
            }
            else
            {
                social_config = SocialUtils.CreateConfig();
            }

            node_config = Utils.ReadConfig <NodeConfig>(social_config.BrunetConfig);
            ipop_config = Utils.ReadConfig <IpopConfig>(social_config.IpopConfig);

            if (!File.Exists(node_config.Security.KeyPath) ||
                node_config.NodeAddress == null)
            {
                node_config.NodeAddress = Utils.GenerateAHAddress().ToString();
                Utils.WriteConfig(social_config.BrunetConfig, node_config);

                SocialUtils.WriteToFile(rsa.ExportCspBlob(true),
                                        node_config.Security.KeyPath);
            }
            else if (File.Exists(node_config.Security.KeyPath))
            {
                rsa.ImportCspBlob(SocialUtils.ReadFileBytes(
                                      node_config.Security.KeyPath));
            }

            SocialNode node = new SocialNode(node_config, ipop_config, rsa);

#if !SVPN_NUNIT
            SocialDnsManager   sdm = new SocialDnsManager(node);
            SocialStatsManager ssm = new SocialStatsManager(node);

            SocialConnectionManager manager = new SocialConnectionManager(node,
                                                                          node.AppNode.Node.Rpc, sdm, ssm, social_config);

            JabberNetwork jabber = new JabberNetwork(social_config.JabberID,
                                                     social_config.JabberPass, social_config.JabberHost,
                                                     social_config.JabberPort);

            TestNetwork test = new TestNetwork();

            manager.Register("jabber", jabber);
            manager.Register("test", test);

            if (social_config.AutoLogin)
            {
                manager.Login("jabber", social_config.JabberID,
                              social_config.JabberPass);
            }

            HttpInterface http = new HttpInterface(social_config.HttpPort);
            http.ProcessEvent += manager.ProcessHandler;

            node._marad.Resolver  = sdm;
            node.Shutdown.OnExit += jabber.Logout;
            node.Shutdown.OnExit += http.Stop;
            http.Start();
#endif

            return(node);
        }