Esempio n. 1
0
        async Task ThreadFunc()
        {
            try {
                var nodes = await RancherManager.GetServiceNodes();

                Logger.Log(RancherThreadLog, $"There are {nodes.Count} nodes available (including me). Fetching encrypted passwords.");
                foreach (var node in nodes)
                {
                    try {
                        if (!node.IsSelf)
                        {
                            var getUrl   = $"http://{node.IPAddress}:5100/remoteSigner/__internal/__getUnlockPasswords";
                            var postUrl  = $"http://localhost:5100/remoteSigner/__internal/__postEncryptedPasswords";
                            var jsonData = await Tools.Get(getUrl);

                            var keys = JsonConvert.DeserializeObject <Dictionary <string, string> >(jsonData);
                            Logger.Log(RancherThreadLog, $"Got {keys.Keys.Count} passwords for node {node.IPAddress}. Adding to local password holder.");
                            await Tools.Post(postUrl, jsonData);
                        }
                    } catch (Exception e) {
                        Logger.Error(RancherThreadLog, $"Error checking node passwords: {e.Message}");
                    }
                }
                Logger.Log(RancherThreadLog, $"Passwords added. Triggering local unlock.");
                await Tools.Get("http://localhost:5100/remoteSigner/__internal/__triggerKeyUnlock");
            } catch (Exception e) {
                Logger.Error(RancherThreadLog, $"There was an error checking for other nodes: {e.Message}");
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            Logger.GlobalEnableDebug = true;
            if (Configuration.EnableRethinkSKS)
            {
                var dm = DatabaseManager.GlobalDm.GetConnection();
                Logger.Log("Application", $"Database Hostname: {dm.Hostname}");
            }
            RancherThread rt = new RancherThread();

            RancherManager.Init();
            if (RancherManager.InRancher)
            {
                Logger.Log("Application", "Running in rancher. Starting Rancher Sentinel.");
                rt.Start();
            }
            Http httpServer = new Http(Configuration.HttpPort);

            httpServer.StartSync();
        }