Inheritance: Ipop.Managed.ManagedIpopNode
 public SocialDnsManager(SocialNode node)
 {
     _node      = node;
     _mappings  = ImmutableDictionary <string, DnsMapping> .Empty;
     _tmappings = ImmutableDictionary <string, DnsMapping> .Empty;
     _sender    = new WriteOnce <IRpcSender>();
     LoadState();
     AddDnsMapping(System.Net.Dns.GetHostName());
 }
        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
        }
Example #3
0
    public JabberNetwork(string network_host, string jabber_port,
      bool autoFriend, SocialNode node) {

      _jclient = new JabberClient();
      _jclient.Port = Int32.Parse(jabber_port);
      _jclient.NetworkHost = network_host;
      _jclient.AutoReconnect = 30F;
      _jclient.AutoStartTLS = true;
      _jclient.AutoStartCompression = false;
      _jclient.KeepAlive = 30F;
      _jclient.AutoPresence = true;
      _jclient.AutoRoster = false;
      _jclient.LocalCertificate = null;
      Random rand = new Random();
      _jclient.Resource = SVPNRESOURCE + rand.Next(Int32.MaxValue);

      _jclient.OnAuthenticate += HandleOnAuthenticate;
      _jclient.OnPresence += HandleOnPresence;
      _jclient.OnIQ += HandleOnIQ;
      _jclient.OnInvalidCertificate += 
        new RemoteCertificateValidationCallback(HandleInvalidCert);
      
      _jclient.OnError += HandleOnError;
      _jclient.OnAuthError += HandleOnAuthError;
      _jclient.OnReadText += HandleOnReadText;
      _jclient.OnWriteText += HandleOnWriteText;

      _rman = null;
      _node = node;

      if(autoFriend) {
        _rman = new RosterManager();
        _rman.Stream = _jclient;
        _rman.AutoAllow = jabber.client.AutoSubscriptionHanding.AllowAll;
      }
    }
    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

    }
Example #5
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;
    }
Example #6
0
 public SocialStatsManager(SocialNode node) {
   _node = node;
   _latencies = ImmutableDictionary<string, double>.Empty;
 }
Example #7
0
 public SocialStatsManager(SocialNode node)
 {
     _node      = node;
     _latencies = ImmutableDictionary <string, double> .Empty;
 }
Example #8
0
    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;
    }
Example #9
0
        public static void Main(string[] args)
        {
            SocialNode node = SocialNode.CreateNode();

            node.Run();
        }
Example #10
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);
        }