Ejemplo n.º 1
0
 public int Connect(Connector conn)
 {
     int retval;
     retval = conn.Connect(this);
     return retval;
 }
Ejemplo n.º 2
0
 private int ReadFile(string filename)
 {
     string[] configfile;
     try
     {
         configfile = System.IO.File.ReadAllLines(filename);
     }
     catch
     {
         Runner.DebugMessage("Debug.Error.Trackfile", "File not found: " + filename.ToString());
         return 1;
     }
     Boolean firstline = true;
     foreach (string line in configfile)
     {
         string LineType;
         if (line.Length != 0)
         {
             LineType = line.Substring(0, 1);
         }
         else
         {
             LineType = "EMPTY";
         }
         if (firstline == true)
         {
             firstline = false;
             string[] chunks = line.Split('!');
             if (LineType == "I")
             {
                 this._versiontype = chunks[1];
                 this._createddate = chunks[2];
                 this._lastmodifieddate = chunks[3];
                 this._name = chunks[4];
                 this._nethash = chunks[5];
             }
         }
         else
         {
             switch (this._versiontype)
             {
                 case "1.1":
                     string[] chunks = line.Split('!');
                     string UUID;
                     string keystring;
                     Node scratch;
                     switch (chunks[0])
                     {
                         case "#":
                             break;
                         case "EMPTY":
                             break;
                         case "N":
                             UUID = chunks[1];
                             if (UUID != Node.UUID.ToString())
                             {
                                 scratch = this.NodeInit(UUID);
                                 scratch.Name = chunks[2];
                             }
                             break;
                         case "C":
                             UUID = chunks[1];
                             if (UUID != Node.UUID.ToString())
                             {
                                 scratch = this.NodeInit(UUID);
                                 string connectorstring = line.Replace("C!" + chunks[1] + "!", "");
                                 Connector scratchconnector = new Connector(connectorstring);
                                 scratchconnector.Type = Connector.ConnectorTypes.Connect;
                                 scratch.ConnectorList.Add(scratchconnector.Key(), scratchconnector);
                             }
                             break;
                         case "A":
                             UUID = chunks[1];
                             if (UUID != Node.UUID.ToString())
                             {
                                 scratch = this.NodeInit(UUID);
                                 keystring = line.Replace("A!" + chunks[1] + "!" + chunks[2] + "!" + chunks[3] + "!", "");
                                 Auth auth = new Auth(keystring, BoolUnpack(chunks[3]), BoolUnpack(chunks[4]));
                                 scratch.AuthKeyList.Add(auth.UUID, auth);
                             }
                             break;
                         case "E":
                             UUID = chunks[1];
                             keystring = line.Replace("E!" + chunks[1] + "!" + chunks[2] + "!" + chunks[3] + "!", "");
                             this.Enrollment.Add(UUID, new Auth(keystring, BoolUnpack(chunks[2]), BoolUnpack(chunks[3])));
                             break;
                     }
                     break;
             }
         }
     }
     string message = "Enrollment Keys";
     foreach (KeyValuePair<string, Auth> enrolled in this.Enrollment)
     {
         message += "\n\t" + enrolled.Value.Key.ToString();
     }
     SimpleMesh.Service.Runner.DebugMessage("Debug.Info.Trackfile", message);
     foreach (KeyValuePair<string, Node> line in this.NodeList)
     {
         Node scratch = line.Value;
         message = "Name=\t" + scratch.Name;
         message += "\nUUID=\t" + scratch.UUID;
         message += "\nAuthentication:";
         foreach (KeyValuePair<UUID, Auth> auth in scratch.AuthKeyList)
         {
             message += "\n\t" + auth.Value.Key.ToString();
         }
         message += "\nConnectors:";
         foreach (KeyValuePair<string, Connector> connector in scratch.ConnectorList)
         {
             message += "\n\t" + connector.Value.ToString();
         }
         SimpleMesh.Service.Runner.DebugMessage("Debug.Info.Trackfile", message);
     }
     this._new = false;
     return 0;
 }