コード例 #1
0
ファイル: SocialNode.cs プロジェクト: bakriy/brunet
    public static new SocialNode CreateNode() {
      SocialConfig social_config;
      NodeConfig node_config;
      IpopConfig ipop_config;

      byte[] certData = SocialUtils.ReadFileBytes("local.cert");
      string certb64 = Convert.ToBase64String(certData);
      social_config = Utils.ReadConfig<SocialConfig>("social.config");
      node_config = Utils.ReadConfig<NodeConfig>(social_config.BrunetConfig);
      ipop_config = Utils.ReadConfig<IpopConfig>(social_config.IpopConfig);

      SocialNode node = new SocialNode(node_config, ipop_config, certb64);
      HttpInterface http_ui = new HttpInterface(social_config.HttpPort);
      SocialDnsManager dns_manager = new SocialDnsManager(node);
      JabberNetwork jabber = new JabberNetwork(social_config.JabberHost,
                                               social_config.JabberPort,
                                               social_config.AutoFriend,
                                               node);

      http_ui.ProcessEvent += node.ProcessHandler;
      http_ui.ProcessEvent += jabber.ProcessHandler;
      http_ui.ProcessEvent += dns_manager.ProcessHandler;

      node.Shutdown.OnExit += http_ui.Stop;
      node.Shutdown.OnExit += jabber.Logout;

      node.SetGlobalBlock(social_config.GlobalBlock);
      node.LoadState();
      if (social_config.AutoLogin) {
        jabber.Login(social_config.JabberID, social_config.JabberPass);
      }
      http_ui.Start();
      return node;
    }
コード例 #2
0
ファイル: SocialNode.cs プロジェクト: ikaragkiozoglou/brunet
    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;
    }
コード例 #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);
        }